annotate app/controller/grid/Probenehmer.js @ 1213:f4a9fe78404f

Remove debug logging.
author Tom Gottfried <tom@intevation.de>
date Thu, 13 Oct 2016 15:35:25 +0200
parents 01bcca98ae8f
children
rev   line source
984
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
1 /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
2 * Software engineering by Intevation GmbH
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
3 *
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
4 * This file is Free Software under the GNU GPL (v>=3)
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
6 * the documentation coming with IMIS-Labordaten-Application for details.
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
7 */
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
8
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
9 /**
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
10 * This is a controller for a grid of Probenehmer Stammdaten
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
11 */
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
12 Ext.define('Lada.controller.grid.Probenehmer', {
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
13 extend: 'Ext.app.Controller',
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
14
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
15 /**
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
16 * Inhitialize the controller
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
17 * It has 3 listeners
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
18 */
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
19 init: function() {
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
20 this.control({
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
21 'probenehmergrid': {
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
22 edit: this.gridSave,
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
23 canceledit: this.cancelEdit,
1078
fe5fb960da9d Handle edit and delete status for stammdaten objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1073
diff changeset
24 select: this.select,
1039
77e22ad5cc84 Use user 'funktionen' attribute to set read/write status for stammdaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1003
diff changeset
25 deselect: this.buttonToggle,
77e22ad5cc84 Use user 'funktionen' attribute to set read/write status for stammdaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1003
diff changeset
26 itemdblclick: this.edit
984
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
27 },
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
28 'probenehmergrid button[action=add]': {
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
29 click: this.add
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
30 },
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
31 'probenehmergrid button[action=delete]': {
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
32 click: this.remove
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
33 }
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
34 });
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
35 },
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
36
1078
fe5fb960da9d Handle edit and delete status for stammdaten objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1073
diff changeset
37 select: function(rowModel, record) {
fe5fb960da9d Handle edit and delete status for stammdaten objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1073
diff changeset
38 this.checkEdit(rowModel, record);
fe5fb960da9d Handle edit and delete status for stammdaten objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1073
diff changeset
39 this.buttonToggle(rowModel, record);
fe5fb960da9d Handle edit and delete status for stammdaten objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1073
diff changeset
40 },
fe5fb960da9d Handle edit and delete status for stammdaten objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1073
diff changeset
41
fe5fb960da9d Handle edit and delete status for stammdaten objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1073
diff changeset
42 checkEdit: function(rowModel, record) {
fe5fb960da9d Handle edit and delete status for stammdaten objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1073
diff changeset
43 if (!Ext.Array.contains(Lada.netzbetreiber,
1089
01bcca98ae8f Allow row-editing for items with empty netzbetreiberId.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1081
diff changeset
44 record.get('netzbetreiberId')) &&
01bcca98ae8f Allow row-editing for items with empty netzbetreiberId.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1081
diff changeset
45 record.get('netzbetreiberId') !== '') {
1078
fe5fb960da9d Handle edit and delete status for stammdaten objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1073
diff changeset
46 var grid = Ext.ComponentQuery.query('probenehmergrid')[0];
fe5fb960da9d Handle edit and delete status for stammdaten objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1073
diff changeset
47 grid.rowEditing.cancelEdit();
fe5fb960da9d Handle edit and delete status for stammdaten objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1073
diff changeset
48 return;
fe5fb960da9d Handle edit and delete status for stammdaten objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1073
diff changeset
49 }
fe5fb960da9d Handle edit and delete status for stammdaten objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1073
diff changeset
50 },
fe5fb960da9d Handle edit and delete status for stammdaten objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1073
diff changeset
51
fe5fb960da9d Handle edit and delete status for stammdaten objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1073
diff changeset
52 edit: function (gridView, record) {
1039
77e22ad5cc84 Use user 'funktionen' attribute to set read/write status for stammdaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1003
diff changeset
53 var grid = Ext.ComponentQuery.query('probenehmergrid')[0];
1078
fe5fb960da9d Handle edit and delete status for stammdaten objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1073
diff changeset
54 if (!Ext.Array.contains(Lada.netzbetreiber,
1089
01bcca98ae8f Allow row-editing for items with empty netzbetreiberId.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1081
diff changeset
55 record.get('netzbetreiberId')) &&
01bcca98ae8f Allow row-editing for items with empty netzbetreiberId.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1081
diff changeset
56 record.get('netzbetreiberId') !== '') {
1078
fe5fb960da9d Handle edit and delete status for stammdaten objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1073
diff changeset
57 grid.rowEditing.cancelEdit();
fe5fb960da9d Handle edit and delete status for stammdaten objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1073
diff changeset
58 return;
fe5fb960da9d Handle edit and delete status for stammdaten objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1073
diff changeset
59 }
1081
5e9a674d7bb4 Added Icon-column to stammdaten grid showing RW-status.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1078
diff changeset
60 grid.rowEditing.startEdit(record, 0);
1039
77e22ad5cc84 Use user 'funktionen' attribute to set read/write status for stammdaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1003
diff changeset
61 grid.down('button[action=delete]').disable();
77e22ad5cc84 Use user 'funktionen' attribute to set read/write status for stammdaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1003
diff changeset
62 },
77e22ad5cc84 Use user 'funktionen' attribute to set read/write status for stammdaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1003
diff changeset
63
984
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
64 /**
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
65 * This function is called when the grids roweditor saves
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
66 * the record.
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
67 * On success it refreshes the windows which contains the grid
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
68 * On failure it displays a message
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
69 */
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
70 gridSave: function(editor, context) {
1003
15d8c64049d1 Datensatzerzeuger now uses the server. Added i18n to confirmation messages
Dustin Demuth <dustin@intevation.de>
parents: 984
diff changeset
71 var i18n = Lada.getApplication().bundle;
984
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
72 context.record.save({
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
73 success: function(record, response) {
1073
e79403c3482e Add value for letzteAenderung and reload store on change.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1059
diff changeset
74 var grid = Ext.ComponentQuery.query('probenehmergrid')[0];
e79403c3482e Add value for letzteAenderung and reload store on change.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1059
diff changeset
75 grid.store.reload();
984
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
76 },
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
77 failure: function(record, response) {
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
78 var json = response.request.scope.reader.jsonData;
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
79 if (json) {
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
80 if (json.message){
1003
15d8c64049d1 Datensatzerzeuger now uses the server. Added i18n to confirmation messages
Dustin Demuth <dustin@intevation.de>
parents: 984
diff changeset
81 Ext.Msg.alert(i18n.getMsg('err.msg.save.title')
984
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
82 +' #'+json.message,
1003
15d8c64049d1 Datensatzerzeuger now uses the server. Added i18n to confirmation messages
Dustin Demuth <dustin@intevation.de>
parents: 984
diff changeset
83 i18n.getMsg(json.message));
984
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
84 } else {
1003
15d8c64049d1 Datensatzerzeuger now uses the server. Added i18n to confirmation messages
Dustin Demuth <dustin@intevation.de>
parents: 984
diff changeset
85 Ext.Msg.alert(i18n.getMsg('err.msg.save.title'),
15d8c64049d1 Datensatzerzeuger now uses the server. Added i18n to confirmation messages
Dustin Demuth <dustin@intevation.de>
parents: 984
diff changeset
86 i18n.getMsg('err.msg.generic.body'));
984
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
87 }
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
88 }
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
89 }
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
90 });
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
91 },
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
92
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
93 /**
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
94 * When the edit was canceled,
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
95 * the empty row might have been created by the roweditor is removed
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
96 */
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
97 cancelEdit: function(editor, context) {
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
98 if (!context.record.get('id') ||
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
99 context.record.get('id') === '') {
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
100 editor.getCmp().store.remove(context.record);
1039
77e22ad5cc84 Use user 'funktionen' attribute to set read/write status for stammdaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1003
diff changeset
101 this.buttonToggle();
984
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
102 }
1039
77e22ad5cc84 Use user 'funktionen' attribute to set read/write status for stammdaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1003
diff changeset
103 else {
77e22ad5cc84 Use user 'funktionen' attribute to set read/write status for stammdaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1003
diff changeset
104 this.buttonToggle(context.grid.getSelectionModel(), context.record);
77e22ad5cc84 Use user 'funktionen' attribute to set read/write status for stammdaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1003
diff changeset
105 }
984
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
106 },
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
107
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
108 /**
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
109 * This function adds a new row to add a probenehmer
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
110 */
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
111 add: function(button) {
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
112 var record = Ext.create('Lada.model.Probenehmer');
1073
e79403c3482e Add value for letzteAenderung and reload store on change.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1059
diff changeset
113 if (!record.get('letzteAenderung')) {
e79403c3482e Add value for letzteAenderung and reload store on change.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1059
diff changeset
114 record.data.letzteAenderung = new Date();
e79403c3482e Add value for letzteAenderung and reload store on change.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1059
diff changeset
115 }
984
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
116 button.up('probenehmergrid').store.insert(0, record);
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
117 button.up('probenehmergrid').rowEditing.startEdit(0, 1);
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
118 },
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
119
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
120 /**
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
121 * A record can be removed from the grid with the remove
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
122 * function. It asks the user for confirmation
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
123 * If the removal was confirmed, it reloads the parent window on success,
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
124 * on failure, an error message is shown.
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
125 */
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
126 remove: function(button) {
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
127 var grid = button.up('grid');
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
128 var selection = grid.getView().getSelectionModel().getSelection()[0];
1003
15d8c64049d1 Datensatzerzeuger now uses the server. Added i18n to confirmation messages
Dustin Demuth <dustin@intevation.de>
parents: 984
diff changeset
129 var i18n = Lada.getApplication().bundle;
15d8c64049d1 Datensatzerzeuger now uses the server. Added i18n to confirmation messages
Dustin Demuth <dustin@intevation.de>
parents: 984
diff changeset
130 Ext.MessageBox.confirm(i18n.getMsg('delete'),
15d8c64049d1 Datensatzerzeuger now uses the server. Added i18n to confirmation messages
Dustin Demuth <dustin@intevation.de>
parents: 984
diff changeset
131 i18n.getMsg('confirmation.question'),
15d8c64049d1 Datensatzerzeuger now uses the server. Added i18n to confirmation messages
Dustin Demuth <dustin@intevation.de>
parents: 984
diff changeset
132 function(btn) {
984
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
133 if (btn === 'yes') {
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
134 selection.destroy({
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
135 success: function() {
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
136 //DO NOTHING
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
137 },
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
138 failure: function(request, response) {
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
139 var json = response.request.scope.reader.jsonData;
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
140 if (json) {
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
141 if (json.message){
1003
15d8c64049d1 Datensatzerzeuger now uses the server. Added i18n to confirmation messages
Dustin Demuth <dustin@intevation.de>
parents: 984
diff changeset
142 Ext.Msg.alert(i18n.getMsg('err.msg.delete.title')
984
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
143 +' #'+json.message,
1003
15d8c64049d1 Datensatzerzeuger now uses the server. Added i18n to confirmation messages
Dustin Demuth <dustin@intevation.de>
parents: 984
diff changeset
144 i18n.getMsg(json.message));
984
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
145 } else {
1003
15d8c64049d1 Datensatzerzeuger now uses the server. Added i18n to confirmation messages
Dustin Demuth <dustin@intevation.de>
parents: 984
diff changeset
146 Ext.Msg.alert(i18n.getMsg('err.msg.delete.title'),
15d8c64049d1 Datensatzerzeuger now uses the server. Added i18n to confirmation messages
Dustin Demuth <dustin@intevation.de>
parents: 984
diff changeset
147 i18n.getMsg('err.msg.generic.body'));
984
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
148 }
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
149 } else {
1003
15d8c64049d1 Datensatzerzeuger now uses the server. Added i18n to confirmation messages
Dustin Demuth <dustin@intevation.de>
parents: 984
diff changeset
150 Ext.Msg.alert(i18n.getMsg('err.msg.delete.title'),
15d8c64049d1 Datensatzerzeuger now uses the server. Added i18n to confirmation messages
Dustin Demuth <dustin@intevation.de>
parents: 984
diff changeset
151 i18n.getMsg('err.msg.response.body'));
984
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
152 }
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
153 }
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
154 });
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
155 }
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
156 });
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
157 grid.down('button[action=delete]').disable();
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
158 },
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
159
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
160 /**
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
161 * Enables/Disables a set of buttons
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
162 **/
1039
77e22ad5cc84 Use user 'funktionen' attribute to set read/write status for stammdaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1003
diff changeset
163 buttonToggle: function(rowModel, record) {
77e22ad5cc84 Use user 'funktionen' attribute to set read/write status for stammdaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1003
diff changeset
164 if (!Ext.Array.contains(Lada.funktionen, 4)) {
77e22ad5cc84 Use user 'funktionen' attribute to set read/write status for stammdaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1003
diff changeset
165 return;
77e22ad5cc84 Use user 'funktionen' attribute to set read/write status for stammdaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1003
diff changeset
166 }
77e22ad5cc84 Use user 'funktionen' attribute to set read/write status for stammdaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1003
diff changeset
167 var grid = Ext.ComponentQuery.query('probenehmergrid')[0];
1078
fe5fb960da9d Handle edit and delete status for stammdaten objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1073
diff changeset
168 if (!record ||
fe5fb960da9d Handle edit and delete status for stammdaten objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1073
diff changeset
169 !Ext.Array.contains(Lada.netzbetreiber,
fe5fb960da9d Handle edit and delete status for stammdaten objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1073
diff changeset
170 record.get('netzbetreiberId'))) {
1039
77e22ad5cc84 Use user 'funktionen' attribute to set read/write status for stammdaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1003
diff changeset
171 grid.down('button[action=delete]').disable();
1059
fa422d69940c Fixed button toggle on cancel edit.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1039
diff changeset
172 return;
1039
77e22ad5cc84 Use user 'funktionen' attribute to set read/write status for stammdaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1003
diff changeset
173 }
77e22ad5cc84 Use user 'funktionen' attribute to set read/write status for stammdaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1003
diff changeset
174 if (record.get('readonly') ||
77e22ad5cc84 Use user 'funktionen' attribute to set read/write status for stammdaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1003
diff changeset
175 rowModel.selected.items.length === 0) {
984
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
176 grid.down('button[action=delete]').disable();
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
177 }
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
178 else {
1039
77e22ad5cc84 Use user 'funktionen' attribute to set read/write status for stammdaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1003
diff changeset
179 if (grid.getPlugin('rowedit').editing) {
984
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
180 //only enable buttons, when grid is not beeing edited
1039
77e22ad5cc84 Use user 'funktionen' attribute to set read/write status for stammdaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1003
diff changeset
181 grid.down('button[action=delete]').disable();
77e22ad5cc84 Use user 'funktionen' attribute to set read/write status for stammdaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1003
diff changeset
182 }
77e22ad5cc84 Use user 'funktionen' attribute to set read/write status for stammdaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1003
diff changeset
183 else {
984
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
184 grid.down('button[action=delete]').enable();
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
185 }
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
186 }
1039
77e22ad5cc84 Use user 'funktionen' attribute to set read/write status for stammdaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1003
diff changeset
187 }
984
b21421ba6917 added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
188 });

http://lada.wald.intevation.org