Commit aba2eb974042cba3724438e6f20345b2d043ed87
1 parent
69ca3676
Exists in
master
and in
16 other branches
Add InsertToTTCatlog to DateZoomIntervalSelection
Showing
5 changed files
with
198 additions
and
13 deletions
Show diff stats
js/app/views/PlotComponents/intervalSelection/DateZoomIntervalSelection.js
1 | 1 | Ext.define('amdaPlotComp.intervalSelection.DateZoomIntervalSelection', { |
2 | 2 | extend: 'amdaPlotComp.intervalSelection.ZoomIntervalSelection', |
3 | + requires: ['amdaPlotComp.intervalSelection.InsertToTTCatlog'], | |
3 | 4 | |
4 | 5 | type: 'timeAxis', |
5 | - title: "Zoom on time axis & Interval selection" | |
6 | + title: "Zoom on time axis & Interval selection", | |
7 | + insertToTTCatlog: null, | |
8 | + | |
9 | + initComponent: function () { | |
10 | + this.callParent(arguments); | |
11 | + this.insertToTTCatlog = new amdaPlotComp.intervalSelection.InsertToTTCatlog({parent: this}); | |
12 | + this.parent.add(this.insertToTTCatlog); | |
13 | + }, | |
6 | 14 | |
7 | 15 | }); |
... | ... |
js/app/views/PlotComponents/intervalSelection/InsertToTTCatlog.js
0 → 100644
... | ... | @@ -0,0 +1,172 @@ |
1 | +Ext.define('amdaPlotComp.intervalSelection.InsertToTTCatlog', { | |
2 | + extend: 'Ext.form.FieldSet', | |
3 | + | |
4 | + collapsible: false, | |
5 | + layout: LAYOUT_STYLE, | |
6 | + title: 'Add in Time Table or Catalog', | |
7 | + name: 'tt-insertion-fieldset', | |
8 | + | |
9 | + fieldTypeTTCat: 'ttcat-type', | |
10 | + fieldTypeName: 'ttcat-name', | |
11 | + ttModuleId: 'timetab-win', | |
12 | + catModuleId: 'catalog-win', | |
13 | + | |
14 | + parent: null, | |
15 | + | |
16 | + initComponent: function () { | |
17 | + const self = this; | |
18 | + | |
19 | + const insertTypeStore = Ext.create('Ext.data.Store', { | |
20 | + fields: ['key', 'name'], | |
21 | + data: [ | |
22 | + { "key": "timeTable", "name": "TimeTable" }, | |
23 | + { "key": "catalog", "name": "Catalog" } | |
24 | + ] | |
25 | + }); | |
26 | + | |
27 | + Ext.apply(self, { | |
28 | + items: [{ | |
29 | + xtype: 'combo', | |
30 | + fieldLabel: 'Insert In', | |
31 | + store: insertTypeStore, | |
32 | + queryMode: 'local', | |
33 | + displayField: 'name', | |
34 | + valueField: 'key', | |
35 | + editable: false, | |
36 | + value: 'timeTable', | |
37 | + name: self.fieldTypeTTCat, | |
38 | + itemId: self.fieldTypeTTCat, | |
39 | + }, | |
40 | + { | |
41 | + xtype: 'textfield', | |
42 | + fieldLabel: 'Name', | |
43 | + name: self.fieldTypeName, | |
44 | + itemId: self.fieldTypeName, | |
45 | + listeners: | |
46 | + { | |
47 | + render: function (o, op) { | |
48 | + var field = this; | |
49 | + var el = this.el; | |
50 | + Ext.create('Ext.dd.DropTarget', el, { | |
51 | + ddGroup: 'explorerTree', | |
52 | + notifyOver: function (ddSource, e, data) { | |
53 | + var TTCatType = self._getFieldTypeTTCat().getValue(); | |
54 | + if (data.records[0].data.leaf && (data.records[0].data.nodeType == TTCatType)) { | |
55 | + this.valid = true; | |
56 | + return this.dropAllowed; | |
57 | + } | |
58 | + this.valid = false; | |
59 | + return this.dropNotAllowed; | |
60 | + }, | |
61 | + notifyDrop: function (ddSource, e, data) { | |
62 | + if (!this.valid) | |
63 | + return false; | |
64 | + field.setValue(data.records[0].get('text')); | |
65 | + return true; | |
66 | + } | |
67 | + }); | |
68 | + } | |
69 | + } | |
70 | + }, | |
71 | + { | |
72 | + xtype: 'button', | |
73 | + width: width, | |
74 | + text: 'Insert Interval', | |
75 | + scope: this, | |
76 | + handler: function () { | |
77 | + var me = this; | |
78 | + | |
79 | + var TTCatType = self._getFieldTypeTTCat().getValue(); | |
80 | + var TTCatName = self._getFieldNameTTCat().getValue(); | |
81 | + | |
82 | + var isCatalog = (TTCatType == 'catalog'); | |
83 | + myDesktopApp.getLoadedModule(isCatalog ? this.catModuleId : this.ttModuleId, true, function (module) { | |
84 | + var targetModuleUI = module.getUiContent(); | |
85 | + if (me.linkedTTCatNode && (me.linkedTTCatNode.get('text') == TTCatName) && (me.linkedTTCatNode.get('nodeType') == TTCatType)) { | |
86 | + if (targetModuleUI) | |
87 | + me.insertInterval(); | |
88 | + else { | |
89 | + me.linkedTTCatNode.editLeaf(function () { | |
90 | + me.insertInterval(); | |
91 | + }); | |
92 | + } | |
93 | + } | |
94 | + else { | |
95 | + var explorerTree = Ext.getCmp(amdaUI.ExplorerUI.RESRC_TAB.TREE_ID); | |
96 | + var ttCatRootNode = explorerTree.getRootNode().findChild('id', isCatalog ? 'catalog-treeRootNode' : 'timeTable-treeRootNode', true); | |
97 | + amdaModel.InteractiveNode.preloadNodes(ttCatRootNode, function () { | |
98 | + var nodeWithSameName = null; | |
99 | + | |
100 | + if (TTCatName != '') | |
101 | + nodeWithSameName = ttCatRootNode.findChild('text', TTCatName, true); | |
102 | + | |
103 | + if (nodeWithSameName !== null) | |
104 | + me.linkedTTCatNode = nodeWithSameName; | |
105 | + else { | |
106 | + module.createLinkedNode(); | |
107 | + module.getLinkedNode().set('text', TTCatName); | |
108 | + me.linkedTTCatNode = module.getLinkedNode(); | |
109 | + var obj = { | |
110 | + name: TTCatName, | |
111 | + fromPlugin: true | |
112 | + }; | |
113 | + if (isCatalog) { | |
114 | + Ext.Msg.prompt('Define Parameters', 'Please enter parameters number for the new catalog:', function (btn, text) { | |
115 | + if (btn == 'ok') { | |
116 | + obj.nbParameters = parseInt(text, 10); | |
117 | + if (isNaN(obj.nbParameters)) { | |
118 | + obj.nbParameters = 1; | |
119 | + } | |
120 | + module.createObject(obj); | |
121 | + me.linkedTTCatNode.editLeaf(function () { | |
122 | + me.insertInterval(); | |
123 | + }); | |
124 | + } | |
125 | + }); | |
126 | + return; | |
127 | + } | |
128 | + else { | |
129 | + module.createObject(obj); | |
130 | + } | |
131 | + } | |
132 | + | |
133 | + me.linkedTTCatNode.editLeaf(function () { | |
134 | + me.insertInterval(); | |
135 | + }); | |
136 | + }); | |
137 | + } | |
138 | + }); | |
139 | + } | |
140 | + } | |
141 | + ] | |
142 | + }); | |
143 | + | |
144 | + self.callParent(arguments); | |
145 | + }, | |
146 | + | |
147 | + | |
148 | + _getFieldTypeTTCat: function () { | |
149 | + return this.down('#' + this.fieldTypeTTCat); | |
150 | + }, | |
151 | + | |
152 | + _getFieldNameTTCat: function () { | |
153 | + return this.down('#' + this.fieldTypeName); | |
154 | + }, | |
155 | + | |
156 | + /** | |
157 | + * add Interval to Time table or Catalog | |
158 | + */ | |
159 | + insertInterval: function () { | |
160 | + const start = this.parent.getField1Value(); | |
161 | + const stop = this.parent.getField2Value(); | |
162 | + | |
163 | + const TTCatType = this._getFieldTypeTTCat().getValue(); | |
164 | + const isCatalog = (TTCatType == 'catalog'); | |
165 | + | |
166 | + myDesktopApp.getLoadedModule(isCatalog ? this.catModuleId : this.ttModuleId, true, function (module) { | |
167 | + var targetModuleUI = module.getUiContent(); | |
168 | + if (targetModuleUI) | |
169 | + targetModuleUI.addInterval(start, stop); | |
170 | + }); | |
171 | + } | |
172 | +}); | |
... | ... |
js/app/views/PlotComponents/intervalSelection/IntervalSelection.js
1 | -// Define the itemIds as constants | |
2 | -// These will be used to reference the fields later in the code | |
3 | -var FIELD1_ITEM_ID = 'field1'; | |
4 | -var FIELD2_ITEM_ID = 'field2'; | |
1 | + | |
5 | 2 | |
6 | 3 | // Define a constant for the layout style of the form |
7 | 4 | const LAYOUT_STYLE = { |
... | ... | @@ -10,6 +7,8 @@ const LAYOUT_STYLE = { |
10 | 7 | align: 'stretch' // each child item is stretched to fill the width of the container |
11 | 8 | }; |
12 | 9 | |
10 | +const width = 100; | |
11 | + | |
13 | 12 | // Define the parent class |
14 | 13 | Ext.define('amdaPlotComp.intervalSelection.IntervalSelection', { |
15 | 14 | extend: 'Ext.window.Window', // This class extends from Ext.window.Window |
... | ... | @@ -29,13 +28,18 @@ Ext.define('amdaPlotComp.intervalSelection.IntervalSelection', { |
29 | 28 | config: { |
30 | 29 | field1Type: 'datefield', // The xtype of field1. By default is datefield because we are working with time series. |
31 | 30 | field1Label: 'Start Time', // The label of field1. |
32 | - field1Format: 'Y/m/d H:i:s.u', | |
31 | + field1Format: 'Y/m/d H:i:s.u', | |
33 | 32 | field2Type: 'datefield', // The xtype of field2. By default is datefield. |
34 | 33 | field2Label: 'Stop Time', // The label of field2. |
35 | - field2Format: 'Y/m/d H:i:s.u', | |
34 | + field2Format: 'Y/m/d H:i:s.u', | |
36 | 35 | buttonApply: 'Apply' |
37 | 36 | }, |
38 | 37 | |
38 | + // Define the itemIds as constants | |
39 | + // These will be used to reference the fields later in the code | |
40 | + FIELD1_ITEM_ID: 'field1', | |
41 | + FIELD2_ITEM_ID: 'field2', | |
42 | + | |
39 | 43 | initComponent: function () { |
40 | 44 | const me = this; // Reference to this instance for use in event handlers |
41 | 45 | |
... | ... | @@ -55,13 +59,13 @@ Ext.define('amdaPlotComp.intervalSelection.IntervalSelection', { |
55 | 59 | items: [{ |
56 | 60 | xtype: this.field1Type, |
57 | 61 | fieldLabel: this.field1Label, |
58 | - itemId: FIELD1_ITEM_ID, | |
62 | + itemId: this.FIELD1_ITEM_ID, | |
59 | 63 | format: this.field1Format |
60 | 64 | }, |
61 | 65 | { |
62 | 66 | xtype: this.field2Type, |
63 | 67 | fieldLabel: this.field2Label, |
64 | - itemId: FIELD2_ITEM_ID, | |
68 | + itemId: this.FIELD2_ITEM_ID, | |
65 | 69 | format: this.field2Format, |
66 | 70 | listeners: { |
67 | 71 | change: function (field, newValue) { |
... | ... | @@ -80,6 +84,7 @@ Ext.define('amdaPlotComp.intervalSelection.IntervalSelection', { |
80 | 84 | }, { |
81 | 85 | xtype: 'button', |
82 | 86 | text: 'Reset', |
87 | + width: width, | |
83 | 88 | handler: function () { |
84 | 89 | me._getField1().reset(); |
85 | 90 | me._getField2().reset(); |
... | ... | @@ -120,11 +125,11 @@ Ext.define('amdaPlotComp.intervalSelection.IntervalSelection', { |
120 | 125 | }, |
121 | 126 | |
122 | 127 | _getField1: function () { |
123 | - return this.parent.down('#' + FIELD1_ITEM_ID); | |
128 | + return this.parent.down('#' + this.FIELD1_ITEM_ID); | |
124 | 129 | }, |
125 | 130 | |
126 | 131 | _getField2: function () { |
127 | - return this.parent.down('#' + FIELD2_ITEM_ID); | |
132 | + return this.parent.down('#' + this.FIELD2_ITEM_ID); | |
128 | 133 | }, |
129 | 134 | |
130 | 135 | getField1Value: function () { |
... | ... |
js/app/views/PlotComponents/intervalSelection/PlotFunctionIntervalSelection.js
... | ... | @@ -13,7 +13,7 @@ Ext.define('amdaPlotComp.intervalSelection.PlotFunctionIntervalSelection', { |
13 | 13 | |
14 | 14 | _apply: function () { |
15 | 15 | if (this._notValidValues()) { |
16 | - myDesktopApp.warningMsg('The Input Values are not defined'); | |
16 | + myDesktopApp.warningMsg('Please note that either the Start Time or the Stop Time has not been defined. To proceed, ensure both times are properly set.'); | |
17 | 17 | } else { |
18 | 18 | let request_to_send = {}; |
19 | 19 | request_to_send = Object.assign({}, this.plotFunctionType.getValues()); |
... | ... |
js/app/views/PlotComponents/intervalSelection/ZoomIntervalSelection.js
... | ... | @@ -9,7 +9,7 @@ Ext.define('amdaPlotComp.intervalSelection.ZoomIntervalSelection', { |
9 | 9 | this.callParent(arguments); |
10 | 10 | this.parent.getDockedItems('toolbar[dock="bottom"]')[0].add({ |
11 | 11 | xtype: 'button', |
12 | - width: 100, | |
12 | + width: width, | |
13 | 13 | text: 'Undo Zoom', |
14 | 14 | handler: function () { |
15 | 15 | me._undoZoom(); |
... | ... |