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