Mercurial > lada > lada-client
annotate app/controller/Ort.js @ 1354:02252ce0cf1e
Ortserstellung validator: fix reference to form
author | Maximilian Krambach <mkrambach@intevation.de> |
---|---|
date | Tue, 07 Feb 2017 16:44:07 +0100 |
parents | 053bd0cd9744 |
children | 5c2d6812d85a |
rev | line source |
---|---|
1049
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
1 /** |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
2 * |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
3 */ |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
4 Ext.define('Lada.controller.Ort', { |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
5 extend: 'Ext.app.Controller', |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
6 |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
7 /** |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
8 * @private |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
9 * Initialize the controller. |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
10 */ |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
11 init: function() { |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
12 var me = this; |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
13 this.control({ |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
14 'ortpanel button[action=addMap]': { |
1130
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
15 click: me.activateDraw |
1049
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
16 }, |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
17 'ortpanel button[action=add]': { |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
18 click: me.addRecord |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
19 }, |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
20 'ortpanel button[action=delete]': { |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
21 click: me.deleteItem |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
22 }, |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
23 'ortpanel ortstammdatengrid': { |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
24 edit: me.gridSave, |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
25 canceledit: me.cancelEdit, |
1329
053bd0cd9744
check the correct grid to avoid editing.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1315
diff
changeset
|
26 select: me.selectPanel |
1130
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
27 }, |
1315
d312e514875c
enabled saving of grid editing in ortszuordnungswindow
Maximilian Krambach <mkrambach@intevation.de>
parents:
1145
diff
changeset
|
28 'ortszuordnungwindow ortstammdatengrid': { |
d312e514875c
enabled saving of grid editing in ortszuordnungswindow
Maximilian Krambach <mkrambach@intevation.de>
parents:
1145
diff
changeset
|
29 edit: me.gridSave, |
d312e514875c
enabled saving of grid editing in ortszuordnungswindow
Maximilian Krambach <mkrambach@intevation.de>
parents:
1145
diff
changeset
|
30 canceledit: me.cancelEdit, |
1329
053bd0cd9744
check the correct grid to avoid editing.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1315
diff
changeset
|
31 select: me.selectWindow |
1315
d312e514875c
enabled saving of grid editing in ortszuordnungswindow
Maximilian Krambach <mkrambach@intevation.de>
parents:
1145
diff
changeset
|
32 }, |
1130
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
33 'ortpanel map': { |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
34 featureadded: me.featureadded |
1049
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
35 } |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
36 }); |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
37 }, |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
38 |
1130
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
39 featureadded: function(record) { |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
40 var grid = Ext.ComponentQuery.query('ortpanel ortstammdatengrid')[0]; |
1132
c213c3dc51d2
Expand ort grid on add ort button clicked.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1130
diff
changeset
|
41 if (grid.getCollapsed()) { |
c213c3dc51d2
Expand ort grid on add ort button clicked.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1130
diff
changeset
|
42 grid.expand(); |
c213c3dc51d2
Expand ort grid on add ort button clicked.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1130
diff
changeset
|
43 } |
1130
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
44 if (!record.get('letzteAenderung')) { |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
45 record.data.letzteAenderung = new Date(); |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
46 } |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
47 grid.store.insert(0, record); |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
48 grid.rowEditing.startEdit(0, 1); |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
49 }, |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
50 |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
51 activateDraw: function(button) { |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
52 var map = button.up('ortpanel').down('map'); |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
53 var record = Ext.create('Lada.model.Ort'); |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
54 map.activateDraw(record); |
1049
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
55 }, |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
56 |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
57 addRecord: function(button) { |
1130
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
58 var record = Ext.create('Lada.model.Ort'); |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
59 var grid = button.up('ortpanel').down('ortstammdatengrid'); |
1132
c213c3dc51d2
Expand ort grid on add ort button clicked.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1130
diff
changeset
|
60 if (grid.getCollapsed()) { |
c213c3dc51d2
Expand ort grid on add ort button clicked.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1130
diff
changeset
|
61 grid.expand(); |
c213c3dc51d2
Expand ort grid on add ort button clicked.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1130
diff
changeset
|
62 } |
1130
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
63 if (!record.get('letzteAenderung')) { |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
64 record.data.letzteAenderung = new Date(); |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
65 } |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
66 grid.store.insert(0, record); |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
67 grid.rowEditing.startEdit(0, 1); |
1049
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
68 }, |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
69 |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
70 deleteItem: function(button) { |
1130
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
71 var grid = button.up('ortpanel').down('ortstammdatengrid'); |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
72 var selection = grid.getView().getSelectionModel().getSelection()[0]; |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
73 var i18n = Lada.getApplication().bundle; |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
74 Ext.MessageBox.confirm(i18n.getMsg('delete'), |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
75 i18n.getMsg('confirmation.question'), |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
76 function(btn) { |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
77 if (btn === 'yes') { |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
78 selection.destroy({ |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
79 success: function() { |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
80 //DO NOTHING |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
81 }, |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
82 failure: function(request, response) { |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
83 var json = response.request.scope.reader.jsonData; |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
84 if (json) { |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
85 if (json.message){ |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
86 Ext.Msg.alert(i18n.getMsg('err.msg.delete.title') |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
87 +' #'+json.message, |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
88 i18n.getMsg(json.message)); |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
89 } else { |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
90 Ext.Msg.alert(i18n.getMsg('err.msg.delete.title'), |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
91 i18n.getMsg('err.msg.generic.body')); |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
92 } |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
93 } else { |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
94 Ext.Msg.alert(i18n.getMsg('err.msg.delete.title'), |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
95 i18n.getMsg('err.msg.response.body')); |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
96 } |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
97 } |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
98 }); |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
99 } |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
100 }); |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
101 grid.up('ortpanel').down('button[action=delete]').disable(); |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
102 }, |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
103 |
1329
053bd0cd9744
check the correct grid to avoid editing.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1315
diff
changeset
|
104 selectPanel: function(rowModel, record) { |
053bd0cd9744
check the correct grid to avoid editing.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1315
diff
changeset
|
105 this.checkEditPanel(rowModel, record); |
1130
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
106 this.buttonToggle(rowModel, record); |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
107 }, |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
108 |
1329
053bd0cd9744
check the correct grid to avoid editing.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1315
diff
changeset
|
109 selectWindow: function(rowModel, record) { |
053bd0cd9744
check the correct grid to avoid editing.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1315
diff
changeset
|
110 this.checkEditWindow(rowModel, record); |
053bd0cd9744
check the correct grid to avoid editing.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1315
diff
changeset
|
111 this.buttonToggle(rowModel, record); |
053bd0cd9744
check the correct grid to avoid editing.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1315
diff
changeset
|
112 }, |
053bd0cd9744
check the correct grid to avoid editing.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1315
diff
changeset
|
113 |
053bd0cd9744
check the correct grid to avoid editing.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1315
diff
changeset
|
114 checkEditWindow: function(rowModel, record) { |
053bd0cd9744
check the correct grid to avoid editing.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1315
diff
changeset
|
115 if (!Ext.Array.contains(Lada.netzbetreiber, |
053bd0cd9744
check the correct grid to avoid editing.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1315
diff
changeset
|
116 record.get('netzbetreiberId')) && |
053bd0cd9744
check the correct grid to avoid editing.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1315
diff
changeset
|
117 record.get('netzbetreiberId') !== '') { |
053bd0cd9744
check the correct grid to avoid editing.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1315
diff
changeset
|
118 var grid = Ext.ComponentQuery.query('ortszuordnungwindow ortstammdatengrid')[0]; |
053bd0cd9744
check the correct grid to avoid editing.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1315
diff
changeset
|
119 grid.rowEditing.cancelEdit(); |
053bd0cd9744
check the correct grid to avoid editing.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1315
diff
changeset
|
120 return; |
053bd0cd9744
check the correct grid to avoid editing.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1315
diff
changeset
|
121 } |
053bd0cd9744
check the correct grid to avoid editing.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1315
diff
changeset
|
122 }, |
053bd0cd9744
check the correct grid to avoid editing.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1315
diff
changeset
|
123 |
053bd0cd9744
check the correct grid to avoid editing.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1315
diff
changeset
|
124 checkEditPanel: function(rowModel, record) { |
1130
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
125 if (!Ext.Array.contains(Lada.netzbetreiber, |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
126 record.get('netzbetreiberId')) && |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
127 record.get('netzbetreiberId') !== '') { |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
128 var grid = Ext.ComponentQuery.query('ortpanel ortstammdatengrid')[0]; |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
129 grid.rowEditing.cancelEdit(); |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
130 return; |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
131 } |
1049
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
132 }, |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
133 |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
134 /** |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
135 * This function is called when the grids roweditor saves |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
136 * the record. |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
137 * On success it refreshes the windows which contains the grid |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
138 * On failure it displays a message |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
139 */ |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
140 gridSave: function(editor, context) { |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
141 var i18n = Lada.getApplication().bundle; |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
142 context.record.save({ |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
143 success: function(record, response) { |
1130
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
144 var grid = Ext.ComponentQuery.query('ortstammdatengrid')[0]; |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
145 grid.store.reload(); |
1145
7ac4d811cf89
Reload stammdaten orte store to have all orte objects available.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1132
diff
changeset
|
146 Ext.StoreManager.get('orte').load(); |
1049
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
147 }, |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
148 failure: function(record, response) { |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
149 var json = response.request.scope.reader.jsonData; |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
150 if (json) { |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
151 if (json.message){ |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
152 Ext.Msg.alert(i18n.getMsg('err.msg.save.title') |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
153 +' #'+json.message, |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
154 i18n.getMsg(json.message)); |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
155 } else { |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
156 Ext.Msg.alert(i18n.getMsg('err.msg.save.title'), |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
157 i18n.getMsg('err.msg.generic.body')); |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
158 } |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
159 } |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
160 } |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
161 }); |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
162 }, |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
163 |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
164 /** |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
165 * When the edit was canceled, |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
166 * the empty row might have been created by the roweditor is removed |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
167 */ |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
168 cancelEdit: function(editor, context) { |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
169 if (!context.record.get('id') || |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
170 context.record.get('id') === '') { |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
171 editor.getCmp().store.remove(context.record); |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
172 } |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
173 context.grid.getSelectionModel().deselect(context.record); |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
174 }, |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
175 |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
176 /** |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
177 * Enables/Disables a set of buttons |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
178 **/ |
1130
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
179 buttonToggle: function(rowModel, record) { |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
180 if (!Ext.Array.contains(Lada.funktionen, 4)) { |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
181 return; |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
182 } |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
183 var grid = Ext.ComponentQuery.query('ortstammdatengrid')[0]; |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
184 if (!record || |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
185 !Ext.Array.contains(Lada.netzbetreiber, |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
186 record.get('netzbetreiberId'))) { |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
187 grid.up('ortpanel').down('button[action=delete]').disable(); |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
188 return; |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
189 } |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
190 if (record.get('readonly') || |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
191 rowModel.selected.items.length === 0) { |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
192 grid.up('ortpanel').down('button[action=delete]').disable(); |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
193 } |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
194 else { |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
195 if (grid.getPlugin('rowedit').editing) { |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
196 //only enable buttons, when grid is not beeing edited |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
197 grid.up('ortpanel').down('button[action=delete]').disable(); |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
198 } |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
199 else { |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
200 grid.up('ortpanel').down('button[action=delete]').enable(); |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
201 } |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
202 } |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
203 /* |
1050
e0b5e64928c9
Use rowediting plugin for orte grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1049
diff
changeset
|
204 if (!enabled && |
e0b5e64928c9
Use rowediting plugin for orte grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1049
diff
changeset
|
205 panel.down('button[action=delete]')) { |
1049
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
206 panel.down('button[action=delete]').disable(); |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
207 } |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
208 else { |
1050
e0b5e64928c9
Use rowediting plugin for orte grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1049
diff
changeset
|
209 if (panel.down('ortstammdatengrid').getPlugin('rowedit') && |
e0b5e64928c9
Use rowediting plugin for orte grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1049
diff
changeset
|
210 !panel.down('ortstammdatengrid').getPlugin('rowedit').editing && |
e0b5e64928c9
Use rowediting plugin for orte grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1049
diff
changeset
|
211 panel.down('button[action=delete]')) { |
1049
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
212 //only enable buttons, when grid is not beeing edited |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
213 panel.down('button[action=delete]').enable(); |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
214 } |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
215 //else turn them off again! |
1051
981339d774b8
merged stammdatengrids to default.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1050
diff
changeset
|
216 else if (panel.down('button[action=delete]')) { |
1050
e0b5e64928c9
Use rowediting plugin for orte grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1049
diff
changeset
|
217 panel.down('button[action=delete]').disable(); |
1049
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
218 } |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
219 } |
1130
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
220 */ |
1049
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
221 } |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
222 }); |