diff --git a/js/app/views/PlotComponents/intervalSelection/DateZoomIntervalSelection.js b/js/app/views/PlotComponents/intervalSelection/DateZoomIntervalSelection.js index 01949b6..a82369b 100644 --- a/js/app/views/PlotComponents/intervalSelection/DateZoomIntervalSelection.js +++ b/js/app/views/PlotComponents/intervalSelection/DateZoomIntervalSelection.js @@ -1,7 +1,15 @@ Ext.define('amdaPlotComp.intervalSelection.DateZoomIntervalSelection', { extend: 'amdaPlotComp.intervalSelection.ZoomIntervalSelection', + requires: ['amdaPlotComp.intervalSelection.InsertToTTCatlog'], type: 'timeAxis', - title: "Zoom on time axis & Interval selection" + title: "Zoom on time axis & Interval selection", + insertToTTCatlog: null, + + initComponent: function () { + this.callParent(arguments); + this.insertToTTCatlog = new amdaPlotComp.intervalSelection.InsertToTTCatlog({parent: this}); + this.parent.add(this.insertToTTCatlog); + }, }); diff --git a/js/app/views/PlotComponents/intervalSelection/InsertToTTCatlog.js b/js/app/views/PlotComponents/intervalSelection/InsertToTTCatlog.js new file mode 100644 index 0000000..5d416e6 --- /dev/null +++ b/js/app/views/PlotComponents/intervalSelection/InsertToTTCatlog.js @@ -0,0 +1,172 @@ +Ext.define('amdaPlotComp.intervalSelection.InsertToTTCatlog', { + extend: 'Ext.form.FieldSet', + + collapsible: false, + layout: LAYOUT_STYLE, + title: 'Add in Time Table or Catalog', + name: 'tt-insertion-fieldset', + + fieldTypeTTCat: 'ttcat-type', + fieldTypeName: 'ttcat-name', + ttModuleId: 'timetab-win', + catModuleId: 'catalog-win', + + parent: null, + + initComponent: function () { + const self = this; + + const insertTypeStore = Ext.create('Ext.data.Store', { + fields: ['key', 'name'], + data: [ + { "key": "timeTable", "name": "TimeTable" }, + { "key": "catalog", "name": "Catalog" } + ] + }); + + Ext.apply(self, { + items: [{ + xtype: 'combo', + fieldLabel: 'Insert In', + store: insertTypeStore, + queryMode: 'local', + displayField: 'name', + valueField: 'key', + editable: false, + value: 'timeTable', + name: self.fieldTypeTTCat, + itemId: self.fieldTypeTTCat, + }, + { + xtype: 'textfield', + fieldLabel: 'Name', + name: self.fieldTypeName, + itemId: self.fieldTypeName, + listeners: + { + render: function (o, op) { + var field = this; + var el = this.el; + Ext.create('Ext.dd.DropTarget', el, { + ddGroup: 'explorerTree', + notifyOver: function (ddSource, e, data) { + var TTCatType = self._getFieldTypeTTCat().getValue(); + if (data.records[0].data.leaf && (data.records[0].data.nodeType == TTCatType)) { + this.valid = true; + return this.dropAllowed; + } + this.valid = false; + return this.dropNotAllowed; + }, + notifyDrop: function (ddSource, e, data) { + if (!this.valid) + return false; + field.setValue(data.records[0].get('text')); + return true; + } + }); + } + } + }, + { + xtype: 'button', + width: width, + text: 'Insert Interval', + scope: this, + handler: function () { + var me = this; + + var TTCatType = self._getFieldTypeTTCat().getValue(); + var TTCatName = self._getFieldNameTTCat().getValue(); + + var isCatalog = (TTCatType == 'catalog'); + myDesktopApp.getLoadedModule(isCatalog ? this.catModuleId : this.ttModuleId, true, function (module) { + var targetModuleUI = module.getUiContent(); + if (me.linkedTTCatNode && (me.linkedTTCatNode.get('text') == TTCatName) && (me.linkedTTCatNode.get('nodeType') == TTCatType)) { + if (targetModuleUI) + me.insertInterval(); + else { + me.linkedTTCatNode.editLeaf(function () { + me.insertInterval(); + }); + } + } + else { + var explorerTree = Ext.getCmp(amdaUI.ExplorerUI.RESRC_TAB.TREE_ID); + var ttCatRootNode = explorerTree.getRootNode().findChild('id', isCatalog ? 'catalog-treeRootNode' : 'timeTable-treeRootNode', true); + amdaModel.InteractiveNode.preloadNodes(ttCatRootNode, function () { + var nodeWithSameName = null; + + if (TTCatName != '') + nodeWithSameName = ttCatRootNode.findChild('text', TTCatName, true); + + if (nodeWithSameName !== null) + me.linkedTTCatNode = nodeWithSameName; + else { + module.createLinkedNode(); + module.getLinkedNode().set('text', TTCatName); + me.linkedTTCatNode = module.getLinkedNode(); + var obj = { + name: TTCatName, + fromPlugin: true + }; + if (isCatalog) { + Ext.Msg.prompt('Define Parameters', 'Please enter parameters number for the new catalog:', function (btn, text) { + if (btn == 'ok') { + obj.nbParameters = parseInt(text, 10); + if (isNaN(obj.nbParameters)) { + obj.nbParameters = 1; + } + module.createObject(obj); + me.linkedTTCatNode.editLeaf(function () { + me.insertInterval(); + }); + } + }); + return; + } + else { + module.createObject(obj); + } + } + + me.linkedTTCatNode.editLeaf(function () { + me.insertInterval(); + }); + }); + } + }); + } + } + ] + }); + + self.callParent(arguments); + }, + + + _getFieldTypeTTCat: function () { + return this.down('#' + this.fieldTypeTTCat); + }, + + _getFieldNameTTCat: function () { + return this.down('#' + this.fieldTypeName); + }, + + /** + * add Interval to Time table or Catalog + */ + insertInterval: function () { + const start = this.parent.getField1Value(); + const stop = this.parent.getField2Value(); + + const TTCatType = this._getFieldTypeTTCat().getValue(); + const isCatalog = (TTCatType == 'catalog'); + + myDesktopApp.getLoadedModule(isCatalog ? this.catModuleId : this.ttModuleId, true, function (module) { + var targetModuleUI = module.getUiContent(); + if (targetModuleUI) + targetModuleUI.addInterval(start, stop); + }); + } +}); diff --git a/js/app/views/PlotComponents/intervalSelection/IntervalSelection.js b/js/app/views/PlotComponents/intervalSelection/IntervalSelection.js index 1b5f8a4..2adf84e 100644 --- a/js/app/views/PlotComponents/intervalSelection/IntervalSelection.js +++ b/js/app/views/PlotComponents/intervalSelection/IntervalSelection.js @@ -1,7 +1,4 @@ -// Define the itemIds as constants -// These will be used to reference the fields later in the code -var FIELD1_ITEM_ID = 'field1'; -var FIELD2_ITEM_ID = 'field2'; + // Define a constant for the layout style of the form const LAYOUT_STYLE = { @@ -10,6 +7,8 @@ const LAYOUT_STYLE = { align: 'stretch' // each child item is stretched to fill the width of the container }; +const width = 100; + // Define the parent class Ext.define('amdaPlotComp.intervalSelection.IntervalSelection', { extend: 'Ext.window.Window', // This class extends from Ext.window.Window @@ -29,13 +28,18 @@ Ext.define('amdaPlotComp.intervalSelection.IntervalSelection', { config: { field1Type: 'datefield', // The xtype of field1. By default is datefield because we are working with time series. field1Label: 'Start Time', // The label of field1. - field1Format: 'Y/m/d H:i:s.u', + field1Format: 'Y/m/d H:i:s.u', field2Type: 'datefield', // The xtype of field2. By default is datefield. field2Label: 'Stop Time', // The label of field2. - field2Format: 'Y/m/d H:i:s.u', + field2Format: 'Y/m/d H:i:s.u', buttonApply: 'Apply' }, + // Define the itemIds as constants + // These will be used to reference the fields later in the code + FIELD1_ITEM_ID: 'field1', + FIELD2_ITEM_ID: 'field2', + initComponent: function () { const me = this; // Reference to this instance for use in event handlers @@ -55,13 +59,13 @@ Ext.define('amdaPlotComp.intervalSelection.IntervalSelection', { items: [{ xtype: this.field1Type, fieldLabel: this.field1Label, - itemId: FIELD1_ITEM_ID, + itemId: this.FIELD1_ITEM_ID, format: this.field1Format }, { xtype: this.field2Type, fieldLabel: this.field2Label, - itemId: FIELD2_ITEM_ID, + itemId: this.FIELD2_ITEM_ID, format: this.field2Format, listeners: { change: function (field, newValue) { @@ -80,6 +84,7 @@ Ext.define('amdaPlotComp.intervalSelection.IntervalSelection', { }, { xtype: 'button', text: 'Reset', + width: width, handler: function () { me._getField1().reset(); me._getField2().reset(); @@ -120,11 +125,11 @@ Ext.define('amdaPlotComp.intervalSelection.IntervalSelection', { }, _getField1: function () { - return this.parent.down('#' + FIELD1_ITEM_ID); + return this.parent.down('#' + this.FIELD1_ITEM_ID); }, _getField2: function () { - return this.parent.down('#' + FIELD2_ITEM_ID); + return this.parent.down('#' + this.FIELD2_ITEM_ID); }, getField1Value: function () { diff --git a/js/app/views/PlotComponents/intervalSelection/PlotFunctionIntervalSelection.js b/js/app/views/PlotComponents/intervalSelection/PlotFunctionIntervalSelection.js index ee37531..2e1d93d 100644 --- a/js/app/views/PlotComponents/intervalSelection/PlotFunctionIntervalSelection.js +++ b/js/app/views/PlotComponents/intervalSelection/PlotFunctionIntervalSelection.js @@ -13,7 +13,7 @@ Ext.define('amdaPlotComp.intervalSelection.PlotFunctionIntervalSelection', { _apply: function () { if (this._notValidValues()) { - myDesktopApp.warningMsg('The Input Values are not defined'); + 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.'); } else { let request_to_send = {}; request_to_send = Object.assign({}, this.plotFunctionType.getValues()); diff --git a/js/app/views/PlotComponents/intervalSelection/ZoomIntervalSelection.js b/js/app/views/PlotComponents/intervalSelection/ZoomIntervalSelection.js index 9f04153..9e7ad03 100644 --- a/js/app/views/PlotComponents/intervalSelection/ZoomIntervalSelection.js +++ b/js/app/views/PlotComponents/intervalSelection/ZoomIntervalSelection.js @@ -9,7 +9,7 @@ Ext.define('amdaPlotComp.intervalSelection.ZoomIntervalSelection', { this.callParent(arguments); this.parent.getDockedItems('toolbar[dock="bottom"]')[0].add({ xtype: 'button', - width: 100, + width: width, text: 'Undo Zoom', handler: function () { me._undoZoom(); -- libgit2 0.21.2