issue #23965: move dashboard to its own module
authorSteve Hackbarth <stephenhackbarth@gmail.com>
Fri, 20 Jun 2014 02:10:22 +0000 (22:10 -0400)
committerSteve Hackbarth <stephenhackbarth@gmail.com>
Fri, 20 Jun 2014 02:10:22 +0000 (22:10 -0400)
enyo-client/database/source/xm/javascript/system.sql
enyo-client/extensions/source/crm/client/postbooks.js
enyo-client/extensions/source/crm/client/views/dashboard.js [deleted file]
enyo-client/extensions/source/crm/client/views/package.js
enyo-client/extensions/source/sales/client/postbooks.js
enyo-client/extensions/source/sales/client/views/dashboard.js [deleted file]
enyo-client/extensions/source/sales/client/views/package.js
lib/enyo-x/source/views/dashboard.js

index 6ee1406..1759f6a 100644 (file)
@@ -9,7 +9,7 @@ select xt.install_js('XM','System','xtuple', $$
     "CCCompany",
     "CCTest",
     "CCRequireCCV",
-    "DashboardsLite",
+    "DashboardLite",
     "DefaultPriority",
     "RequireProjectAssignment",
     "UseProjects"
index 51665d0..78d5771 100644 (file)
@@ -62,8 +62,23 @@ trailing:true, white:true*/
       ]
     };
 
-    if (XT.session.settings.get("DashboardsLite")) {
-      module.panels.unshift({name: "crmDashboard", kind: "XV.CrmDashboard"});
+    if (XT.session.settings.get("DashboardLite")) {
+      var dashboardModule = {
+        name: "dashboardLite",
+        label: "_dashboard".loc(),
+        panels: [
+          {
+            name: "dashboardLite",
+            kind: "XV.DashboardLite",
+            newActions: [
+              {name: "assignedIncidents", label: "_assignedIncidents".loc(), item: "XV.AssignedIncidentBarChart"},
+              {name: "opportunities", label: "_opportunities".loc(), item: "XV.OpportunityBarChart"}
+            ]
+          }
+        ]
+      };
+
+      XT.app.$.postbooks.insertModule(dashboardModule, 0);
     }
 
     isBiAvailable = XT.session.config.biAvailable && XT.session.privileges.get("ViewSalesHistory");
diff --git a/enyo-client/extensions/source/crm/client/views/dashboard.js b/enyo-client/extensions/source/crm/client/views/dashboard.js
deleted file mode 100644 (file)
index 7c89865..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-/*jshint bitwise:true, indent:2, curly:true, eqeqeq:true, immed:true,
-latedef:true, newcap:true, noarg:true, regexp:true, undef:true,
-trailing:true, white:true*/
-/*global XT:true, XM:true, XV:true, _:true, window: true, enyo:true, nv:true, d3:true, console:true */
-
-(function () {
-
-  enyo.kind({
-    name: "XV.CrmDashboard",
-    kind: "XV.Dashboard",
-    collection: "XM.UserChartCollection",
-    // this tells the default query what extension to pull charts for
-    extension: "crm",
-    // title is what show in the "add chart" picker on the
-    // dashboard and the chart is the widget to be added
-    newActions: [
-      {name: "assignedIncidents", label: "_assignedIncidents".loc(), item: "XV.AssignedIncidentBarChart"},
-      {name: "opportunities", label: "_opportunities".loc(), item: "XV.OpportunityBarChart"}
-    ]
-  });
-}());
index 75b7cc7..825df5b 100644 (file)
@@ -1,6 +1,5 @@
 enyo.depends(
   "list_relations.js",
   "list_relations_box.js",
-  "dashboard.js",
   "workspace.js"
 );
index 3cc54cb..583fe69 100644 (file)
@@ -1,7 +1,7 @@
 /*jshint bitwise:true, indent:2, curly:true, eqeqeq:true, immed:true,
 latedef:true, newcap:true, noarg:true, regexp:true, undef:true,
 trailing:true, white:true*/
-/*global XT:true, XV:true, XM:true, enyo:true, console:true */
+/*global XT:true, XV:true, XM:true, enyo:true, console:true, _:true */
 
 (function () {
 
@@ -67,6 +67,37 @@ trailing:true, white:true*/
       ]
     };
 
+    if (XT.session.settings.get("DashboardLite")) {
+      // TODO if we commit to this approach it would make sense to move this code into
+      // XT.app.$.postbooks.insertDashboardCharts() or something like it
+      var newActions = [
+        {name: "salesHistory", label: "_salesHistory".loc(), item: "XV.SalesHistoryTimeSeriesChart"},
+        {name: "bookings", label: "_bookings".loc(), item: "XV.SalesOrderTimeSeriesChart"}
+      ];
+      var preExistingDashboard = _.find(XT.app.$.postbooks.modules, function (module) {
+        return module.name === "dashboardLite";
+      });
+
+      if (preExistingDashboard) {
+        preExistingDashboard.panels[0].newActions = _.union(preExistingDashboard.panels[0].newActions, newActions);
+
+      } else {
+        var dashboardModule = {
+          name: "dashboardLite",
+          label: "_dashboard".loc(),
+          panels: [
+            {
+              name: "dashboardLite",
+              kind: "XV.DashboardLite",
+              newActions: newActions
+            }
+          ]
+        };
+
+        XT.app.$.postbooks.insertModule(dashboardModule, 0);
+      }
+    }
+
     isBiAvailable = XT.session.config.biAvailable && XT.session.privileges.get("ViewSalesHistory");
     if (isBiAvailable) {
       module.panels.push({name: "salesAnalysisPage", kind: "analysisFrame"});
diff --git a/enyo-client/extensions/source/sales/client/views/dashboard.js b/enyo-client/extensions/source/sales/client/views/dashboard.js
deleted file mode 100644 (file)
index 1874e6d..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*jshint bitwise:true, indent:2, curly:true, eqeqeq:true, immed:true,
-latedef:true, newcap:true, noarg:true, regexp:true, undef:true,
-trailing:true, white:true*/
-/*global XT:true, XM:true, XV:true, _:true, window: true, enyo:true, nv:true, d3:true, console:true */
-
-(function () {
-
-  enyo.kind({
-    name: "XV.SalesDashboard",
-    kind: "XV.Dashboard",
-    collection: "XM.UserChartCollection",
-    // title is what show in the "add chart" picker on the
-    // dashboard and the chart is the widget to be added
-    // this tells the default query what extension to pull charts for
-    extension: "sales",
-    newActions: [
-      {name: "salesHistory", label: "_salesHistory".loc(), item: "XV.SalesHistoryTimeSeriesChart"},
-      {name: "bookings", label: "_bookings".loc(), item: "XV.SalesOrderTimeSeriesChart"}
-    ]
-  });
-
-}());
index 4398429..7a12635 100644 (file)
@@ -2,6 +2,5 @@ enyo.depends(
   "list.js",
   "list_relations.js",
   "list_relations_box.js",
-  "dashboard.js",
   "workspace.js"
 );
index 1e8f9cf..30ea218 100644 (file)
@@ -250,4 +250,14 @@ trailing:true, white:true*/
     }
   });
 
+  enyo.kind({
+    name: "XV.DashboardLite",
+    kind: "XV.Dashboard",
+    collection: "XM.UserChartCollection",
+    // this tells the default query what extension to pull charts for
+    extension: "crm",
+    // title is what show in the "add chart" picker on the
+    // dashboard and the chart is the widget to be added
+    newActions: [] // to be added by extensions
+  });
 }());