Aliases.js
2.34 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
Ext.define('MyMA.controller.Aliases', {
extend: 'Ext.app.Controller',
stores: ['Aliases'],
views: ['Aliases','Alias'],
refs: [{
selector: 'aliases > grid',
ref: 'aliasesList'
}],
init: function() {
this.control({
'aliases > grid > toolbar > #addrecord': {
click: this.showForm
},
'aliases > grid > toolbar > #search': {
click: this.onSearch
},
'aliases actioncolumn': {
click: this.onActionColumn
}
});
},
/**
* Handles action columns click
* @param {Object} grid view
* @param {HTMLElement} Element
* @param {Integer} row index
* @param {Integer} column index
* @param {Object} Event object
* @param {Object} Scope object
* @param {Object}
*/
onActionColumn: function(gridview, el, rowIndex, colIndex, e, scope, rowEl) {
if(e.getTarget('.x-ibtn-edit')) {
var record = scope.store.getAt(rowIndex);
var widget = this.getController('Taskpanel').addProgram({
name: 'alias'
});
widget.setTitle('Alias: ' + record.get('alias'));
widget.down('form').getForm().loadRecord(record);
}
if(e.getTarget('.x-ibtn-delete')) {
var record = scope.store.getAt(rowIndex);
Ext.Msg.confirm('Info', 'Press Yes to confirm remove action', function(button) {
if (button === 'yes') {
this.record.destroy({
scope: this,
success: function() {
this.store.remove(this.record)
}
});
}
}, {
store: scope.store,
record: record
});
}
},
/**
* Show form to add new record or edit existing data
* @param {Object} Button
*/
showForm: function(Button) {
this.getController('Taskpanel').addProgram({
name: 'alias',
title: 'New Alias'
});
},
/**
* Search action
*/
onSearch: function(Button) {
this.getAliasesList().getStore().reload({ params: Button.up('toolbar').getValues() });
}
});