Mercurial > lada > lada-client
annotate app/controller/grid/Messmethode.js @ 1429:8e5326142711
Removed extra params from messgroesse store to show all entries in messwert grid.
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Fri, 07 Apr 2017 09:57:26 +0200 |
parents | 01f083db45b7 |
children |
rev | line source |
---|---|
758
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
1 /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
2 * Software engineering by Intevation GmbH |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
3 * |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
4 * This file is Free Software under the GNU GPL (v>=3) |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
6 * the documentation coming with IMIS-Labordaten-Application for details. |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
7 */ |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
8 |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
9 /** |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
10 * This is a controller for a grid of Messmethode |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
11 */ |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
12 Ext.define('Lada.controller.grid.Messmethode', { |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
13 extend: 'Ext.app.Controller', |
766
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
14 record: null, |
758
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
15 |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
16 /** |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
17 * Inhitialize the controller |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
18 * It has 3 listeners |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
19 */ |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
20 init: function() { |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
21 this.control({ |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
22 'messmethodengrid': { |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
23 edit: this.gridSave, |
764
ba8c0e754979
Some work was done on the nuklidegrid, added a checkbox model to select the nuklide. Looks OK, but has no function right now
Dustin Demuth <dustin@intevation.de>
parents:
758
diff
changeset
|
24 canceledit: this.cancelEdit, |
768
380edfecac67
changes on the margins, erratic behaviour is not fixed
Dustin Demuth <dustin@intevation.de>
parents:
767
diff
changeset
|
25 select: this.selectRow, |
380edfecac67
changes on the margins, erratic behaviour is not fixed
Dustin Demuth <dustin@intevation.de>
parents:
767
diff
changeset
|
26 deselect: this.deselectRow |
758
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
27 }, |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
28 'messmethodengrid button[action=add]': { |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
29 click: this.add |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
30 }, |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
31 'messmethodengrid button[action=delete]': { |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
32 click: this.remove |
766
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
33 }, |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
34 //Nuklidegrid |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
35 'nuklidegrid': { |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
36 edit: this.gridSaveNuklid, |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
37 canceledit: this.cancelEdit |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
38 }, |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
39 'nuklidegrid button[action=add]': { |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
40 click: this.addNuklid |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
41 }, |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
42 'nuklidegrid button[action=remove]': { |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
43 click: this.removeNuklid |
758
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
44 } |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
45 }); |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
46 }, |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
47 |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
48 /** |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
49 * This function is called when the grids roweditor saves |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
50 * the record. |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
51 * On success it refreshes the windows which contains the grid |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
52 * On failure it displays a message |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
53 */ |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
54 gridSave: function(editor, context) { |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
55 context.record.save({ |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
56 success: function() { |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
57 context.grid.initData(); |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
58 context.grid.up('window').initData(); |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
59 }, |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
60 failure: function(request, response) { |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
61 var json = response.request.scope.reader.jsonData; |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
62 if (json) { |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
63 if (json.message){ |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
64 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.save.title') |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
65 +' #'+json.message, |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
66 Lada.getApplication().bundle.getMsg(json.message)); |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
67 } else { |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
68 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.save.title'), |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
69 Lada.getApplication().bundle.getMsg('err.msg.generic.body')); |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
70 } |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
71 } else { |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
72 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.save.title'), |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
73 Lada.getApplication().bundle.getMsg('err.msg.response.body')); |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
74 } |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
75 } |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
76 }); |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
77 }, |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
78 |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
79 /** |
766
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
80 * This function is called when the Nuklide-grids roweditor saves |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
81 * the record. |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
82 * It adds the nuklid to the messgroessen-array of the messmethode |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
83 * record. |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
84 * On success it refreshes the windows which contains the grid |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
85 * On failure it displays a message |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
86 */ |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
87 gridSaveNuklid: function(editor, context) { |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
88 console.log(context); |
767
5ee59111b188
Add/Remove is now reliable
Dustin Demuth <dustin@intevation.de>
parents:
766
diff
changeset
|
89 var modified = false; |
5ee59111b188
Add/Remove is now reliable
Dustin Demuth <dustin@intevation.de>
parents:
766
diff
changeset
|
90 var id = context.newValues.id; |
5ee59111b188
Add/Remove is now reliable
Dustin Demuth <dustin@intevation.de>
parents:
766
diff
changeset
|
91 var mg = this.record.get('messgroessen'); |
5ee59111b188
Add/Remove is now reliable
Dustin Demuth <dustin@intevation.de>
parents:
766
diff
changeset
|
92 |
5ee59111b188
Add/Remove is now reliable
Dustin Demuth <dustin@intevation.de>
parents:
766
diff
changeset
|
93 //Test if this Nuklid already exists. |
5ee59111b188
Add/Remove is now reliable
Dustin Demuth <dustin@intevation.de>
parents:
766
diff
changeset
|
94 if (Array.isArray(id)){ |
5ee59111b188
Add/Remove is now reliable
Dustin Demuth <dustin@intevation.de>
parents:
766
diff
changeset
|
95 for (i in id) { |
5ee59111b188
Add/Remove is now reliable
Dustin Demuth <dustin@intevation.de>
parents:
766
diff
changeset
|
96 //Only insert if value does not exist |
5ee59111b188
Add/Remove is now reliable
Dustin Demuth <dustin@intevation.de>
parents:
766
diff
changeset
|
97 if (! Ext.Array.contains(mg, id[i])) { |
5ee59111b188
Add/Remove is now reliable
Dustin Demuth <dustin@intevation.de>
parents:
766
diff
changeset
|
98 modified = true; |
5ee59111b188
Add/Remove is now reliable
Dustin Demuth <dustin@intevation.de>
parents:
766
diff
changeset
|
99 } |
5ee59111b188
Add/Remove is now reliable
Dustin Demuth <dustin@intevation.de>
parents:
766
diff
changeset
|
100 } |
5ee59111b188
Add/Remove is now reliable
Dustin Demuth <dustin@intevation.de>
parents:
766
diff
changeset
|
101 } |
5ee59111b188
Add/Remove is now reliable
Dustin Demuth <dustin@intevation.de>
parents:
766
diff
changeset
|
102 else { |
5ee59111b188
Add/Remove is now reliable
Dustin Demuth <dustin@intevation.de>
parents:
766
diff
changeset
|
103 if (! Ext.Array.contains(mg, id)) { |
5ee59111b188
Add/Remove is now reliable
Dustin Demuth <dustin@intevation.de>
parents:
766
diff
changeset
|
104 mg.push(id); |
5ee59111b188
Add/Remove is now reliable
Dustin Demuth <dustin@intevation.de>
parents:
766
diff
changeset
|
105 modified = true; |
5ee59111b188
Add/Remove is now reliable
Dustin Demuth <dustin@intevation.de>
parents:
766
diff
changeset
|
106 } |
5ee59111b188
Add/Remove is now reliable
Dustin Demuth <dustin@intevation.de>
parents:
766
diff
changeset
|
107 } |
5ee59111b188
Add/Remove is now reliable
Dustin Demuth <dustin@intevation.de>
parents:
766
diff
changeset
|
108 |
5ee59111b188
Add/Remove is now reliable
Dustin Demuth <dustin@intevation.de>
parents:
766
diff
changeset
|
109 if (modified) { |
5ee59111b188
Add/Remove is now reliable
Dustin Demuth <dustin@intevation.de>
parents:
766
diff
changeset
|
110 this.syncArray(context.store); |
5ee59111b188
Add/Remove is now reliable
Dustin Demuth <dustin@intevation.de>
parents:
766
diff
changeset
|
111 } |
5ee59111b188
Add/Remove is now reliable
Dustin Demuth <dustin@intevation.de>
parents:
766
diff
changeset
|
112 else { |
5ee59111b188
Add/Remove is now reliable
Dustin Demuth <dustin@intevation.de>
parents:
766
diff
changeset
|
113 editor.getCmp().store.remove(context.record); |
5ee59111b188
Add/Remove is now reliable
Dustin Demuth <dustin@intevation.de>
parents:
766
diff
changeset
|
114 } |
766
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
115 }, |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
116 |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
117 /** |
758
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
118 * When the edit was canceled, |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
119 * the empty row might have been created by the roweditor is removed |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
120 */ |
766
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
121 cancelEdit: function(editor, context) { |
758
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
122 if (!context.record.get('id') || |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
123 context.record.get('id') === '') { |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
124 editor.getCmp().store.remove(context.record); |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
125 } |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
126 }, |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
127 |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
128 /** |
764
ba8c0e754979
Some work was done on the nuklidegrid, added a checkbox model to select the nuklide. Looks OK, but has no function right now
Dustin Demuth <dustin@intevation.de>
parents:
758
diff
changeset
|
129 * When a row is selected, |
ba8c0e754979
Some work was done on the nuklidegrid, added a checkbox model to select the nuklide. Looks OK, but has no function right now
Dustin Demuth <dustin@intevation.de>
parents:
758
diff
changeset
|
130 * the nuklid-grid will be updated |
ba8c0e754979
Some work was done on the nuklidegrid, added a checkbox model to select the nuklide. Looks OK, but has no function right now
Dustin Demuth <dustin@intevation.de>
parents:
758
diff
changeset
|
131 * to display the nuklide which are possible for this |
ba8c0e754979
Some work was done on the nuklidegrid, added a checkbox model to select the nuklide. Looks OK, but has no function right now
Dustin Demuth <dustin@intevation.de>
parents:
758
diff
changeset
|
132 * Messmethod |
ba8c0e754979
Some work was done on the nuklidegrid, added a checkbox model to select the nuklide. Looks OK, but has no function right now
Dustin Demuth <dustin@intevation.de>
parents:
758
diff
changeset
|
133 */ |
ba8c0e754979
Some work was done on the nuklidegrid, added a checkbox model to select the nuklide. Looks OK, but has no function right now
Dustin Demuth <dustin@intevation.de>
parents:
758
diff
changeset
|
134 selectRow: function(row, record, index) { |
766
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
135 //save the record to this object. which makes it accessible |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
136 //for nuklideGrid releated functions. |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
137 this.record = record; |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
138 var nuklide = record.get('messgroessen'); |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
139 |
764
ba8c0e754979
Some work was done on the nuklidegrid, added a checkbox model to select the nuklide. Looks OK, but has no function right now
Dustin Demuth <dustin@intevation.de>
parents:
758
diff
changeset
|
140 var ngrid = row.view.up('window').down('nuklidegrid'); |
766
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
141 |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
142 var mmtmessgroessenstore = this.buildNuklideStore(nuklide); |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
143 //Set Store |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
144 ngrid.setData(mmtmessgroessenstore); |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
145 |
1419
01f083db45b7
Use readonly flag to set edit status of UI
Raimund Renkert <raimund.renkert@intevation.de>
parents:
972
diff
changeset
|
146 //Enable Editing depending on the readonly state of the messprogramm. |
01f083db45b7
Use readonly flag to set edit status of UI
Raimund Renkert <raimund.renkert@intevation.de>
parents:
972
diff
changeset
|
147 ngrid.setReadOnly(row.view.up('window').record.get('readonly')); |
766
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
148 }, |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
149 |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
150 /** |
768
380edfecac67
changes on the margins, erratic behaviour is not fixed
Dustin Demuth <dustin@intevation.de>
parents:
767
diff
changeset
|
151 * Clear the nuklideGrid when a MMT Row is deselected |
380edfecac67
changes on the margins, erratic behaviour is not fixed
Dustin Demuth <dustin@intevation.de>
parents:
767
diff
changeset
|
152 */ |
380edfecac67
changes on the margins, erratic behaviour is not fixed
Dustin Demuth <dustin@intevation.de>
parents:
767
diff
changeset
|
153 deselectRow: function(row, record, index){ |
380edfecac67
changes on the margins, erratic behaviour is not fixed
Dustin Demuth <dustin@intevation.de>
parents:
767
diff
changeset
|
154 var ngrid = row.view.up('window').down('nuklidegrid'); |
380edfecac67
changes on the margins, erratic behaviour is not fixed
Dustin Demuth <dustin@intevation.de>
parents:
767
diff
changeset
|
155 ngrid.initData(); |
380edfecac67
changes on the margins, erratic behaviour is not fixed
Dustin Demuth <dustin@intevation.de>
parents:
767
diff
changeset
|
156 }, |
380edfecac67
changes on the margins, erratic behaviour is not fixed
Dustin Demuth <dustin@intevation.de>
parents:
767
diff
changeset
|
157 |
380edfecac67
changes on the margins, erratic behaviour is not fixed
Dustin Demuth <dustin@intevation.de>
parents:
767
diff
changeset
|
158 /** |
766
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
159 * This function syncs the Messmethoden-Messgroessen Array |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
160 * With the Nuklide Store. |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
161 * It simply overwrites the Array |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
162 */ |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
163 syncArray: function(store) { |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
164 var mg = new Array(); |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
165 console.log('syncarray'); |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
166 console.log(store); |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
167 var item; |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
168 for (item in store.data.items){ |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
169 mg.push(store.data.items[item].get('id')); |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
170 } |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
171 |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
172 // Ext.Array.contains(mg, id[i]) |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
173 this.record.set('messgroessen', mg); |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
174 var me = this; |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
175 this.record.save({ |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
176 success: function() { |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
177 console.log('Success'); |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
178 console.log(me.record.get('messgroessen')); |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
179 console.log(mg); |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
180 }, |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
181 failure: function(request, response) { |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
182 var json = response.request.scope.reader.jsonData; |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
183 if (json) { |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
184 if (json.message){ |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
185 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.save.title') |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
186 +' #'+json.message, |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
187 Lada.getApplication().bundle.getMsg(json.message)); |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
188 } else { |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
189 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.save.title'), |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
190 Lada.getApplication().bundle.getMsg('err.msg.generic.body')); |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
191 } |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
192 } else { |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
193 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.save.title'), |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
194 Lada.getApplication().bundle.getMsg('err.msg.response.body')); |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
195 } |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
196 } |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
197 }); |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
198 |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
199 }, |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
200 |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
201 /** |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
202 * Return a MessgroessenStore created from nuklide array |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
203 */ |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
204 buildNuklideStore: function(nuklide) { |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
205 // Create a fully populated Messgroessen Store |
764
ba8c0e754979
Some work was done on the nuklidegrid, added a checkbox model to select the nuklide. Looks OK, but has no function right now
Dustin Demuth <dustin@intevation.de>
parents:
758
diff
changeset
|
206 var store = Ext.data.StoreManager.get('messgroessen'); |
ba8c0e754979
Some work was done on the nuklidegrid, added a checkbox model to select the nuklide. Looks OK, but has no function right now
Dustin Demuth <dustin@intevation.de>
parents:
758
diff
changeset
|
207 if (!store) { |
ba8c0e754979
Some work was done on the nuklidegrid, added a checkbox model to select the nuklide. Looks OK, but has no function right now
Dustin Demuth <dustin@intevation.de>
parents:
758
diff
changeset
|
208 store = Ext.create('Lada.store.Messgroessen'); |
ba8c0e754979
Some work was done on the nuklidegrid, added a checkbox model to select the nuklide. Looks OK, but has no function right now
Dustin Demuth <dustin@intevation.de>
parents:
758
diff
changeset
|
209 } |
766
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
210 |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
211 //Create an empty Messgroessen Store which will be populated with the |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
212 //Messgroessen defined in the Messmethoden record. |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
213 var mmtmessgroessenstore = Ext.create('Ext.data.Store', { |
786
d2ee6858f452
removed trailing comma
Dustin Demuth <dustin@intevation.de>
parents:
768
diff
changeset
|
214 model: 'Lada.model.Messgroesse' |
765
62721a75d31d
A draft on how the Nuklide could be selected... maybe this path can be used
Dustin Demuth <dustin@intevation.de>
parents:
764
diff
changeset
|
215 }); |
62721a75d31d
A draft on how the Nuklide could be selected... maybe this path can be used
Dustin Demuth <dustin@intevation.de>
parents:
764
diff
changeset
|
216 |
766
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
217 // Copy every Record from Messgroessenstore to the empty Store |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
218 // which was defined in the messmethode record |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
219 for (n in nuklide) { |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
220 mmtmessgroessenstore.add(store.getById(nuklide[n])); |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
221 } |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
222 return mmtmessgroessenstore; |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
223 }, |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
224 |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
225 /** |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
226 * This function adds a new row in the NuklidGrid |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
227 */ |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
228 addNuklid: function(button) { |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
229 var record = Ext.create('Lada.model.Messgroesse'); |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
230 button.up('nuklidegrid').store.insert(0, record); |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
231 button.up('nuklidegrid').rowEditing.startEdit(0, 0); |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
232 }, |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
233 |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
234 /** |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
235 * A row can be removed from the Nuklidgrid with the remove |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
236 * function. It asks the user for confirmation |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
237 * If the removal was confirmed, it reloads the parent window on success, |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
238 * on failure, an error message is shown. |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
239 */ |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
240 removeNuklid: function(button) { |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
241 var grid = button.up('grid'); |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
242 var selection = grid.getView().getSelectionModel().getSelection()[0]; |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
243 grid.getStore().remove(selection); |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
244 var store = grid.getStore(); |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
245 this.syncArray(store); |
764
ba8c0e754979
Some work was done on the nuklidegrid, added a checkbox model to select the nuklide. Looks OK, but has no function right now
Dustin Demuth <dustin@intevation.de>
parents:
758
diff
changeset
|
246 }, |
ba8c0e754979
Some work was done on the nuklidegrid, added a checkbox model to select the nuklide. Looks OK, but has no function right now
Dustin Demuth <dustin@intevation.de>
parents:
758
diff
changeset
|
247 |
ba8c0e754979
Some work was done on the nuklidegrid, added a checkbox model to select the nuklide. Looks OK, but has no function right now
Dustin Demuth <dustin@intevation.de>
parents:
758
diff
changeset
|
248 /** |
758
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
249 * This function adds a new row |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
250 */ |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
251 add: function(button) { |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
252 var record = Ext.create('Lada.model.MmtMessprogramm'); |
972
24b5684d74d7
Set letzteAenderung in a Bunch of controllers.
Dustin Demuth <dustin@intevation.de>
parents:
786
diff
changeset
|
253 if (!record.get('letzteAenderung')) { |
24b5684d74d7
Set letzteAenderung in a Bunch of controllers.
Dustin Demuth <dustin@intevation.de>
parents:
786
diff
changeset
|
254 record.data.letzteAenderung = new Date(); |
24b5684d74d7
Set letzteAenderung in a Bunch of controllers.
Dustin Demuth <dustin@intevation.de>
parents:
786
diff
changeset
|
255 } |
758
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
256 record.set('messprogrammId', button.up('messmethodengrid').recordId); |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
257 button.up('messmethodengrid').store.insert(0, record); |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
258 button.up('messmethodengrid').rowEditing.startEdit(0, 0); |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
259 }, |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
260 |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
261 /** |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
262 * A row can be removed from the grid with the remove |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
263 * function. It asks the user for confirmation |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
264 * If the removal was confirmed, it reloads the parent window on success, |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
265 * on failure, an error message is shown. |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
266 */ |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
267 remove: function(button) { |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
268 var grid = button.up('grid'); |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
269 //TODO i18n |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
270 var selection = grid.getView().getSelectionModel().getSelection()[0]; |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
271 Ext.MessageBox.confirm('Löschen', 'Sind Sie sicher?', function(btn) { |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
272 if (btn === 'yes') { |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
273 selection.destroy({ |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
274 success: function() { |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
275 button.up('window').initData(); |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
276 }, |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
277 failure: function(request, response) { |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
278 var json = response.request.scope.reader.jsonData; |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
279 if (json) { |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
280 if (json.message){ |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
281 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.delete.title') |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
282 +' #'+json.message, |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
283 Lada.getApplication().bundle.getMsg(json.message)); |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
284 } else { |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
285 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.delete.title'), |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
286 Lada.getApplication().bundle.getMsg('err.msg.generic.body')); |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
287 } |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
288 } else { |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
289 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.delete.title'), |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
290 Lada.getApplication().bundle.getMsg('err.msg.response.body')); |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
291 } |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
292 } |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
293 }); |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
294 } |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
295 }); |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
296 } |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
297 }); |