Commit 2b1b3d603d61e629676f4e459feab3763d9c1cdf
1 parent
d7558ac5
Exists in
master
and in
17 other branches
Create a base component for interval selection.
Showing
3 changed files
with
164 additions
and
1 deletions
Show diff stats
js/app/views/PlotComponents/PlotZoomPlug.js
... | ... | @@ -17,7 +17,7 @@ |
17 | 17 | Ext.define('amdaPlotComp.PlotZoomPlug', { |
18 | 18 | extend: 'Ext.util.Observable', |
19 | 19 | alias: 'plugin.plotZoomPlugin', |
20 | - requires: [ | |
20 | + requires: ['amdaPlotComp.intervalSelection.IntervalSelection', | |
21 | 21 | 'amdaPlotComp.plotFunction.ParamField', 'amdaPlotComp.plotFunction.FunctionType', 'amdaPlotComp.plotFunction.CreatePlot'], |
22 | 22 | |
23 | 23 | //id: 'plot-zoom-plug', |
... | ... | @@ -30,6 +30,7 @@ Ext.define('amdaPlotComp.PlotZoomPlug', { |
30 | 30 | zoomType: '', |
31 | 31 | interactiveId: '', |
32 | 32 | panelId: -1, |
33 | + myChildWindow: null, | |
33 | 34 | |
34 | 35 | linkedTTCatNode: null, |
35 | 36 | /** |
... | ... | @@ -69,6 +70,8 @@ Ext.define('amdaPlotComp.PlotZoomPlug', { |
69 | 70 | if (!this.form) |
70 | 71 | return; |
71 | 72 | |
73 | + this.myChildWindow.setField1Value(min); | |
74 | + | |
72 | 75 | if (this.zoomType == 'timeAxis') { |
73 | 76 | this.form.getForm().findField('zoom-min-time').setValue(min); |
74 | 77 | |
... | ... | @@ -81,6 +84,8 @@ Ext.define('amdaPlotComp.PlotZoomPlug', { |
81 | 84 | if (!this.form) |
82 | 85 | return; |
83 | 86 | |
87 | + this.myChildWindow.setField2Value(max); | |
88 | + | |
84 | 89 | if (this.zoomType == 'timeAxis') { |
85 | 90 | var minValue = this.form.getForm().findField('zoom-min-time').getValue(); |
86 | 91 | if (minValue <= max) { |
... | ... | @@ -130,6 +135,11 @@ Ext.define('amdaPlotComp.PlotZoomPlug', { |
130 | 135 | * creation of the window |
131 | 136 | */ |
132 | 137 | show: function (interactiveId, zoomType, panelId, isPlotFunction_ = false) { |
138 | + this.myChildWindow = Ext.create('amdaPlotComp.intervalSelection.DateIntervalSelection'); | |
139 | + // Show the window | |
140 | + this.myChildWindow.show(); | |
141 | + this.myChildWindow.setPosition(100, 100); | |
142 | + | |
133 | 143 | this.isPlotFunction = isPlotFunction_; |
134 | 144 | if (this.win) { this.close() }; |
135 | 145 | this.win = new Ext.Window({ |
... | ... |
js/app/views/PlotComponents/intervalSelection/DateIntervalSelection.js
0 โ 100644
... | ... | @@ -0,0 +1,30 @@ |
1 | +Ext.define('amdaPlotComp.intervalSelection.DateIntervalSelection', { | |
2 | + extend: 'amdaPlotComp.intervalSelection.IntervalSelection', // This class extends from amdaPlotComp.intervalSelection.IntervalSelection | |
3 | + | |
4 | + field1Type: 'datefield', | |
5 | + field1Label: 'Start Time', | |
6 | + field1Format: 'Y/m/d H:i:s.u', | |
7 | + field2Type: 'datefield', | |
8 | + field2Label: 'Stop Time', | |
9 | + field2Format: 'Y/m/d H:i:s.u', | |
10 | + | |
11 | + /* | |
12 | + setField1Value: function (value) { | |
13 | + var field2Value = this.getField2Value(); | |
14 | + value = new Date(value); | |
15 | + field2Value = new Date(field2Value); | |
16 | + if (value > field2Value) { | |
17 | + value = field2Value; | |
18 | + } | |
19 | + this.parent.down('#' + FIELD1_ITEM_ID).setValue(value); | |
20 | + }, | |
21 | + | |
22 | + setField2Value: function (value) { | |
23 | + value = new Date(value); | |
24 | + field1Value = new Date(field1Value); | |
25 | + if (value < field1Value) { | |
26 | + value = field1Value; | |
27 | + } | |
28 | + this.parent.down('#' + FIELD2_ITEM_ID).setValue(value); | |
29 | + }*/ | |
30 | +}); | |
... | ... |
js/app/views/PlotComponents/intervalSelection/IntervalSelection.js
0 โ 100644
... | ... | @@ -0,0 +1,123 @@ |
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'; | |
5 | + | |
6 | +// Define a constant for the layout style of the form | |
7 | +const LAYOUT_STYLE = { | |
8 | + type: 'vbox', // vertical box layout | |
9 | + pack: 'start', // controls the vertical alignment of child items | |
10 | + align: 'stretch' // each child item is stretched to fill the width of the container | |
11 | +}; | |
12 | + | |
13 | +// Define the parent class | |
14 | +Ext.define('amdaPlotComp.intervalSelection.IntervalSelection', { | |
15 | + extend: 'Ext.window.Window', // This class extends from Ext.window.Window | |
16 | + // Window configurations | |
17 | + x: 0, y: 0, // The initial position of the window | |
18 | + title: 'Interval Selection', // The title of the window | |
19 | + constrain: true, // Constrains the window to within the boundaries of its containing element | |
20 | + collapsible: true, // Allows the window to be collapsed | |
21 | + resizable: false, // Prevents the window from being resizable | |
22 | + ghost: false, // Disables "ghosting" (semi-transparent representation of the window body) when moving or resizing | |
23 | + | |
24 | + parent: null, // Initialize parent to null | |
25 | + | |
26 | + config: { | |
27 | + field1Type: 'numberfield', // The xtype of field1. By default is numberfield. | |
28 | + field1Label: 'Min Value', // The label of field1. | |
29 | + field1Format: null, | |
30 | + field2Type: 'numberfield', // The xtype of field2. By default is numberfield. | |
31 | + field2Label: 'Max Value', // The label of field2. | |
32 | + field2Format: null | |
33 | + }, | |
34 | + | |
35 | + initComponent: function () { | |
36 | + const me = this; // Reference to this instance for use in event handlers | |
37 | + | |
38 | + this.parent = new Ext.form.FormPanel({ // Create a new FormPanel instance and assign it to parent | |
39 | + frame: true, // Display a frame around the panel | |
40 | + width: 255, // Set the width of the panel | |
41 | + layout: LAYOUT_STYLE, // Set the layout style of the panel | |
42 | + fieldDefaults: { | |
43 | + labelWidth: 60 // Set default label width for fields in this panel | |
44 | + }, | |
45 | + items: [{ | |
46 | + xtype: 'fieldset', // Create a new FieldSet to group related fields together | |
47 | + title: 'Interval Selection', | |
48 | + name: 'interval-selection-fieldset', | |
49 | + collapsible: false, | |
50 | + layout: LAYOUT_STYLE, | |
51 | + items: [{ | |
52 | + xtype: this.field1Type, | |
53 | + fieldLabel: this.field1Label, | |
54 | + itemId: FIELD1_ITEM_ID, | |
55 | + format: this.field1Format | |
56 | + }, | |
57 | + { | |
58 | + xtype: this.field2Type, | |
59 | + fieldLabel: this.field2Label, | |
60 | + itemId: FIELD2_ITEM_ID, | |
61 | + format: this.field2Format, | |
62 | + listeners: { | |
63 | + change: function (field, newValue) { | |
64 | + var field1 = me._getField1(); | |
65 | + // Check if field1 is not empty | |
66 | + const value1 = field1.getValue(); | |
67 | + if (value1 !== null && value1 !== undefined && value1 !== '') { | |
68 | + if (newValue < value1) { | |
69 | + // Update both field1 and field2 to the new value | |
70 | + field1.setValue(newValue); | |
71 | + field.setValue(value1); | |
72 | + } | |
73 | + } | |
74 | + } | |
75 | + } | |
76 | + }, { | |
77 | + xtype: 'button', | |
78 | + text: 'Reset', | |
79 | + handler: function () { | |
80 | + me._getField1().reset(); | |
81 | + me._getField2().reset(); | |
82 | + } | |
83 | + }, { | |
84 | + xtype: 'button', | |
85 | + text: 'Use in Time Selection', | |
86 | + handler: function () { | |
87 | + alert('Button 2 clicked'); | |
88 | + } | |
89 | + }] | |
90 | + }] | |
91 | + }) | |
92 | + | |
93 | + Ext.apply(this, { | |
94 | + items: this.parent | |
95 | + }); | |
96 | + | |
97 | + this.callParent(arguments); | |
98 | + }, | |
99 | + | |
100 | + _getField1: function () { | |
101 | + return this.parent.down('#' + FIELD1_ITEM_ID); | |
102 | + }, | |
103 | + | |
104 | + _getField2: function () { | |
105 | + return this.parent.down('#' + FIELD2_ITEM_ID); | |
106 | + }, | |
107 | + | |
108 | + getField1Value: function () { | |
109 | + return this._getField1().getValue(); | |
110 | + }, | |
111 | + | |
112 | + getField2Value: function () { | |
113 | + return this._getField2().getValue(); | |
114 | + }, | |
115 | + | |
116 | + setField1Value: function (value) { | |
117 | + this._getField1().setValue(value); | |
118 | + }, | |
119 | + | |
120 | + setField2Value: function (value) { | |
121 | + this._getField2().setValue(value); | |
122 | + } | |
123 | +}); | |
... | ... |