Merge pull request #1128 from shackbarth/22103
authorTravis Webb <travis@traviswebb.com>
Wed, 11 Dec 2013 16:43:48 +0000 (08:43 -0800)
committerTravis Webb <travis@traviswebb.com>
Wed, 11 Dec 2013 16:43:48 +0000 (08:43 -0800)
issue #22103: allow billing to load without sales

enyo-client/extensions/source/billing/client/postbooks.js
lib/enyo-x/source/views/module_container.js

index 8ef96e7..2accd75 100644 (file)
@@ -50,9 +50,7 @@
         description: "_billingDescription".loc(),
         workspace: "XV.BillingWorkspace"
       },
-      salesPanels = [
-        {name: "sales_invoiceList", kind: "XV.InvoiceList"}
-      ],
+      salesPanels,
       setupPanels = [
         {name: "bankAccountList", kind: "XV.BankAccountList"},
         {name: "reasonCodeList", kind: "XV.ReasonCodeList"},
       ];
 
     XT.app.$.postbooks.appendPanels("setup", setupPanels);
-    XT.app.$.postbooks.appendPanels("sales", salesPanels);
+    if (XT.extensions.sales) {
+      salesPanels = [
+        {name: "sales_invoiceList", kind: "XV.InvoiceList"}
+      ];
+      XT.app.$.postbooks.appendPanels("sales", salesPanels);
+    }
 
     XM.configurations.add(new XM.ConfigurationModel(configuration));
     XT.app.$.postbooks.insertModule(module, 0);
index 71137c5..88da3ff 100644 (file)
@@ -110,8 +110,15 @@ trailing:true, white:true*/
         module = _.find(modules, function (mod) {
           return mod.name === moduleName;
         }),
-        existing = _.pluck(module.panels, "name"),
+        existing,
         i;
+
+      if (!module) {
+        // crash coming soon!
+        XT.log("Error: trying to insert panel into nonexistent module", moduleName);
+      }
+      existing = _.pluck(module.panels, "name");
+
       for (i = 0; i < panels.length; i++) {
         if (!_.contains(existing, panels[i].name)) {
           if (first) {