MultiplotRequestObject.js
3.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/**
* Project : AMDA-NG
* Name : MultiplotRequestObject.js
* @class amdaPlotObj.MutiplotRequestObject
* @extends amdaModel.AmdaTimeObject
* @brief Multi-Plot Request Business Object Definition
* @author Benjamin Renard
* @version $Id: MultiplotRequestObject.js benjamin $
******************************************************************************
* FT Id : Date : Name - Description
******************************************************************************
* : :28/02/2020: BRE - file creation
*/
Ext.define('amdaPlotObj.MultiplotRequestObject', {
extend: 'amdaModel.AmdaTimeObject',
idProperty: 'id',
requires: [
'amdaModel.PlotNode',
'amdaPlotObj.PlotRequestObject'
],
hasMany: {
model : 'amdaModel.PlotNode',
name : 'plots',
associationKey:'plots'
},
constructor: function(){
var me = this;
me.callParent(arguments);
},
isDirty: function() {
var dirty = false;
this.plots().each(function(plotNode) {
var plotObject = plotNode.get('object');
if (plotObject && (plotObject.get('id') != '') && plotObject.dirty) {
dirty = true;
}
});
return dirty;
},
createNewPlot: function() {
var plotObject = Ext.create('amdaPlotObj.PlotRequestObject');
return this.createNewPlotFromObject(plotObject);
},
duplicatePlot: function(plotNode) {
var me = this;
var newPlotNode = null;
this.plots().each(function(node, index) {
if (node == plotNode) {
newPlotNode = Ext.create('amdaModel.PlotNode', {
leaf : true
});
var data = plotNode.get('object').getJsonValues();
newPlotNode.set('object', Ext.create('amdaPlotObj.PlotRequestObject', data));
plotNode.get('object').reject();
me.plots().remove(plotNode);
me.plots().insert(index, [newPlotNode]);
}
});
return newPlotNode;
},
overwritePlot: function(plotNode, targetPlotNode) {
var targetIndex = -1;
this.plots().each(function(node, index) {
if (node == targetPlotNode) {
targetIndex = index;
}
});
if (targetIndex < 0) {
//Target not exists in multiplot node => add it
this.plots().add(targetPlotNode);
targetIndex = this.plots().count() - 1;
}
var data = plotNode.get('object').getJsonValues();
data.id = targetPlotNode.get('id');
targetPlotNode.set('object', Ext.create('amdaPlotObj.PlotRequestObject', data));
plotNode.get('object').reject();
return targetPlotNode;
},
createNewPlotFromObject: function(plotObject) {
var plotNode = Ext.create('amdaModel.PlotNode', {
leaf : true
});
plotNode.set('object',plotObject);
this.plots().add(plotNode);
return this.plots().getAt(this.plots().count()-1);
},
removePlotByInternalId: function(internalId) {
var plotNode = this.plots().data.getByKey(internalId);
if (plotNode)
this.plots().remove(plotNode);
},
addPlot: function(plotNode) {
}
});