issue #23796 - first pass exports the parent record, not the attr in the gridbox
authorGil Moskowitz <gmoskowitz@xtuple.com>
Wed, 11 Jun 2014 13:59:22 +0000 (09:59 -0400)
committerGil Moskowitz <gmoskowitz@xtuple.com>
Wed, 11 Jun 2014 13:59:22 +0000 (09:59 -0400)
lib/enyo-x/source/views/grid_box.js
lib/enyo-x/source/views/workspace.js

index 35b9ab9..de85aa9 100644 (file)
@@ -239,7 +239,8 @@ trailing:true, white:true, strict: false*/
     kind: "XV.Groupbox",
     classes: "panel xv-grid-box",
     events: {
-      onChildWorkspace: ""
+      onChildWorkspace: "",
+      onExportAttr:     ""
     },
     handlers: {
       ontap: "buttonTapped",
@@ -345,13 +346,13 @@ trailing:true, white:true, strict: false*/
         ]}
       );
 
-      // "New" button
       components.push({
         kind: "FittableColumns",
         name: "navigationButtonPanel",
         classes: "xv-buttons",
         components: [
-          {kind: "onyx.Button", name: "newButton", onclick: "newItem", classes: "icon-plus"}
+          {kind: "onyx.Button", name: "newButton", onclick: "newItem", classes: "icon-plus"},
+          {kind: "font.TextIcon", name: "exportButton", onclick: "exportAttr", icon: "share", content: "_export".loc()} // TODO: classes?
         ]
       });
 
@@ -527,6 +528,12 @@ trailing:true, white:true, strict: false*/
       editor.render();
       editor.setFirstFocus();
     },
+    exportAttr: function(inSender, inEvent) {
+      var gridbox = inEvent.originator.parent.parent.parent;
+      this.doExportAttr({ recordType: gridbox.parent.parent.model,
+                          uuid:       gridbox.parent.parent.value.attributes.uuid,
+                          attr:       gridbox.attr });
+    },
     refreshLists: function () {
       this.$.aboveGridList.refresh();
       this.$.belowGridList.refresh();
index a913e9f..93a9684 100644 (file)
@@ -656,7 +656,8 @@ trailing:true, white:true, strict: false*/
       onReport: "report",
       onStatusChange: "statusChanged",
       onTitleChange: "titleChanged",
-      onSaveTextChange: "saveTextChanged"
+      onSaveTextChange: "saveTextChanged",
+      onExportAttr:     "exportAttr"
     },
     components: [
       {kind: "FittableRows", name: "navigationPanel", classes: "xv-menu-container", components: [
@@ -1052,6 +1053,29 @@ trailing:true, white:true, strict: false*/
     saveTextChanged: function (inSender, inEvent) {
       this.$.saveButton.setContent(inEvent.content);
     },
+
+    exportAttr: function (inSender, inEvent) {
+      this.openExportTab('export', inEvent.recordType, inEvent.uuid, inEvent.attr);
+      return true;
+    },
+
+    // export the data for just one attr of the model displayed by the workspace
+    openExportTab: function (routeName, recordType, id, attr) {
+      console.log('workspace exportAttr ' + recordType + '/' + attr + '(' + id + ')');
+      var query = { parameters: [{ attribute: "uuid", value: id }] };
+      // TODO: limit the data treated to just           attribute: attr
+
+      // sending the locale information back over the wire saves a call to the db
+      window.open(XT.getOrganizationPath() +
+        '/%@?details={"nameSpace":"%@","type":"%@","query":%@,"culture":%@,"print":%@}'
+        .f(routeName,
+          recordType.prefix(),
+          recordType.suffix(),
+          JSON.stringify(query),
+          JSON.stringify(XT.locale.culture),
+          "false"),
+        '_newtab');
+    },
     /**
      This is called for each row in the menu List.
      The menu text is derived from the corresponding panel index.