Mercurial > lada > lada-client
comparison app/controller/PKommentarGrid.js @ 572:2c8aa09402a2
Added controller for PKommentarGrid and implemented update/add/delete.
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Tue, 10 Mar 2015 14:31:07 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
571:1dedce48e3e1 | 572:2c8aa09402a2 |
---|---|
1 /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz | |
2 * Software engineering by Intevation GmbH | |
3 * | |
4 * This file is Free Software under the GNU GPL (v>=3) | |
5 * and comes with ABSOLUTELY NO WARRANTY! Check out | |
6 * the documentation coming with IMIS-Labordaten-Application for details. | |
7 */ | |
8 | |
9 Ext.define('Lada.controller.PKommentarGrid', { | |
10 extend: 'Ext.app.Controller', | |
11 | |
12 init: function() { | |
13 this.control({ | |
14 'pkommentargrid': { | |
15 edit: this.edit | |
16 }, | |
17 'pkommentargrid button[action=add]': { | |
18 click: this.add | |
19 }, | |
20 'pkommentargrid button[action=delete]': { | |
21 click: this.remove | |
22 } | |
23 }); | |
24 }, | |
25 | |
26 edit: function(editor, context) { | |
27 context.record.save({ | |
28 success: function() { | |
29 context.grid.store.reload(); | |
30 context.grid.up('window').initData(); | |
31 }, | |
32 failure: function() { | |
33 // TODO | |
34 } | |
35 }); | |
36 }, | |
37 | |
38 add: function(button) { | |
39 var record = Ext.create('Lada.model.PKommentar'); | |
40 record.set('probeId', button.up('pkommentargrid').recordId); | |
41 button.up('pkommentargrid').store.insert(0, record); | |
42 button.up('pkommentargrid').rowEditing.startEdit(0, 1); | |
43 }, | |
44 | |
45 remove: function(button) { | |
46 var grid = button.up('grid'); | |
47 var selection = grid.getView().getSelectionModel().getSelection()[0]; | |
48 Ext.MessageBox.confirm('Löschen', 'Sind Sie sicher?', function(btn) { | |
49 if (btn === 'yes') { | |
50 selection.destroy({ | |
51 success: function() { | |
52 button.up('window').initData(); | |
53 }, | |
54 failure: function() { | |
55 // TODO | |
56 } | |
57 }); | |
58 } | |
59 }); | |
60 } | |
61 }); |