Mercurial > lada > lada-client
comparison app/controller/grid/PKommentar.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 | 4381a32d874f |
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 Ext.define('Lada.controller.grid.PKommentar', { | 9 /** |
10 * This is a controller for a grid of Orte | |
11 */ | |
12 EExt.define('Lada.controller.grid.PKommentar', { | |
10 extend: 'Ext.app.Controller', | 13 extend: 'Ext.app.Controller', |
11 | 14 |
15 /** | |
16 * Initialize the Controller with | |
17 * 3 Listeners | |
18 */ | |
12 init: function() { | 19 init: function() { |
13 this.control({ | 20 this.control({ |
14 'pkommentargrid': { | 21 'pkommentargrid': { |
15 edit: this.gridSave, | 22 edit: this.gridSave, |
16 canceledit: this.cancelEdit | 23 canceledit: this.cancelEdit |
22 click: this.remove | 29 click: this.remove |
23 } | 30 } |
24 }); | 31 }); |
25 }, | 32 }, |
26 | 33 |
27 gridSave: function(editor, context) { | 34 /** |
35 * This function is called when the grids roweditor saves | |
36 * the record. | |
37 * On success it refreshes the windows which contains the grid | |
38 * On failure it displays a message | |
39 */ | |
40 gridSave: function(editor, context) { | |
28 context.record.save({ | 41 context.record.save({ |
29 success: function() { | 42 success: function() { |
30 context.grid.store.reload(); | 43 context.grid.store.reload(); |
31 context.grid.up('window').initData(); | 44 context.grid.up('window').initData(); |
32 }, | 45 }, |
47 } | 60 } |
48 } | 61 } |
49 }); | 62 }); |
50 }, | 63 }, |
51 | 64 |
52 cancelEdit: function(editor, context) { | 65 /** |
66 * When the edit was canceled, | |
67 * the empty row might have been created by the roweditor is removed | |
68 */ | |
69 cancelEdit: function(editor, context) { | |
53 if (!context.record.get('id') || | 70 if (!context.record.get('id') || |
54 context.record.get('id') === '') { | 71 context.record.get('id') === '') { |
55 editor.getCmp().store.remove(context.record); | 72 editor.getCmp().store.remove(context.record); |
56 } | 73 } |
57 }, | 74 }, |
58 | 75 |
59 add: function(button) { | 76 /** |
77 * This function adds a new row to add a PKommentar | |
78 */ | |
79 add: function(button) { | |
60 var record = Ext.create('Lada.model.PKommentar'); | 80 var record = Ext.create('Lada.model.PKommentar'); |
61 record.set('probeId', button.up('pkommentargrid').recordId); | 81 record.set('probeId', button.up('pkommentargrid').recordId); |
62 button.up('pkommentargrid').store.insert(0, record); | 82 button.up('pkommentargrid').store.insert(0, record); |
63 button.up('pkommentargrid').rowEditing.startEdit(0, 1); | 83 button.up('pkommentargrid').rowEditing.startEdit(0, 1); |
64 }, | 84 }, |
65 | 85 |
66 remove: function(button) { | 86 /** |
87 * A PKommentar-row can be removed from the grid with the remove | |
88 * function. It asks the user for confirmation | |
89 * If the removal was confirmed, it reloads the parent window on success, | |
90 * on failure, an error message is shown. | |
91 */ | |
92 remove: function(button) { | |
67 var grid = button.up('grid'); | 93 var grid = button.up('grid'); |
68 var selection = grid.getView().getSelectionModel().getSelection()[0]; | 94 var selection = grid.getView().getSelectionModel().getSelection()[0]; |
69 Ext.MessageBox.confirm('Löschen', 'Sind Sie sicher?', function(btn) { | 95 Ext.MessageBox.confirm('Löschen', 'Sind Sie sicher?', function(btn) { |
70 if (btn === 'yes') { | 96 if (btn === 'yes') { |
71 selection.destroy({ | 97 selection.destroy({ |