Mercurial > lada > lada-client
annotate app/controller/grid/Messmethode.js @ 766:31eaed998531
enabled removal and creation of messgroessen for a messmethode
author | Dustin Demuth <dustin@intevation.de> |
---|---|
date | Tue, 12 May 2015 14:24:41 +0200 |
parents | 62721a75d31d |
children | 5ee59111b188 |
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, |
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
|
25 select: this.selectRow |
758
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
26 }, |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
27 'messmethodengrid button[action=add]': { |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
28 click: this.add |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
29 }, |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
30 'messmethodengrid button[action=delete]': { |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
31 click: this.remove |
766
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
32 }, |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
33 //Nuklidegrid |
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 edit: this.gridSaveNuklid, |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
36 canceledit: this.cancelEdit |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
37 }, |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
38 'nuklidegrid button[action=add]': { |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
39 click: this.addNuklid |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
40 }, |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
41 'nuklidegrid button[action=remove]': { |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
42 click: this.removeNuklid |
758
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
43 } |
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 * This function is called when the grids roweditor saves |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
49 * the record. |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
50 * On success it refreshes the windows which contains the grid |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
51 * On failure it displays a message |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
52 */ |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
53 gridSave: function(editor, context) { |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
54 context.record.save({ |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
55 success: function() { |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
56 context.grid.initData(); |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
57 context.grid.up('window').initData(); |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
58 }, |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
59 failure: function(request, response) { |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
60 var json = response.request.scope.reader.jsonData; |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
61 if (json) { |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
62 if (json.message){ |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
63 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.save.title') |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
64 +' #'+json.message, |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
65 Lada.getApplication().bundle.getMsg(json.message)); |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
66 } else { |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
67 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.save.title'), |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
68 Lada.getApplication().bundle.getMsg('err.msg.generic.body')); |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
69 } |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
70 } else { |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
71 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.save.title'), |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
72 Lada.getApplication().bundle.getMsg('err.msg.response.body')); |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
73 } |
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 /** |
766
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
79 * 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
|
80 * the record. |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
81 * 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
|
82 * record. |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
83 * 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
|
84 * 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
|
85 */ |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
86 gridSaveNuklid: function(editor, context) { |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
87 console.log(context); |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
88 this.syncArray(context.store); |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
89 }, |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
90 |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
91 /** |
758
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
92 * When the edit was canceled, |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
93 * 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
|
94 */ |
766
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
95 cancelEdit: function(editor, context) { |
758
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
96 if (!context.record.get('id') || |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
97 context.record.get('id') === '') { |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
98 editor.getCmp().store.remove(context.record); |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
99 } |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
100 }, |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
101 |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
102 /** |
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
|
103 * 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
|
104 * 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
|
105 * 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
|
106 * 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
|
107 */ |
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
|
108 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
|
109 //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
|
110 //for nuklideGrid releated functions. |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
111 this.record = record; |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
112 var nuklide = record.get('messgroessen'); |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
113 |
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
|
114 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
|
115 |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
116 var mmtmessgroessenstore = this.buildNuklideStore(nuklide); |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
117 //Set Store |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
118 ngrid.setData(mmtmessgroessenstore); |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
119 |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
120 //Enable Editing |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
121 ngrid.setReadOnly(false); |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
122 }, |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
123 |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
124 /** |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
125 * 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
|
126 * With the Nuklide Store. |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
127 * It simply overwrites the Array |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
128 */ |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
129 syncArray: function(store) { |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
130 var mg = new Array(); |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
131 console.log('syncarray'); |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
132 console.log(store); |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
133 var item; |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
134 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
|
135 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
|
136 } |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
137 |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
138 // 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
|
139 this.record.set('messgroessen', mg); |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
140 var me = this; |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
141 this.record.save({ |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
142 success: function() { |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
143 console.log('Success'); |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
144 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
|
145 console.log(mg); |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
146 }, |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
147 failure: function(request, response) { |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
148 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
|
149 if (json) { |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
150 if (json.message){ |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
151 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
|
152 +' #'+json.message, |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
153 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
|
154 } else { |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
155 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
|
156 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
|
157 } |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
158 } else { |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
159 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
|
160 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
|
161 } |
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 }); |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
164 |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
165 }, |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
166 |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
167 /** |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
168 * 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
|
169 */ |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
170 buildNuklideStore: function(nuklide) { |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
171 // 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
|
172 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
|
173 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
|
174 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
|
175 } |
766
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
176 |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
177 //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
|
178 //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
|
179 var mmtmessgroessenstore = Ext.create('Ext.data.Store', { |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
180 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
|
181 }); |
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
|
182 |
766
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
183 // 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
|
184 // 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
|
185 for (n in nuklide) { |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
186 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
|
187 } |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
188 return mmtmessgroessenstore; |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
189 }, |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
190 |
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 * 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
|
193 */ |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
194 addNuklid: function(button) { |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
195 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
|
196 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
|
197 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
|
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 * 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
|
202 * 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
|
203 * 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
|
204 * 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
|
205 */ |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
206 removeNuklid: function(button) { |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
207 var grid = button.up('grid'); |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
208 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
|
209 grid.getStore().remove(selection); |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
210 var store = grid.getStore(); |
31eaed998531
enabled removal and creation of messgroessen for a messmethode
Dustin Demuth <dustin@intevation.de>
parents:
765
diff
changeset
|
211 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
|
212 }, |
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
|
213 |
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
|
214 /** |
758
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
215 * This function adds a new row |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
216 */ |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
217 add: function(button) { |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
218 var record = Ext.create('Lada.model.MmtMessprogramm'); |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
219 record.set('messprogrammId', button.up('messmethodengrid').recordId); |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
220 button.up('messmethodengrid').store.insert(0, record); |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
221 button.up('messmethodengrid').rowEditing.startEdit(0, 0); |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
222 }, |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
223 |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
224 /** |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
225 * A row can be removed from the grid with the remove |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
226 * function. It asks the user for confirmation |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
227 * 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
|
228 * on failure, an error message is shown. |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
229 */ |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
230 remove: function(button) { |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
231 var grid = button.up('grid'); |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
232 //TODO i18n |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
233 var selection = grid.getView().getSelectionModel().getSelection()[0]; |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
234 Ext.MessageBox.confirm('Löschen', 'Sind Sie sicher?', function(btn) { |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
235 if (btn === 'yes') { |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
236 selection.destroy({ |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
237 success: function() { |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
238 button.up('window').initData(); |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
239 }, |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
240 failure: function(request, response) { |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
241 var json = response.request.scope.reader.jsonData; |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
242 if (json) { |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
243 if (json.message){ |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
244 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.delete.title') |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
245 +' #'+json.message, |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
246 Lada.getApplication().bundle.getMsg(json.message)); |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
247 } else { |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
248 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.delete.title'), |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
249 Lada.getApplication().bundle.getMsg('err.msg.generic.body')); |
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 } else { |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
252 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.delete.title'), |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
253 Lada.getApplication().bundle.getMsg('err.msg.response.body')); |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
254 } |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
255 } |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
256 }); |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
257 } |
b2fcbdc4969d
Filled MessmethodenGrid with life.
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
258 }); |
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 }); |