Mercurial > lada > lada-client
annotate app/controller/Orte.js @ 465:20df35a31490
Improved import dialog
author | Torsten Irländer <torsten.irlaender@intevation.de> |
---|---|
date | Thu, 09 Jan 2014 11:30:34 +0100 |
parents | edb9dee114f8 |
children | debfcc7713e3 |
rev | line source |
---|---|
292
73a2c114db64
Inherit from Base controller
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
217
diff
changeset
|
1 /** |
73a2c114db64
Inherit from Base controller
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
217
diff
changeset
|
2 * Controller for Orte |
73a2c114db64
Inherit from Base controller
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
217
diff
changeset
|
3 */ |
109
2308094f5a8c
Added forms to add Orte
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
4 Ext.define('Lada.controller.Orte', { |
292
73a2c114db64
Inherit from Base controller
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
217
diff
changeset
|
5 extend: 'Lada.controller.Base', |
109
2308094f5a8c
Added forms to add Orte
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
6 views: [ |
2308094f5a8c
Added forms to add Orte
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
7 'orte.List', |
447
12231f31c112
Apply new workflow in orte dialog.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
362
diff
changeset
|
8 'orte.Create', |
12231f31c112
Apply new workflow in orte dialog.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
362
diff
changeset
|
9 'orte.CreateOrt' |
109
2308094f5a8c
Added forms to add Orte
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
10 ], |
2308094f5a8c
Added forms to add Orte
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
11 stores: [ |
149
26ac4c99f8c4
Added Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
109
diff
changeset
|
12 'Orte', |
26ac4c99f8c4
Added Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
109
diff
changeset
|
13 'Ortedetails', |
26ac4c99f8c4
Added Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
109
diff
changeset
|
14 'Staaten', |
26ac4c99f8c4
Added Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
109
diff
changeset
|
15 'Verwaltungseinheiten' |
109
2308094f5a8c
Added forms to add Orte
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
16 ], |
2308094f5a8c
Added forms to add Orte
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
17 models: [ |
2308094f5a8c
Added forms to add Orte
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
18 'Ort' |
2308094f5a8c
Added forms to add Orte
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
19 ], |
2308094f5a8c
Added forms to add Orte
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
20 init: function() { |
2308094f5a8c
Added forms to add Orte
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
21 console.log('Initialising the Orte controller'); |
292
73a2c114db64
Inherit from Base controller
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
217
diff
changeset
|
22 this.callParent(); |
73a2c114db64
Inherit from Base controller
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
217
diff
changeset
|
23 }, |
73a2c114db64
Inherit from Base controller
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
217
diff
changeset
|
24 addListeners: function() { |
109
2308094f5a8c
Added forms to add Orte
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
25 this.control({ |
2308094f5a8c
Added forms to add Orte
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
26 'ortelist': { |
292
73a2c114db64
Inherit from Base controller
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
217
diff
changeset
|
27 itemdblclick: this.editItem |
109
2308094f5a8c
Added forms to add Orte
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
28 }, |
2308094f5a8c
Added forms to add Orte
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
29 'ortelist toolbar button[action=add]': { |
292
73a2c114db64
Inherit from Base controller
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
217
diff
changeset
|
30 click: this.addItem |
109
2308094f5a8c
Added forms to add Orte
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
31 }, |
2308094f5a8c
Added forms to add Orte
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
32 'ortelist toolbar button[action=delete]': { |
292
73a2c114db64
Inherit from Base controller
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
217
diff
changeset
|
33 click: this.deleteItem |
109
2308094f5a8c
Added forms to add Orte
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
34 }, |
149
26ac4c99f8c4
Added Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
109
diff
changeset
|
35 'ortecreate button[action=save]': { |
292
73a2c114db64
Inherit from Base controller
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
217
diff
changeset
|
36 click: this.saveItem |
149
26ac4c99f8c4
Added Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
109
diff
changeset
|
37 }, |
447
12231f31c112
Apply new workflow in orte dialog.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
362
diff
changeset
|
38 'ortecreate form button[action=newort]': { |
12231f31c112
Apply new workflow in orte dialog.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
362
diff
changeset
|
39 click: this.createOrt |
12231f31c112
Apply new workflow in orte dialog.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
362
diff
changeset
|
40 }, |
12231f31c112
Apply new workflow in orte dialog.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
362
diff
changeset
|
41 'createortdetail button[action=save]': { |
12231f31c112
Apply new workflow in orte dialog.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
362
diff
changeset
|
42 click: this.saveNewOrt |
12231f31c112
Apply new workflow in orte dialog.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
362
diff
changeset
|
43 }, |
109
2308094f5a8c
Added forms to add Orte
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
44 'ortecreate form': { |
2308094f5a8c
Added forms to add Orte
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
45 savesuccess: this.createSuccess, |
2308094f5a8c
Added forms to add Orte
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
46 savefailure: this.createFailure |
2308094f5a8c
Added forms to add Orte
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
47 }, |
2308094f5a8c
Added forms to add Orte
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
48 'orteedit form': { |
2308094f5a8c
Added forms to add Orte
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
49 savesuccess: this.editSuccess, |
2308094f5a8c
Added forms to add Orte
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
50 savefailure: this.editFailure |
2308094f5a8c
Added forms to add Orte
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
51 } |
2308094f5a8c
Added forms to add Orte
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
52 }); |
2308094f5a8c
Added forms to add Orte
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
53 }, |
447
12231f31c112
Apply new workflow in orte dialog.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
362
diff
changeset
|
54 createOrt: function(button) { |
12231f31c112
Apply new workflow in orte dialog.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
362
diff
changeset
|
55 console.log('button clicked'); |
12231f31c112
Apply new workflow in orte dialog.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
362
diff
changeset
|
56 var win = Ext.create('Lada.view.orte.CreateOrt',{}); |
12231f31c112
Apply new workflow in orte dialog.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
362
diff
changeset
|
57 win.show(); |
12231f31c112
Apply new workflow in orte dialog.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
362
diff
changeset
|
58 }, |
12231f31c112
Apply new workflow in orte dialog.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
362
diff
changeset
|
59 saveNewOrt: function(button) { |
12231f31c112
Apply new workflow in orte dialog.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
362
diff
changeset
|
60 console.log('button clicked'); |
12231f31c112
Apply new workflow in orte dialog.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
362
diff
changeset
|
61 |
12231f31c112
Apply new workflow in orte dialog.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
362
diff
changeset
|
62 var form = button.up('window').down('form').getForm(); |
12231f31c112
Apply new workflow in orte dialog.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
362
diff
changeset
|
63 var ortdetailstore = Ext.getStore('Ortedetails'); |
12231f31c112
Apply new workflow in orte dialog.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
362
diff
changeset
|
64 var ortdetail = Ext.create('Lada.model.Ortdetail'); |
12231f31c112
Apply new workflow in orte dialog.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
362
diff
changeset
|
65 var fields = ['beschreibung', 'hoeheLand', |
12231f31c112
Apply new workflow in orte dialog.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
362
diff
changeset
|
66 'latitude', 'longitude', 'staatId', 'gemId']; |
12231f31c112
Apply new workflow in orte dialog.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
362
diff
changeset
|
67 for (var i = fields.length - 1; i >= 0; i--){ |
12231f31c112
Apply new workflow in orte dialog.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
362
diff
changeset
|
68 var ffield = form.findField("ort_"+fields[i]); |
12231f31c112
Apply new workflow in orte dialog.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
362
diff
changeset
|
69 ortdetail.set(fields[i], ffield.getValue()); |
12231f31c112
Apply new workflow in orte dialog.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
362
diff
changeset
|
70 } |
12231f31c112
Apply new workflow in orte dialog.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
362
diff
changeset
|
71 ortdetailstore.add(ortdetail); |
12231f31c112
Apply new workflow in orte dialog.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
362
diff
changeset
|
72 ortdetailstore.sync({ |
12231f31c112
Apply new workflow in orte dialog.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
362
diff
changeset
|
73 success: function(batch, options) { |
12231f31c112
Apply new workflow in orte dialog.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
362
diff
changeset
|
74 console.log(batch); |
12231f31c112
Apply new workflow in orte dialog.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
362
diff
changeset
|
75 var od = Ext.ComponentQuery.query('ortdetail'); |
12231f31c112
Apply new workflow in orte dialog.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
362
diff
changeset
|
76 console.log(od); |
12231f31c112
Apply new workflow in orte dialog.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
362
diff
changeset
|
77 batch.operations[0].resultSet.records[0].data; |
12231f31c112
Apply new workflow in orte dialog.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
362
diff
changeset
|
78 var response = batch.operations[0].resultSet.records[0].data; |
12231f31c112
Apply new workflow in orte dialog.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
362
diff
changeset
|
79 od[0].setValue(response.ortId); |
12231f31c112
Apply new workflow in orte dialog.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
362
diff
changeset
|
80 console.log('id:' + response.ortId); |
12231f31c112
Apply new workflow in orte dialog.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
362
diff
changeset
|
81 button.up('window').close(); |
12231f31c112
Apply new workflow in orte dialog.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
362
diff
changeset
|
82 }, |
12231f31c112
Apply new workflow in orte dialog.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
362
diff
changeset
|
83 failure: function() { |
12231f31c112
Apply new workflow in orte dialog.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
362
diff
changeset
|
84 console.log('Error on saving Ortdetails'); |
12231f31c112
Apply new workflow in orte dialog.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
362
diff
changeset
|
85 ortdetailstore.remove(ortdetail); |
12231f31c112
Apply new workflow in orte dialog.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
362
diff
changeset
|
86 } |
12231f31c112
Apply new workflow in orte dialog.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
362
diff
changeset
|
87 }); |
12231f31c112
Apply new workflow in orte dialog.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
362
diff
changeset
|
88 }, |
292
73a2c114db64
Inherit from Base controller
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
217
diff
changeset
|
89 saveItem: function(button) { |
149
26ac4c99f8c4
Added Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
109
diff
changeset
|
90 console.log('Saving Ort'); |
26ac4c99f8c4
Added Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
109
diff
changeset
|
91 var form = button.up('window').down('form'); |
154
16ba7e2465fd
Implemented creating and editing new l_ort. Created editing orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
149
diff
changeset
|
92 var fform = form.getForm(); |
16ba7e2465fd
Implemented creating and editing new l_ort. Created editing orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
149
diff
changeset
|
93 |
16ba7e2465fd
Implemented creating and editing new l_ort. Created editing orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
149
diff
changeset
|
94 var ortdetail = null; |
16ba7e2465fd
Implemented creating and editing new l_ort. Created editing orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
149
diff
changeset
|
95 var ortdetailstore = Ext.getStore('Ortedetails'); |
155
5414e611097e
Set ortId in l_ort if new ortdetail was created.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
154
diff
changeset
|
96 var newortdetail = false; |
154
16ba7e2465fd
Implemented creating and editing new l_ort. Created editing orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
149
diff
changeset
|
97 |
216
6aedf2026fb4
Fixed issue23
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
215
diff
changeset
|
98 var ortidfield = fform.findField('ortId'); |
6aedf2026fb4
Fixed issue23
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
215
diff
changeset
|
99 var ortid = ortidfield.getValue(); |
154
16ba7e2465fd
Implemented creating and editing new l_ort. Created editing orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
149
diff
changeset
|
100 if (ortid === null) { |
16ba7e2465fd
Implemented creating and editing new l_ort. Created editing orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
149
diff
changeset
|
101 console.log('New Ortdetail'); |
16ba7e2465fd
Implemented creating and editing new l_ort. Created editing orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
149
diff
changeset
|
102 ortdetail = Ext.create('Lada.model.Ortdetail'); |
16ba7e2465fd
Implemented creating and editing new l_ort. Created editing orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
149
diff
changeset
|
103 ortdetailstore.add(ortdetail); |
16ba7e2465fd
Implemented creating and editing new l_ort. Created editing orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
149
diff
changeset
|
104 newortdetail = true; |
16ba7e2465fd
Implemented creating and editing new l_ort. Created editing orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
149
diff
changeset
|
105 } else { |
16ba7e2465fd
Implemented creating and editing new l_ort. Created editing orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
149
diff
changeset
|
106 console.log('Editing Ortdetail'); |
16ba7e2465fd
Implemented creating and editing new l_ort. Created editing orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
149
diff
changeset
|
107 ortdetail = ortdetailstore.getById(ortid); |
16ba7e2465fd
Implemented creating and editing new l_ort. Created editing orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
149
diff
changeset
|
108 } |
16ba7e2465fd
Implemented creating and editing new l_ort. Created editing orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
149
diff
changeset
|
109 |
16ba7e2465fd
Implemented creating and editing new l_ort. Created editing orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
149
diff
changeset
|
110 var fields = ['beschreibung', 'bezeichnung', 'hoeheLand', |
16ba7e2465fd
Implemented creating and editing new l_ort. Created editing orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
149
diff
changeset
|
111 'latitude', 'longitude', 'staatId', 'gemId']; |
16ba7e2465fd
Implemented creating and editing new l_ort. Created editing orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
149
diff
changeset
|
112 for (var i = fields.length - 1; i >= 0; i--){ |
16ba7e2465fd
Implemented creating and editing new l_ort. Created editing orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
149
diff
changeset
|
113 ffield = fform.findField("ort_"+fields[i]); |
16ba7e2465fd
Implemented creating and editing new l_ort. Created editing orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
149
diff
changeset
|
114 ortdetail.set(fields[i], ffield.getValue()); |
16ba7e2465fd
Implemented creating and editing new l_ort. Created editing orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
149
diff
changeset
|
115 } |
16ba7e2465fd
Implemented creating and editing new l_ort. Created editing orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
149
diff
changeset
|
116 // Create a new Ortedetail if nessecary |
16ba7e2465fd
Implemented creating and editing new l_ort. Created editing orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
149
diff
changeset
|
117 ortdetailstore.sync({ |
155
5414e611097e
Set ortId in l_ort if new ortdetail was created.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
154
diff
changeset
|
118 success: function(batch, options) { |
154
16ba7e2465fd
Implemented creating and editing new l_ort. Created editing orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
149
diff
changeset
|
119 if (newortdetail) { |
155
5414e611097e
Set ortId in l_ort if new ortdetail was created.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
154
diff
changeset
|
120 // Get ID from new created ortdetail and set it to the ort |
215
19d79b41f95d
Fixed issue22
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
155
diff
changeset
|
121 var response = options.operations.create[0].store.proxy.reader.jsonData; |
155
5414e611097e
Set ortId in l_ort if new ortdetail was created.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
154
diff
changeset
|
122 form.model.set('ortId', response.ortId); |
154
16ba7e2465fd
Implemented creating and editing new l_ort. Created editing orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
149
diff
changeset
|
123 } |
216
6aedf2026fb4
Fixed issue23
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
215
diff
changeset
|
124 ortidfield.setValue(ortid); |
154
16ba7e2465fd
Implemented creating and editing new l_ort. Created editing orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
149
diff
changeset
|
125 }, |
16ba7e2465fd
Implemented creating and editing new l_ort. Created editing orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
149
diff
changeset
|
126 failure: function() { |
16ba7e2465fd
Implemented creating and editing new l_ort. Created editing orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
149
diff
changeset
|
127 console.log('Error on saving Ortdetails'); |
16ba7e2465fd
Implemented creating and editing new l_ort. Created editing orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
149
diff
changeset
|
128 } |
16ba7e2465fd
Implemented creating and editing new l_ort. Created editing orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
149
diff
changeset
|
129 }); |
454
edb9dee114f8
Issue67: Always commit the form und not only if there has been changes to the
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
447
diff
changeset
|
130 form.commit(); |
154
16ba7e2465fd
Implemented creating and editing new l_ort. Created editing orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
149
diff
changeset
|
131 |
149
26ac4c99f8c4
Added Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
109
diff
changeset
|
132 }, |
292
73a2c114db64
Inherit from Base controller
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
217
diff
changeset
|
133 addItem: function(button) { |
149
26ac4c99f8c4
Added Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
109
diff
changeset
|
134 console.log('Adding new Ort for Probe ' + button.probeId); |
26ac4c99f8c4
Added Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
109
diff
changeset
|
135 var ort = Ext.create('Lada.model.Ort'); |
26ac4c99f8c4
Added Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
109
diff
changeset
|
136 ort.set('probeId', button.probeId); |
26ac4c99f8c4
Added Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
109
diff
changeset
|
137 var view = Ext.widget('ortecreate', {model: ort}); |
109
2308094f5a8c
Added forms to add Orte
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
138 }, |
292
73a2c114db64
Inherit from Base controller
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
217
diff
changeset
|
139 editItem: function(grid, record) { |
109
2308094f5a8c
Added forms to add Orte
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
140 console.log('Editing Ort'); |
362
6a7a9267e00f
Issue56: Changed way how to set the form and window to readonly. Now all dialogs should
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
292
diff
changeset
|
141 record.getAuthInfo(this.initEditWindow) |
6a7a9267e00f
Issue56: Changed way how to set the form and window to readonly. Now all dialogs should
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
292
diff
changeset
|
142 console.log("Loaded Ort with ID " + record.getId()); //outputs ID |
6a7a9267e00f
Issue56: Changed way how to set the form and window to readonly. Now all dialogs should
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
292
diff
changeset
|
143 }, |
6a7a9267e00f
Issue56: Changed way how to set the form and window to readonly. Now all dialogs should
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
292
diff
changeset
|
144 initEditWindow: function(record, readonly, owner) { |
447
12231f31c112
Apply new workflow in orte dialog.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
362
diff
changeset
|
145 var view = Ext.widget('ortecreate', {model: record, edit: true}); |
362
6a7a9267e00f
Issue56: Changed way how to set the form and window to readonly. Now all dialogs should
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
292
diff
changeset
|
146 var ignore = Array(); |
6a7a9267e00f
Issue56: Changed way how to set the form and window to readonly. Now all dialogs should
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
292
diff
changeset
|
147 if (readonly) { |
6a7a9267e00f
Issue56: Changed way how to set the form and window to readonly. Now all dialogs should
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
292
diff
changeset
|
148 var form = view.down('form'); |
6a7a9267e00f
Issue56: Changed way how to set the form and window to readonly. Now all dialogs should
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
292
diff
changeset
|
149 form.setReadOnly(true, ignore); |
6a7a9267e00f
Issue56: Changed way how to set the form and window to readonly. Now all dialogs should
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
292
diff
changeset
|
150 } |
109
2308094f5a8c
Added forms to add Orte
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
151 }, |
2308094f5a8c
Added forms to add Orte
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
152 createSuccess: function(form, record, operation) { |
2308094f5a8c
Added forms to add Orte
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
153 // Reload store |
2308094f5a8c
Added forms to add Orte
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
154 var store = this.getOrteStore(); |
2308094f5a8c
Added forms to add Orte
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
155 store.reload(); |
2308094f5a8c
Added forms to add Orte
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
156 var win = form.up('window'); |
2308094f5a8c
Added forms to add Orte
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
157 win.close(); |
2308094f5a8c
Added forms to add Orte
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
158 }, |
2308094f5a8c
Added forms to add Orte
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
159 editSuccess: function(form, record, operation) { |
2308094f5a8c
Added forms to add Orte
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
160 // Reload store |
2308094f5a8c
Added forms to add Orte
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
161 var store = this.getOrteStore(); |
2308094f5a8c
Added forms to add Orte
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
162 store.reload(); |
2308094f5a8c
Added forms to add Orte
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
163 var win = form.up('window'); |
2308094f5a8c
Added forms to add Orte
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
164 win.close(); |
2308094f5a8c
Added forms to add Orte
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
165 } |
2308094f5a8c
Added forms to add Orte
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
166 }); |