Mercurial > lada > lada-client
comparison app/controller/grid/Probenzusatzwert.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 | 23d2204eaf7c |
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 Probenzusatzwert | |
11 */ | |
9 Ext.define('Lada.controller.grid.Probenzusatzwert', { | 12 Ext.define('Lada.controller.grid.Probenzusatzwert', { |
10 extend: 'Ext.app.Controller', | 13 extend: 'Ext.app.Controller', |
11 | 14 |
12 init: function() { | 15 /** |
16 * Initialize the Controller with | |
17 * 3 Listeners | |
18 */ | |
19 init: function() { | |
13 this.control({ | 20 this.control({ |
14 'probenzusatzwertgrid': { | 21 'probenzusatzwertgrid': { |
15 edit: this.gridSave, | 22 edit: this.gridSave, |
16 canceledit: this.cancelEdit | 23 canceledit: this.cancelEdit |
17 }, | 24 }, |
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 Probenzusatzwert | |
78 */ | |
79 add: function(button) { | |
60 var record = Ext.create('Lada.model.Zusatzwert', { | 80 var record = Ext.create('Lada.model.Zusatzwert', { |
61 probeId: button.up('probenzusatzwertgrid').recordId | 81 probeId: button.up('probenzusatzwertgrid').recordId |
62 }); | 82 }); |
63 button.up('probenzusatzwertgrid').store.insert(0, record); | 83 button.up('probenzusatzwertgrid').store.insert(0, record); |
64 button.up('probenzusatzwertgrid').rowEditing.startEdit(0, 1); | 84 button.up('probenzusatzwertgrid').rowEditing.startEdit(0, 1); |
65 }, | 85 }, |
66 | 86 |
67 remove: function(button) { | 87 /** |
88 * A row can be removed from the grid with the remove | |
89 * function. It asks the user for confirmation | |
90 * If the removal was confirmed, it reloads the parent window on success, | |
91 * on failure, an error message is shown. | |
92 */ | |
93 remove: function(button) { | |
68 var grid = button.up('grid'); | 94 var grid = button.up('grid'); |
69 var selection = grid.getView().getSelectionModel().getSelection()[0]; | 95 var selection = grid.getView().getSelectionModel().getSelection()[0]; |
70 Ext.MessageBox.confirm('Zusatzwert löschen', 'Sind Sie sicher?', function(btn) { | 96 Ext.MessageBox.confirm('Zusatzwert löschen', 'Sind Sie sicher?', function(btn) { |
71 if (btn === 'yes') { | 97 if (btn === 'yes') { |
72 selection.destroy({ | 98 selection.destroy({ |