StatusModalWindow.js
3.25 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
Ext.define('amdaUI.StatusModalWindow',{
extend: 'Ext.window.Window',
alias: 'widget.statusmodalwindow',
requires:[
'amdaUI.StatusGrid'
],
statusGrid: null,
object : null,
constructor:function(config){
this.object = config.object;
this.statusGrid = Ext.create('amdaUI.StatusGrid',{type:config.type, status : config.status})
this.init(config);
this.callParent();
},
init:function(config){
var me=this;
Ext.apply(this, {
title: 'Status Grid',
width: 285,
height: 250,
closable:false,
modal:true,
resizable: false,
items: [
{
xtype: 'form',
renderTo: Ext.getBody(),
layout:'hbox',
frame: false,
items: [
{
flex:1,
items:[me.statusGrid],
}],
buttons: [{
text: 'Save',
handler: function() {
// Check to be sure that max > min
invalidRecord = null;
if(config.type != "cat"){
var records = me.statusGrid.store.getRange();
for (var i = 0; i < records.length; i++) {
var record = records[i];
if (record.get('maxVal') < record.get('minVal')) {
invalidRecord = record;
break;
}
}
if (invalidRecord) {
Ext.Msg.alert('Error', 'Max value must be greater than Min value', function() {
me.statusGrid.cellEditing.startEditByPosition({row: invalidRecord, column: 0});
invalidRecord = null;
});
return;
}
}
// Saving part
config.object.set('status',me.statusGrid.getStatusString());
me.statusGrid.clearStore();
me.close();
},
},
{
// to reset the form
text: 'Reset',
handler: function() {
me.statusGrid.clearStore();
me.statusGrid.parseStatus(config.status);
}
},
{
// To quit the window
text: 'Cancel',
handler: function() {
me.statusGrid.clearStore();
me.statusGrid.destroy();
me.close();
}
}]
}
]
});
}
});