Advertisement
Guest User

Untitled

a guest
Mar 25th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. export default Marionette.LayoutView.extend({
  2. name: "InventoryDetailContainer",
  3. template,
  4. collection: new InventoryItemCollection(),
  5. regions: {
  6. details: "[data-hook='inventory_details']"
  7. },
  8. ui: {
  9. noInventoryAttention: "[data-hook='no-inventory-attention']"
  10. },
  11. initialize(options) {
  12. this.collection._id = options.inventoryItemsUrl;
  13. this.collection.fetch().done(() => {
  14. this.showGrid();
  15. });
  16. },
  17. showGrid() {
  18. if (this.collection.length > 0) {
  19. $(this.ui.noInventoryAttention).addClass("is-hidden");
  20. this.inventoryGridView = new InventoryView({
  21. collection: this.collection
  22. });
  23. this.details.show(this.inventoryGridView);
  24. } else {
  25. $(this.details).empty();
  26. $(this.ui.noInventoryAttention).removeClass("is-hidden");
  27. }
  28. },
  29.  
  30. saveRecipeItemModel() {
  31. //temp values
  32. const recipeItemUrl = `/BaseURL/SampleURL`;
  33. const models = [];
  34. models.push(new InventoryItemModel({ code: "Test" }));
  35. models.push(new InventoryItemModel({ code: "Test2" }));
  36.  
  37. const recipeItemModel = new RecipeItemModel({ _id: recipeItemUrl });
  38. recipeItemModel.relationships = {
  39. inventoryItems: {
  40. data: models
  41. }
  42. };
  43. this.recipeItemModel.save().done(response => {
  44. console.log(response);
  45. });
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement