comparison app/controller/grid/Ort.js @ 742:6e28ebbe1a73

added documentation for Form and Grid controllers
author Dustin Demuth <dustin@intevation.de>
date Thu, 23 Apr 2015 16:28:04 +0200
parents f0bc5387abcc
children 2362f8ab1e9f
comparison
equal deleted inserted replaced
740:2e8da590ea0c 742:6e28ebbe1a73
4 * This file is Free Software under the GNU GPL (v>=3) 4 * This file is Free Software under the GNU GPL (v>=3)
5 * and comes with ABSOLUTELY NO WARRANTY! Check out 5 * and comes with ABSOLUTELY NO WARRANTY! Check out
6 * the documentation coming with IMIS-Labordaten-Application for details. 6 * the documentation coming with IMIS-Labordaten-Application for details.
7 */ 7 */
8 8
9 /**
10 * This is a controller for a grid of Orte
11 */
9 Ext.define('Lada.controller.grid.Ort', { 12 Ext.define('Lada.controller.grid.Ort', {
10 extend: 'Ext.app.Controller', 13 extend: 'Ext.app.Controller',
11 14
12 requires: [ 15 requires: [
13 'Lada.view.window.OrtEdit', 16 'Lada.view.window.OrtEdit',
14 'Lada.view.window.OrtCreate' 17 'Lada.view.window.OrtCreate'
15 ], 18 ],
16 19
20 /**
21 * Inhitialize the controller
22 * It has 3 listeners
23 */
17 init: function() { 24 init: function() {
18 this.control({ 25 this.control({
19 'ortgrid': { 26 'ortgrid': {
20 itemdblclick: this.open 27 itemdblclick: this.open
21 }, 28 },
26 click: this.remove 33 click: this.remove
27 } 34 }
28 }); 35 });
29 }, 36 },
30 37
38 /**
39 * When open is called, a {@link Lada.view.window.OrtEdit}
40 * is created which allows to edit the Orte
41 */
31 open: function(grid, record) { 42 open: function(grid, record) {
32 var probe = grid.up('window').record; 43 var probe = grid.up('window').record;
33 var win = Ext.create('Lada.view.window.OrtEdit', { 44 var win = Ext.create('Lada.view.window.OrtEdit', {
34 parentWindow: grid.up('window'), 45 parentWindow: grid.up('window'),
35 probe: probe, 46 probe: probe,
38 }); 49 });
39 win.show(); 50 win.show();
40 win.initData(); 51 win.initData();
41 }, 52 },
42 53
54 /**
55 * This function adds a new row to add an Ort
56 */
43 add: function(button) { 57 add: function(button) {
44 var probe = button.up('window').record; 58 var probe = button.up('window').record;
45 var win = Ext.create('Lada.view.window.OrtCreate', { 59 var win = Ext.create('Lada.view.window.OrtCreate', {
46 record: probe, 60 record: probe,
47 grid: button.up('ortgrid') 61 grid: button.up('ortgrid')
48 }); 62 });
49 win.show(); 63 win.show();
50 win.initData(); 64 win.initData();
51 }, 65 },
52 66
67 /**
68 * A Ort-row can be removed from the grid with the remove
69 * function. It asks the user for confirmation
70 * If the removal was confirmed, it reloads the parent window on success,
71 * on failure, an error message is shown.
72 */
53 remove: function(button) { 73 remove: function(button) {
54 var grid = button.up('grid'); 74 var grid = button.up('grid');
55 var selection = grid.getView().getSelectionModel().getSelection()[0]; 75 var selection = grid.getView().getSelectionModel().getSelection()[0];
56 Ext.MessageBox.confirm('Ortsangabe löschen', 'Sind Sie sicher?', function(btn) { 76 Ext.MessageBox.confirm('Ortsangabe löschen', 'Sind Sie sicher?', function(btn) {
57 if (btn === 'yes') { 77 if (btn === 'yes') {

http://lada.wald.intevation.org