annotate app/controller/grid/MKommentar.js @ 700:1e76aec72815

Renamed function edit to gridSave
author Dustin Demuth <dustin@intevation.de>
date Fri, 27 Mar 2015 08:43:37 +0100
parents 5b2cbc6bc39a
children f0bc5387abcc
rev   line source
596
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
1 /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
2 * Software engineering by Intevation GmbH
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
3 *
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
4 * This file is Free Software under the GNU GPL (v>=3)
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
6 * the documentation coming with IMIS-Labordaten-Application for details.
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
7 */
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
8
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
9 Ext.define('Lada.controller.grid.MKommentar', {
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
10 extend: 'Ext.app.Controller',
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
11
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
12 init: function() {
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
13 this.control({
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
14 'mkommentargrid': {
700
1e76aec72815 Renamed function edit to gridSave
Dustin Demuth <dustin@intevation.de>
parents: 697
diff changeset
15 edit: this.gridSave,
637
8acb3123b46c Remove a new record on cancel in grids with rowediting plugin.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 596
diff changeset
16 canceledit: this.cancelEdit
596
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
17 },
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
18 'mkommentargrid button[action=add]': {
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
19 click: this.add
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
20 },
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
21 'mkommentargrid button[action=delete]': {
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
22 click: this.remove
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
23 }
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
24 });
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
25 },
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
26
700
1e76aec72815 Renamed function edit to gridSave
Dustin Demuth <dustin@intevation.de>
parents: 697
diff changeset
27 gridSave: function(editor, context) {
596
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
28 context.record.save({
697
5b2cbc6bc39a Display Error Message on Failure
Dustin Demuth <dustin@intevation.de>
parents: 637
diff changeset
29 success: function(record, response) {
596
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
30 context.grid.initData();
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
31 context.grid.up('window').initData();
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
32 },
697
5b2cbc6bc39a Display Error Message on Failure
Dustin Demuth <dustin@intevation.de>
parents: 637
diff changeset
33 failure: function(record, response) {
5b2cbc6bc39a Display Error Message on Failure
Dustin Demuth <dustin@intevation.de>
parents: 637
diff changeset
34 var json = response.request.scope.reader.jsonData;
5b2cbc6bc39a Display Error Message on Failure
Dustin Demuth <dustin@intevation.de>
parents: 637
diff changeset
35 if (json) {
5b2cbc6bc39a Display Error Message on Failure
Dustin Demuth <dustin@intevation.de>
parents: 637
diff changeset
36 if (json.message){
5b2cbc6bc39a Display Error Message on Failure
Dustin Demuth <dustin@intevation.de>
parents: 637
diff changeset
37 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('errmsgtitle')
5b2cbc6bc39a Display Error Message on Failure
Dustin Demuth <dustin@intevation.de>
parents: 637
diff changeset
38 +' '+json.message,
5b2cbc6bc39a Display Error Message on Failure
Dustin Demuth <dustin@intevation.de>
parents: 637
diff changeset
39 Lada.getApplication().bundle.getMsg(json.message));
5b2cbc6bc39a Display Error Message on Failure
Dustin Demuth <dustin@intevation.de>
parents: 637
diff changeset
40 }
5b2cbc6bc39a Display Error Message on Failure
Dustin Demuth <dustin@intevation.de>
parents: 637
diff changeset
41 }
596
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
42 }
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
43 });
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
44 },
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
45
637
8acb3123b46c Remove a new record on cancel in grids with rowediting plugin.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 596
diff changeset
46 cancelEdit: function(editor, context) {
8acb3123b46c Remove a new record on cancel in grids with rowediting plugin.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 596
diff changeset
47 if (!context.record.get('id') ||
8acb3123b46c Remove a new record on cancel in grids with rowediting plugin.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 596
diff changeset
48 context.record.get('id') === '') {
8acb3123b46c Remove a new record on cancel in grids with rowediting plugin.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 596
diff changeset
49 editor.getCmp().store.remove(context.record);
8acb3123b46c Remove a new record on cancel in grids with rowediting plugin.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 596
diff changeset
50 }
8acb3123b46c Remove a new record on cancel in grids with rowediting plugin.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 596
diff changeset
51 },
8acb3123b46c Remove a new record on cancel in grids with rowediting plugin.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 596
diff changeset
52
596
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
53 add: function(button) {
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
54 var record = Ext.create('Lada.model.MKommentar');
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
55 record.set('messungsId', button.up('mkommentargrid').recordId);
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
56 button.up('mkommentargrid').store.insert(0, record);
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
57 button.up('mkommentargrid').rowEditing.startEdit(0, 1);
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
58 },
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
59
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
60 remove: function(button) {
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
61 var grid = button.up('grid');
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
62 var selection = grid.getView().getSelectionModel().getSelection()[0];
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
63 Ext.MessageBox.confirm('Löschen', 'Sind Sie sicher?', function(btn) {
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
64 if (btn === 'yes') {
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
65 selection.destroy({
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
66 success: function() {
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
67 button.up('window').initData();
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
68 },
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
69 failure: function() {
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
70 // TODO
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
71 }
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
72 });
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
73 }
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
74 });
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
75 }
b0a3580a41e9 Added messung kommentar grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
76 });

http://lada.wald.intevation.org