Commit 7b0f552939e4f2419f10b34d6141a44b4f4723cb

Authored by Laurent BEIGBEDER
1 parent 8f842704
Exists in master

11530: add input position unit choice

ihm/app/controller/Vectors/UnitsManager.js 0 → 100644
... ... @@ -0,0 +1,59 @@
  1 +Ext.define('treps.controller.Vectors.UnitsManager', {
  2 + singleton : true,
  3 +
  4 + constructor: function() {
  5 + },
  6 +
  7 + loadUnitsStore: function(onAfterLoad) {
  8 + var me = this;
  9 +
  10 + var store = this.getUnitsStore();
  11 +
  12 + /* Create a local store
  13 + var myStore = Ext.create('Ext.data.Store',{
  14 + fields:['Id','fullname',''],
  15 + data:[
  16 + {Id:0,Name:'Yes'},
  17 + {Id:1,Name:'No'},
  18 + {Id:2,Name:'Maybe'}
  19 + ]
  20 + });
  21 + */
  22 + //if store exists, empty it
  23 + if (store != null)
  24 + store.removeAll();
  25 + else
  26 + store = Ext.create('treps.store.Units');
  27 +
  28 + console.log('****** loading unitManager store ');
  29 +
  30 + store.load(
  31 + {
  32 + scope: me,
  33 + callback: function(records, operation, success)
  34 + {
  35 + if (!success)
  36 + {
  37 + treps.Messages.showError("Cannot get units list");
  38 + return;
  39 + }
  40 +
  41 + if (onAfterLoad != null)
  42 + onAfterLoad.call(me,store);
  43 + }
  44 + });
  45 + },
  46 +
  47 + getUnitsStore : function()
  48 + {
  49 + return Ext.getStore('UnitsStore');
  50 + },
  51 +
  52 + getFirstUnitId : function()
  53 + {
  54 + var store = this.getUnitsStore();
  55 + if ((store != null) && (store.count() > 0))
  56 + return store.getAt(0).get("id");
  57 + return "";
  58 + }
  59 +});
... ...
ihm/app/controller/Vectors/VecDefGrid.js deleted
... ... @@ -1,214 +0,0 @@
1   -Ext.define('treps.controller.Vectors.VecDefGrid', {
2   - extend: 'Ext.app.Controller',
3   -
4   - views: [
5   - 'Steps.TransformationDefinition.TransformationDefinitionPanel'
6   - ],
7   -
8   - stores: [
9   - 'Vectors'
10   - ],
11   -
12   - models: [
13   - 'Vector'
14   - ],
15   -
16   - refs: [
17   - {
18   - ref: 'vectorsGrid',
19   - selector: 'dataselect_container > container > vecdef_grid'
20   - }
21   - ],
22   -
23   - init: function() {
24   - var me = this;
25   -
26   - this.control({
27   - 'dataselect_container > container > vecdef_grid > toolbar > #addVecButton': {
28   - click: me.onAddVector,
29   - scope: me
30   - },
31   - 'dataselect_container > container > vecdef_grid > toolbar > #removeVecButton': {
32   - click: me.onRemoveVector,
33   - scope: me
34   - },
35   - 'dataselect_container > container > vecdef_grid > toolbar > #editVecButton': {
36   - click: me.onEditVector,
37   - scope: me
38   - },
39   - 'dataselect_container > container > vecdef_grid': {
40   - select: me.onSelectVector,
41   - scope: me
42   - }
43   - });
44   -
45   - },
46   -
47   - colRenderer: function(value, metaData, record, rowIndex, colIndex, store, gridView)
48   - {
49   - if (colIndex == 0)
50   - metaData.style = 'background:'+treps.Constants.VECTOR_COMP1_COLOR+';';
51   - else if (colIndex == 1)
52   - metaData.style = 'background:'+treps.Constants.VECTOR_COMP2_COLOR+';';
53   - else if (colIndex == 2)
54   - metaData.style = 'background:'+treps.Constants.VECTOR_COMP3_COLOR+';';
55   -
56   - return value;
57   - },
58   -
59   - initRenderer: function()
60   - {
61   - var grid = this.getVectorsGrid();
62   - grid.colRenderer = this.colRenderer;
63   - },
64   -
65   - addVector: function(comp1, comp2, comp3)
66   - {
67   - var grid = this.getVectorsGrid();
68   - var store = grid.getStore();
69   -
70   - var record = Ext.create("treps.model.Vector");
71   - record.set('comp_1',comp1);
72   - record.set('comp_2',comp2);
73   - record.set('comp_3',comp3);
74   - record = store.add(record);
75   -
76   - var selMod = grid.getSelectionModel();
77   - selMod.deselectAll();
78   - selMod.select(record);
79   - },
80   -
81   - onAddVector: function() {
82   - this.addVector('','','');
83   - this.onEditVector();
84   - },
85   -
86   - onRemoveVector: function() {
87   - var grid = this.getVectorsGrid();
88   - var store = grid.getStore();
89   -
90   - var selMod = grid.getSelectionModel();
91   -
92   - var selVecs = selMod.getSelection();
93   -
94   - if (!selVecs | selVecs.length == 0)
95   - {
96   - treps.Messages.showError('No vector selected');
97   - return;
98   - }
99   -
100   - selMod.deselectAll();
101   -
102   - store.remove(selVecs);
103   -
104   - if (store.getCount() > 0)
105   - selMod.select(store.getAt(0));
106   - else
107   - this.application.fireEvent('resetvector');
108   - },
109   -
110   - onEditVector: function() {
111   - var grid = this.getVectorsGrid();
112   -
113   - var selMod = grid.getSelectionModel();
114   -
115   - var selVecs = selMod.getSelection();
116   -
117   - if (!selVecs | selVecs.length == 0)
118   - {
119   - treps.Messages.showError('No vector selected');
120   - return;
121   - }
122   -
123   - var selVec = selVecs[0];
124   -
125   - this.application.fireEvent('editvector',selVec);
126   - },
127   -
128   - onSelectVector: function(grid,record,index)
129   - {
130   - this.application.fireEvent('selectvector',record);
131   - },
132   -
133   - clearStore: function()
134   - {
135   - var grid = this.getVectorsGrid();
136   - var store = grid.getStore();
137   -
138   - this.application.fireEvent('resetvector');
139   -
140   - store.removeAll();
141   - },
142   -
143   - componentInUse: function(comp)
144   - {
145   - var grid = this.getVectorsGrid();
146   - var store = grid.getStore();
147   -
148   - var inUse = false;
149   -
150   - store.each(function (vec)
151   - {
152   - if ((vec.get('comp_1') == comp) || (vec.get('comp_2') == comp) || (vec.get('comp_3') == comp))
153   - inUse = true;
154   - });
155   -
156   - return inUse;
157   - },
158   -
159   - isValid: function(noTrans)
160   - {
161   - var grid = this.getVectorsGrid();
162   - var store = grid.getStore();
163   -
164   - if (!noTrans && (store.getCount() < 1))
165   - {
166   - treps.Messages.showError('Please select at least one vector.');
167   - return false;
168   - }
169   -
170   - var valid = true;
171   - store.each(function (vec)
172   - {
173   - var errors = vec.validate();
174   - if (!errors.isValid())
175   - valid = false;
176   - });
177   -
178   - if (!valid)
179   - {
180   - treps.Messages.showError('Please define all vectors components.');
181   - return false;
182   - }
183   -
184   - return true;
185   - },
186   -
187   - getVectorsStr: function()
188   - {
189   - var grid = this.getVectorsGrid();
190   - var store = grid.getStore();
191   -
192   - var res = '';
193   -
194   - store.each(function (vec)
195   - {
196   - if (res != '')
197   - res += ';';
198   - res += '(';
199   - res += vec.get('comp_1');
200   - res += ',';
201   - res += vec.get('comp_2');
202   - res += ',';
203   - res += vec.get('comp_3');
204   - if (vec.get('is_pos'))
205   - {
206   - res += ',';
207   - res += 1;
208   - }
209   - res += ')';
210   - });
211   -
212   - return res;
213   - }
214   -});