From 29d321fa661a9662a4d45e83fecc2ab64438090e Mon Sep 17 00:00:00 2001 From: Menouar AZIB <menouar.azib@akka.eu> Date: Tue, 24 Oct 2023 11:04:18 +0200 Subject: [PATCH] Add comments to PlotZoomPlug.js --- js/app/views/PlotComponents/PlotZoomPlug.js | 77 ++++++++++++++++++++++++++++++++++++++++++----------------------------------- 1 file changed, 42 insertions(+), 35 deletions(-) diff --git a/js/app/views/PlotComponents/PlotZoomPlug.js b/js/app/views/PlotComponents/PlotZoomPlug.js index fdd57bf..e08f9a4 100644 --- a/js/app/views/PlotComponents/PlotZoomPlug.js +++ b/js/app/views/PlotComponents/PlotZoomPlug.js @@ -10,52 +10,54 @@ ******************************************************************************** * FT Id : Date : Name - Description ******************************************************************************* - * : */ +// Define a new class 'amdaPlotComp.PlotZoomPlug' that extends 'Ext.util.Observable' Ext.define('amdaPlotComp.PlotZoomPlug', { extend: 'Ext.util.Observable', alias: 'plugin.plotZoomPlugin', requires: ['amdaPlotComp.intervalSelection.IntervalSelection'], - win: null, - zoomType: '', - interactiveId: '', - panelId: -1, + // Declare a variable to hold the interval selection component + intervalSelectionCmp: null, + + // Constructor function for the class constructor: function (config) { + // Apply the configuration to this instance and call the parent class's constructor Ext.apply(this, config); this.callParent(arguments); }, + // Function to be called when the object is destroyed onDestroy: function () { - this.win = null; + // Set the interval selection component to null + this.intervalSelectionCmp = null; }, + // Initialization function for the class init: function (cmp) { + // Set the host component for this instance this.hostCmp = cmp; }, + // Function to set the minimum value of the interval selection component setMinValue: function (min) { - if (!this.win) + if (!this.intervalSelectionCmp) return; - this.win.setField1Value(min); + this.intervalSelectionCmp.setField1Value(min); }, + // Function to set the maximum value of the interval selection component setMaxValue: function (max) { - if (!this.win) + if (!this.intervalSelectionCmp) return; - this.win.setField2Value(max); + this.intervalSelectionCmp.setField2Value(max); }, - /** - * creation of the window + * Function to create and show a window with specific configuration */ show: function (interactiveId, zoomType, panelId) { - this.zoomType = zoomType; - this.panelId = panelId; - this.interactiveId = interactiveId; - let config = { id: 'plot-zoom-win-' + this.hostCmp.ownerCt.getId(), interactiveId: interactiveId, @@ -73,54 +75,59 @@ Ext.define('amdaPlotComp.PlotZoomPlug', { } }, getConstrainVector: function (constrainTo) { - var me = this; - if (me.constrain || me.constrainHeader) { - constrainTo = constrainTo || (me.floatParent && me.floatParent.getTargetEl()) || me.container || me.el.getScopeParent(); - return (me.constrainHeader ? me.header.el : me.el).getConstrainVector(constrainTo); + const self = this; + if (self.constrain || self.constrainHeader) { + constrainTo = constrainTo || (self.floatParent && self.floatParent.getTargetEl()) || self.container || self.el.getScopeParent(); + return (self.constrainHeader ? self.header.el : self.el).getConstrainVector(constrainTo); } } }; - if (this.win) { this.close() }; + if (this.intervalSelectionCmp) { this.close() }; - let winType; + let intervalSelectionCmpType; - switch (this.zoomType) { + switch (zoomType) { case 'timeAxis': - winType = 'amdaPlotComp.intervalSelection.DateZoomIntervalSelection'; + intervalSelectionCmpType = 'amdaPlotComp.intervalSelection.DateZoomIntervalSelection'; break; case 'y-left': case 'y-right': case 'xaxis_id': - winType = 'amdaPlotComp.intervalSelection.NumberZoomIntervalSelection'; + intervalSelectionCmpType = 'amdaPlotComp.intervalSelection.NumberZoomIntervalSelection'; let title = ""; - if (this.zoomType === 'y-left') { + if (zoomType === 'y-left') { title = 'Zoom on Y Left axis'; - } else if (this.zoomType === 'y-right') { + } else if (zoomType === 'y-right') { title = 'Zoom on Y Right axis'; } else { title = 'Zoom on X axis'; } - config["type"] = this.zoomType; + config["type"] = zoomType; config["title"] = title; break; case 'plotFunction': - winType = 'amdaPlotComp.intervalSelection.PlotFunctionIntervalSelection'; + intervalSelectionCmpType = 'amdaPlotComp.intervalSelection.PlotFunctionIntervalSelection'; break; } - this.win = Ext.create(winType, config); - this.win.on('destroy', this.onDestroy, this); - this.win.show(); + // Create a new instance of the interval selection component with the specified type and configuration + this.intervalSelectionCmp = Ext.create(intervalSelectionCmpType, config); + // Add a listener for the destroy event of the interval selection component + this.intervalSelectionCmp.on('destroy', this.onDestroy, this); + // Show the interval selection component + this.intervalSelectionCmp.show(); }, + // Function to close the interval selection component close: function () { - if (this.win == null) + if (this.intervalSelectionCmp == null) return; - this.win.close(); + this.intervalSelectionCmp.close(); }, + // Function to reset the minimum and maximum values of the interval selection component resetMinMaxValue: function () { - this.win.reset(); + this.intervalSelectionCmp.reset(); } }); -- libgit2 0.21.2