Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- export default Marionette.LayoutView.extend({
- name: "InventoryDetailContainer",
- template,
- collection: new InventoryItemCollection(),
- regions: {
- details: "[data-hook='inventory_details']"
- },
- ui: {
- noInventoryAttention: "[data-hook='no-inventory-attention']"
- },
- initialize(options) {
- this.collection._id = options.inventoryItemsUrl;
- this.collection.fetch().done(() => {
- this.showGrid();
- });
- },
- showGrid() {
- if (this.collection.length > 0) {
- $(this.ui.noInventoryAttention).addClass("is-hidden");
- this.inventoryGridView = new InventoryView({
- collection: this.collection
- });
- this.details.show(this.inventoryGridView);
- } else {
- $(this.details).empty();
- $(this.ui.noInventoryAttention).removeClass("is-hidden");
- }
- },
- saveRecipeItemModel() {
- //temp values
- const recipeItemUrl = `/BaseURL/SampleURL`;
- const models = [];
- models.push(new InventoryItemModel({ code: "Test" }));
- models.push(new InventoryItemModel({ code: "Test2" }));
- const recipeItemModel = new RecipeItemModel({ _id: recipeItemUrl });
- recipeItemModel.relationships = {
- inventoryItems: {
- data: models
- }
- };
- this.recipeItemModel.save().done(response => {
- console.log(response);
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement