Browse Source

HPCC-9638 Filter "Clear" does not reset some drop down controls

Fixed TargetSelectWidget to detect "null".
Re-factored Select controls into TargetSelectWidget.

Fixes HPCC-9638

Signed-off-by: Gordon Smith <gordon.smith@lexisnexis.com>
Gordon Smith 12 years ago
parent
commit
79a1600bf7

+ 7 - 13
esp/files/scripts/GetDFUWorkunitsWidget.js

@@ -73,11 +73,13 @@ define([
         workunitsTab: null,
         workunitsGrid: null,
         clusterTargetSelect: null,
+        stateTargetSelect: null,
 
         postCreate: function (args) {
             this.inherited(arguments);
             this.workunitsTab = registry.byId(this.id + "_Workunits");
             this.clusterTargetSelect = registry.byId(this.id + "ClusterTargetSelect");
+            this.stateSelect = registry.byId(this.id + "StateSelect");
         },
 
         startup: function (args) {
@@ -221,6 +223,10 @@ define([
                 Groups: true,
                 includeBlank: true
             });
+            this.stateSelect.init({
+                DFUState: true,
+                includeBlank: true
+            });
             this.selectChild(this.workunitsTab, true);
         },
 
@@ -300,7 +306,7 @@ define([
                 this.menuFilterState = this.addMenuItem(pSubMenu, {
                     onClick: function (args) {
                         context.clearFilter();
-                        registry.byId(context.id + "State").set("value", context.menuFilterState.get("hpcc_value"));
+                        registry.byId(context.id + "StateSelect").set("value", context.menuFilterState.get("hpcc_value"));
                         context.applyFilter();
                     }
                 });
@@ -412,18 +418,6 @@ define([
                 title: "Filter",
                 content: "No filter criteria specified."
             });
-            var stateOptions = [{
-                label: "any",
-                value: ""
-            }];
-            for (var key in FileSpray.States) {
-                stateOptions.push({
-                    label: FileSpray.States[key],
-                    value: FileSpray.States[key]
-                });
-            }
-            var stateSelect = registry.byId(this.id + "State");
-            stateSelect.addOption(stateOptions);
         },
 
         refreshGrid: function (args) {

+ 58 - 35
esp/files/scripts/TargetSelectWidget.js

@@ -26,11 +26,13 @@ require([
     "dijit/registry",
 
     "hpcc/WsTopology",
+    "hpcc/WsWorkunits",
+    "hpcc/FileSpray",
 
     "dojo/text!./templates/TargetSelectWidget.html"
 ], function (declare, lang, arrayUtil, dom,
     _LayoutWidget, _TemplatedMixin, _WidgetsInTemplateMixin, Select, registry,
-    WsTopology,
+    WsTopology, WsWorkunits, FileSpray,
     template) {
     return declare("TargetSelectWidget", [_LayoutWidget, _TemplatedMixin, _WidgetsInTemplateMixin], {
         templateString: template,
@@ -66,17 +68,26 @@ require([
             if (this.initalized)
                 return;
             this.initalized = true;
+            this.targetSelectControl.options = [];
 
             if (params.Target) {
                 this._value = params.Target;
             }
             if (params.includeBlank) {
                 this.includeBlank = params.includeBlank;
+                this.targetSelectControl.options.push({
+                    label: "&nbsp;",
+                    value: ""
+                });
             }
             if (params.Groups === true) {
                 this.loadGroups();
             } else if (params.DropZones === true) {
                 this.loadDropZones();
+            } else if (params.WUState === true) {
+                this.loadWUState();
+            } else if (params.DFUState === true) {
+                this.loadDFUState();
             } else {
                 this.loadTargets();
             }
@@ -109,6 +120,9 @@ require([
         },
 
         _setValueAttr: function (target) {
+            if (target === null) {
+                target = "";
+            }
             if (target !== null && this._value != target) {
                 this._value = target;
                 this.targetSelectControl.set("value", target);
@@ -123,19 +137,19 @@ require([
             return this._value;
         },
 
+        resetDefaultSelection: function () {
+            if (this._value == "") {
+                this._value = this.targetSelectControl.options[0].value;
+            }
+            this.targetSelectControl.set("value", this._value);
+        },
+
         loadDropZones: function () {
             var context = this;
             WsTopology.TpServiceQuery({
                 load: function (response) {
                     if (lang.exists("TpServiceQueryResponse.ServiceList.TpDropZones.TpDropZone", response)) {
                         var targetData = response.TpServiceQueryResponse.ServiceList.TpDropZones.TpDropZone;
-                        context.targetSelectControl.options = [];
-                        if (context.includeBlank) {
-                            context.targetSelectControl.options.push({
-                                label: "",
-                                value: ""
-                            });
-                        }
                         for (var i = 0; i < targetData.length; ++i) {
                             context.targetSelectControl.options.push({
                                 label: targetData[i].Name,
@@ -143,11 +157,7 @@ require([
                                 machine: targetData[i].TpMachines.TpMachine[0]
                             });
                         }
-
-                        if (context._value == "") {
-                            context._value = context.targetSelectControl.options[0].value;
-                        }
-                        context.targetSelectControl.set("value", context._value);
+                        context.resetDefaultSelection();
                     }
                 }
             });
@@ -159,42 +169,56 @@ require([
                 load: function (response) {
                     if (lang.exists("TpGroupQueryResponse.TpGroups.TpGroup", response)) {
                         var targetData = response.TpGroupQueryResponse.TpGroups.TpGroup;
-                        context.targetSelectControl.options = [];
-                        if (context.includeBlank) {
-                            context.targetSelectControl.options.push({
-                                label: "",
-                                value: ""
-                            });
-                        }
                         for (var i = 0; i < targetData.length; ++i) {
                             context.targetSelectControl.options.push({
                                 label: targetData[i].Name,
                                 value: targetData[i].Name
                             });
                         }
-
-                        if (context._value == "") {
-                            context._value = context.targetSelectControl.options[0].value;
-                        }
-                        context.targetSelectControl.set("value", context._value);
+                        context.resetDefaultSelection();
                     }
                 }
             });
         },
 
+        loadWUState: function() {
+            for (var key in WsWorkunits.States) {
+                this.targetSelectControl.options.push({
+                    label: WsWorkunits.States[key],
+                    value: WsWorkunits.States[key]
+                });
+            }
+            this.resetDefaultSelection();
+        },
+
+        loadDFUState: function () {
+            for (var key in FileSpray.States) {
+                this.targetSelectControl.options.push({
+                    label: FileSpray.States[key],
+                    value: FileSpray.States[key]
+                });
+            }
+            this.resetDefaultSelection();
+        },
+
+        LogicalFileSearchType: function() {
+            this.targetSelectControl.options.push({
+                label: "Created",
+                value: "Created"
+            });
+            this.targetSelectControl.options.push({
+                label: "Used",
+                value: "Referenced"
+            });
+            this.resetDefaultSelection();
+        },
+
         loadTargets: function () {
             var context = this;
             WsTopology.TpTargetClusterQuery({
                 load: function (response) {
                     if (lang.exists("TpTargetClusterQueryResponse.TpTargetClusters.TpTargetCluster", response)) {
                         var targetData = response.TpTargetClusterQueryResponse.TpTargetClusters.TpTargetCluster;
-                        context.targetSelectControl.options = [];
-                        if (context.includeBlank) {
-                            context.targetSelectControl.options.push({
-                                label: "",
-                                value: ""
-                            });
-                        }
                         var has_hthor = false;
                         for (var i = 0; i < targetData.length; ++i) {
                             context.targetSelectControl.options.push({
@@ -208,13 +232,12 @@ require([
 
                         if (!context.includeBlank && context._value == "") {
                             if (has_hthor) {
-                                context.setValue("hthor");
+                                context._value = "hthor";
                             } else {
                                 context._value = context.targetSelectControl.options[0].value;
                             }
-                        } else {
-                            context.targetSelectControl.set("value", context._value);
                         }
+                        context.resetDefaultSelection();
                     }
                 }
             });

+ 16 - 15
esp/files/scripts/WUQueryWidget.js

@@ -74,6 +74,8 @@ define([
 
         workunitsTab: null,
         workunitsGrid: null,
+        clusterTargetSelect: null,
+        stateSelect: null,
 
         validateDialog: null,
 
@@ -81,6 +83,8 @@ define([
             this.inherited(arguments);
             this.workunitsTab = registry.byId(this.id + "_Workunits");
             this.clusterTargetSelect = registry.byId(this.id + "ClusterTargetSelect");
+            this.stateSelect = registry.byId(this.id + "StateSelect");
+            this.logicalFileSearchTypeSelect = registry.byId(this.id + "LogicalFileSearchType");
         },
 
         startup: function (args) {
@@ -203,7 +207,7 @@ define([
         //  Implementation  ---
         clearFilter: function () {
             arrayUtil.forEach(registry.byId(this.id + "FilterForm").getDescendants(), function (item, idx) {
-                item.set('value', null);
+                item.set("value", null);
             });
         },
 
@@ -220,7 +224,6 @@ define([
         getFilter: function () {
             var retVal = domForm.toObject(this.id + "FilterForm");
             lang.mixin(retVal, {
-                Cluster: this.clusterTargetSelect.get("value"),
                 StartDate: this.getISOString("FromDate", "FromTime"),
                 EndDate: this.getISOString("ToDate", "ToTime")
             });
@@ -250,6 +253,16 @@ define([
                 includeBlank: true,
                 Target: params.Cluster
             });
+            this.stateSelect.init({
+                WUState: true,
+                includeBlank: true,
+                Target: ""
+            });
+            this.logicalFileSearchTypeSelect.init({
+                LogicalFileSearchType: true,
+                includeBlank: true,
+                Target: ""
+            });
 
             this.initWorkunitsGrid();
             this.selectChild(this.workunitsTab, true);
@@ -335,7 +348,7 @@ define([
                 this.menuFilterState = this.addMenuItem(pSubMenu, {
                     onClick: function (args) {
                         context.clearFilter();
-                        registry.byId(context.id + "State").set("value", context.menuFilterState.get("hpcc_value"));
+                        registry.byId(context.id + "StateSelect").set("value", context.menuFilterState.get("hpcc_value"));
                         context.applyFilter();
                     }
                 });
@@ -436,18 +449,6 @@ define([
                 title: "Filter",
                 content: "No filter criteria specified."
             });
-            var stateOptions = [{
-                label: "any",
-                value: ""
-            }];
-            for (var key in WsWorkunits.States) {
-                stateOptions.push({
-                    label: WsWorkunits.States[key],
-                    value: WsWorkunits.States[key]
-                });
-            }
-            var stateSelect = registry.byId(this.id + "State");
-            stateSelect.addOption(stateOptions);
         },
 
         refreshGrid: function (args) {

+ 1 - 2
esp/files/templates/GetDFUWorkunitsWidget.html

@@ -21,8 +21,7 @@
                                     <input id="${id}Owner" title="Owner:" name="Owner" colspan="2" data-dojo-props="trim: true, placeHolder:'jsmi*'" data-dojo-type="dijit.form.TextBox" />
                                     <input id="${id}Jobname" title="Jobname:" name="Jobname" colspan="2" data-dojo-props="trim: true, placeHolder:'log_analysis_1*'" data-dojo-type="dijit.form.TextBox" />
                                     <input id="${id}ClusterTargetSelect" title="Cluster:" name="Cluster" colspan="2" data-dojo-props="trim: true, placeHolder:'r?x*'" data-dojo-type="TargetSelectWidget" />
-                                    <select id="${id}State" title="State" name="StateReq" colspan="2" data-dojo-props="trim: true, placeHolder:'Created'" data-dojo-type="dijit.form.Select">
-                                    </select>
+                                    <input id="${id}StateSelect" title="State" name="StateReq" colspan="2" data-dojo-props="trim: true, placeHolder:'Created'" data-dojo-type="TargetSelectWidget" />
                                     <input id="${id}Type" title="Archived&nbsp;Only" name="Type" value="archived workunits" colspan="2" data-dojo-type="dijit.form.CheckBox" />
                                 </div>
                                 <button data-dojo-attach-event="onClick:_onFilterApply" data-dojo-type="dijit.form.Button">Apply</button>

+ 3 - 8
esp/files/templates/WUQueryWidget.html

@@ -26,16 +26,11 @@
                                     <input id="${id}Wuid" title="WUID:" name="Wuid" colspan="2" data-dojo-props="trim: true, placeHolder:'W20130222-171723'" data-dojo-type="dijit.form.TextBox" />
                                     <input id="${id}Owner" title="Owner:" name="Owner" colspan="2" data-dojo-props="trim: true, placeHolder:'jsmi*'" data-dojo-type="dijit.form.TextBox" />
                                     <input id="${id}Jobname" title="Job&nbsp;Name:" name="Jobname" colspan="2" data-dojo-props="trim: true, placeHolder:'log_analysis_1*'" data-dojo-type="dijit.form.TextBox" />
-                                    <input id="${id}ClusterTargetSelect" title="Cluster:" name="Cluster" colspan="3" data-dojo-props="trim: true, placeHolder:'r?x*'" data-dojo-type="TargetSelectWidget" />
-                                    <select id="${id}State" title="State" name="State" colspan="2" data-dojo-props="trim: true, placeHolder:'Created'" data-dojo-type="dijit.form.Select">
-                                    </select>
+                                    <input id="${id}ClusterTargetSelect" title="Cluster:" name="Cluster" colspan="2" data-dojo-props="trim: true, placeHolder:'r?x*'" data-dojo-type="TargetSelectWidget" />
+                                    <input id="${id}StateSelect" title="State:" name="State" colspan="2" data-dojo-props="trim: true, placeHolder:'Created'" data-dojo-type="TargetSelectWidget" />
                                     <input id="${id}ECL" title="ECL:" name="ECL" colspan="2" data-dojo-props="trim: true, placeHolder:':=dataset*'" data-dojo-type="dijit.form.TextBox" />
                                     <input id="${id}LogicalFile" title="Logical&nbsp;File" name="LogicalFile" colspan="2" data-dojo-props="trim: true, placeHolder:'*::somefile'" data-dojo-type="dijit.form.TextBox" />
-                                    <select id="${id}LogicalFileSearchType" title="Logical&nbsp;File&nbsp;Type" name="LogicalFileSearchType" colspan="2" data-dojo-type="dijit.form.Select">
-                                        <option value="" selected="true"></option>
-                                        <option value="Created">Created</option>
-                                        <option value="Used">Referenced</option>
-                                    </select>
+                                    <input id="${id}LogicalFileSearchType" title="Logical&nbsp;File&nbsp;Type" name="LogicalFileSearchType" colspan="2" data-dojo-type="TargetSelectWidget" />
                                     <input id="${id}FromDate" title="From&nbsp;Date:" name="StartDate" data-dojo-props="trim: true, placeHolder:'7/28/2013'" data-dojo-type="dijit.form.DateTextBox" />
                                     <input id="${id}FromTime" name="FromTime" data-dojo-props="trim: true, placeHolder:'7:30 AM'" data-dojo-type="dijit.form.TimeTextBox" />
                                     <input id="${id}ToDate" title="To&nbsp;Date:" name="EndDate" data-dojo-props="trim: true, placeHolder:'7/28/2013'" data-dojo-type="dijit.form.DateTextBox" />