Users.js
6.03 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
Ext.define('MyMA.view.Users', {
extend: 'Ext.window.Window',
alias: 'widget.users',
layout: 'fit',
minimizable: true,
constrainHeader: true,
closeAction: 'destroy',
width: 900,
listeners: {
render: function(win) {
if(Ext.getBody().getHeight() > 500) {
win.setHeight(Ext.getBody().getHeight() - 150);
}
}
},
items: [{
xtype: 'grid',
border: false,
listeners: {
/**
* Initiate data save through proxy
* @param editor : Ext.grid.plugin.Editing
* @param object
* grid - The grid
* record - The record that was edited
* field - The field name that was edited
* value - The value being set
* row - The grid table row
* column - The grid Column defining the column that was edited.
* rowIdx - The row index that was edited
* colIdx - The column index that was edited
* originalValue - The original value for the field, before the edit (only when using CellEditing)
* originalValues - The original values for the field, before the edit (only when using RowEditing)
* newValues - The new values being set (only when using RowEditing)
* view - The grid view (only when using RowEditing)
* store - The grid store (only when using RowEditing)
*/
edit: function(editor, data) {
if(data.originalValue == data.value) {
return;
}
data.record.save({
action: 'update',
scope: data,
success: function() {
this.record.commit();
//this.view.refresh();
}
});
}
},
tbar: [{
xtype: 'button',
iconCls: 'x-ibtn-add',
itemId: 'addrecord',
text: 'New Item'
}, {
xtype: 'tbseparator',
width: 5
}, {
xtype: 'searchfield',
handler: 'search',
name: 'query'
}, {
xtype: 'tbspacer',
width: 5
}, {
xtype: 'button',
itemId: 'search',
text: 'Search'
}],
bbar: {
xtype: 'pagingtoolbar',
displayInfo: true,
store: 'Users'
},
plugins: [
Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
})
],
selModel: {
selType: 'cellmodel'
},
columns: [{
xtype: 'actioncolumn',
width: 30,
items: [{
getClass: function() {
return 'x-ibtn-edit x-ibtn-def';
}
}]
}, {
header: 'ID',
dataIndex: 'id',
width: 40
}, {
header: 'Name',
dataIndex: 'name',
editor: {
xtype: 'textfield'
},
flex: 1
}, {
header: 'Login',
dataIndex: 'login',
width: 120,
renderer: function(value, meta, record) {
return value + '@' + record.get('domain');
}
}, {
header: 'Password',
hidden: true,
dataIndex: 'passwd'
}, {
header: 'uid',
dataIndex: 'uid',
hidden: true,
width: 40
}, {
header: 'gid',
dataIndex: 'gid',
hidden: true,
width: 40
}, {
header: 'SMTP',
dataIndex: 'smtp',
width: 55,
editor: {
xtype: 'combo',
valueField: 'id',
displayField: 'name',
triggerAction: 'all',
editable: false,
store: 'Choice'
},
renderer: function(value) {
if(value==1) {
return 'Yes';
}
return 'No';
}
}, {
header: 'IMAP',
dataIndex: 'imap',
width: 55,
editor: {
xtype: 'combo',
valueField: 'id',
displayField: 'name',
triggerAction: 'all',
editable: false,
store: 'Choice'
},
renderer: function(value) {
if(value==1) {
return 'Yes';
}
return 'No';
}
}, {
header: 'POP3',
dataIndex: 'pop3',
width: 55,
editor: {
xtype: 'combo',
valueField: 'id',
displayField: 'name',
triggerAction: 'all',
editable: false,
store: 'Choice'
},
renderer: function(value) {
if(value==1) {
return 'Yes';
}
return 'No';
}
}, {
header: 'Sieve',
dataIndex: 'sieve',
width: 55,
editor: {
xtype: 'combo',
valueField: 'id',
displayField: 'name',
triggerAction: 'all',
editable: false,
store: 'Choice'
},
renderer: function(value) {
if(value==1) {
return 'Yes';
}
return 'No';
}
}, {
header: 'Quota',
dataIndex: 'quota',
editor: {
xtype: 'numberfield',
allowDecimal: false
}
}, {
header: 'Backup (days)',
dataIndex: 'backup',
renderer: function(value) {
return value == 0 ? 'Off' : value;
}
}, {
header: 'Last Backup',
dataIndex: 'backup_last',
renderer: Ext.util.Format.dateRenderer('d.m.Y H:i')
}, {
xtype: 'actioncolumn',
width: 30,
items: [{
getClass: function() {
return 'x-ibtn-delete x-ibtn-def';
}
}]
}],
store: 'Users'
}]
});