Commit 29d321fa661a9662a4d45e83fecc2ab64438090e

Authored by Menouar AZIB
1 parent 594fc719

Add comments to PlotZoomPlug.js

Showing 1 changed file with 42 additions and 35 deletions   Show diff stats
js/app/views/PlotComponents/PlotZoomPlug.js
... ... @@ -10,52 +10,54 @@
10 10 ********************************************************************************
11 11 * FT Id : Date : Name - Description
12 12 *******************************************************************************
13   - * :
14 13 */
15 14  
  15 +// Define a new class 'amdaPlotComp.PlotZoomPlug' that extends 'Ext.util.Observable'
16 16 Ext.define('amdaPlotComp.PlotZoomPlug', {
17 17 extend: 'Ext.util.Observable',
18 18 alias: 'plugin.plotZoomPlugin',
19 19 requires: ['amdaPlotComp.intervalSelection.IntervalSelection'],
20   - win: null,
21   - zoomType: '',
22   - interactiveId: '',
23   - panelId: -1,
24 20  
  21 + // Declare a variable to hold the interval selection component
  22 + intervalSelectionCmp: null,
  23 +
  24 + // Constructor function for the class
25 25 constructor: function (config) {
  26 + // Apply the configuration to this instance and call the parent class's constructor
26 27 Ext.apply(this, config);
27 28 this.callParent(arguments);
28 29 },
29 30  
  31 + // Function to be called when the object is destroyed
30 32 onDestroy: function () {
31   - this.win = null;
  33 + // Set the interval selection component to null
  34 + this.intervalSelectionCmp = null;
32 35 },
33 36  
  37 + // Initialization function for the class
34 38 init: function (cmp) {
  39 + // Set the host component for this instance
35 40 this.hostCmp = cmp;
36 41 },
37 42  
  43 + // Function to set the minimum value of the interval selection component
38 44 setMinValue: function (min) {
39   - if (!this.win)
  45 + if (!this.intervalSelectionCmp)
40 46 return;
41   - this.win.setField1Value(min);
  47 + this.intervalSelectionCmp.setField1Value(min);
42 48 },
43 49  
  50 + // Function to set the maximum value of the interval selection component
44 51 setMaxValue: function (max) {
45   - if (!this.win)
  52 + if (!this.intervalSelectionCmp)
46 53 return;
47   - this.win.setField2Value(max);
  54 + this.intervalSelectionCmp.setField2Value(max);
48 55 },
49 56  
50   -
51 57 /**
52   - * creation of the window
  58 + * Function to create and show a window with specific configuration
53 59 */
54 60 show: function (interactiveId, zoomType, panelId) {
55   - this.zoomType = zoomType;
56   - this.panelId = panelId;
57   - this.interactiveId = interactiveId;
58   -
59 61 let config = {
60 62 id: 'plot-zoom-win-' + this.hostCmp.ownerCt.getId(),
61 63 interactiveId: interactiveId,
... ... @@ -73,54 +75,59 @@ Ext.define('amdaPlotComp.PlotZoomPlug', {
73 75 }
74 76 },
75 77 getConstrainVector: function (constrainTo) {
76   - var me = this;
77   - if (me.constrain || me.constrainHeader) {
78   - constrainTo = constrainTo || (me.floatParent && me.floatParent.getTargetEl()) || me.container || me.el.getScopeParent();
79   - return (me.constrainHeader ? me.header.el : me.el).getConstrainVector(constrainTo);
  78 + const self = this;
  79 + if (self.constrain || self.constrainHeader) {
  80 + constrainTo = constrainTo || (self.floatParent && self.floatParent.getTargetEl()) || self.container || self.el.getScopeParent();
  81 + return (self.constrainHeader ? self.header.el : self.el).getConstrainVector(constrainTo);
80 82 }
81 83 }
82 84 };
83 85  
84   - if (this.win) { this.close() };
  86 + if (this.intervalSelectionCmp) { this.close() };
85 87  
86   - let winType;
  88 + let intervalSelectionCmpType;
87 89  
88   - switch (this.zoomType) {
  90 + switch (zoomType) {
89 91 case 'timeAxis':
90   - winType = 'amdaPlotComp.intervalSelection.DateZoomIntervalSelection';
  92 + intervalSelectionCmpType = 'amdaPlotComp.intervalSelection.DateZoomIntervalSelection';
91 93 break;
92 94 case 'y-left':
93 95 case 'y-right':
94 96 case 'xaxis_id':
95   - winType = 'amdaPlotComp.intervalSelection.NumberZoomIntervalSelection';
  97 + intervalSelectionCmpType = 'amdaPlotComp.intervalSelection.NumberZoomIntervalSelection';
96 98 let title = "";
97   - if (this.zoomType === 'y-left') {
  99 + if (zoomType === 'y-left') {
98 100 title = 'Zoom on Y Left axis';
99   - } else if (this.zoomType === 'y-right') {
  101 + } else if (zoomType === 'y-right') {
100 102 title = 'Zoom on Y Right axis';
101 103 } else {
102 104 title = 'Zoom on X axis';
103 105 }
104   - config["type"] = this.zoomType;
  106 + config["type"] = zoomType;
105 107 config["title"] = title;
106 108 break;
107 109 case 'plotFunction':
108   - winType = 'amdaPlotComp.intervalSelection.PlotFunctionIntervalSelection';
  110 + intervalSelectionCmpType = 'amdaPlotComp.intervalSelection.PlotFunctionIntervalSelection';
109 111 break;
110 112 }
111 113  
112   - this.win = Ext.create(winType, config);
113   - this.win.on('destroy', this.onDestroy, this);
114   - this.win.show();
  114 + // Create a new instance of the interval selection component with the specified type and configuration
  115 + this.intervalSelectionCmp = Ext.create(intervalSelectionCmpType, config);
  116 + // Add a listener for the destroy event of the interval selection component
  117 + this.intervalSelectionCmp.on('destroy', this.onDestroy, this);
  118 + // Show the interval selection component
  119 + this.intervalSelectionCmp.show();
115 120 },
116 121  
  122 + // Function to close the interval selection component
117 123 close: function () {
118   - if (this.win == null)
  124 + if (this.intervalSelectionCmp == null)
119 125 return;
120   - this.win.close();
  126 + this.intervalSelectionCmp.close();
121 127 },
122 128  
  129 + // Function to reset the minimum and maximum values of the interval selection component
123 130 resetMinMaxValue: function () {
124   - this.win.reset();
  131 + this.intervalSelectionCmp.reset();
125 132 }
126 133 });
... ...