Mercurial > lada > lada-client
annotate app/controller/Ort.js @ 1140:450368f67858
Set requiered fields for stammdaten.ort grid.
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Thu, 26 May 2016 14:05:36 +0200 |
parents | c213c3dc51d2 |
children | 7ac4d811cf89 |
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, |
1130
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
26 select: me.select |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
27 }, |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
28 'ortpanel map': { |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
29 featureadded: me.featureadded |
1049
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
30 } |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
31 }); |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
32 }, |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
33 |
1130
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
34 featureadded: function(record) { |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
35 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
|
36 if (grid.getCollapsed()) { |
c213c3dc51d2
Expand ort grid on add ort button clicked.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1130
diff
changeset
|
37 grid.expand(); |
c213c3dc51d2
Expand ort grid on add ort button clicked.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1130
diff
changeset
|
38 } |
1130
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
39 if (!record.get('letzteAenderung')) { |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
40 record.data.letzteAenderung = new Date(); |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
41 } |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
42 grid.store.insert(0, record); |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
43 grid.rowEditing.startEdit(0, 1); |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
44 }, |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
45 |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
46 activateDraw: function(button) { |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
47 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
|
48 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
|
49 map.activateDraw(record); |
1049
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
50 }, |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
51 |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
52 addRecord: function(button) { |
1130
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 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
|
55 if (grid.getCollapsed()) { |
c213c3dc51d2
Expand ort grid on add ort button clicked.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1130
diff
changeset
|
56 grid.expand(); |
c213c3dc51d2
Expand ort grid on add ort button clicked.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1130
diff
changeset
|
57 } |
1130
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
58 if (!record.get('letzteAenderung')) { |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
59 record.data.letzteAenderung = new Date(); |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
60 } |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
61 grid.store.insert(0, record); |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
62 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
|
63 }, |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
64 |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
65 deleteItem: function(button) { |
1130
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
66 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
|
67 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
|
68 var i18n = Lada.getApplication().bundle; |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
69 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
|
70 i18n.getMsg('confirmation.question'), |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
71 function(btn) { |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
72 if (btn === 'yes') { |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
73 selection.destroy({ |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
74 success: function() { |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
75 //DO NOTHING |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
76 }, |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
77 failure: function(request, response) { |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
78 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
|
79 if (json) { |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
80 if (json.message){ |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
81 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
|
82 +' #'+json.message, |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
83 i18n.getMsg(json.message)); |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
84 } else { |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
85 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
|
86 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
|
87 } |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
88 } else { |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
89 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
|
90 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
|
91 } |
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 }); |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
94 } |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
95 }); |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
96 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
|
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 select: function(rowModel, record) { |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
100 this.checkEdit(rowModel, record); |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
101 this.buttonToggle(rowModel, record); |
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 |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
104 checkEdit: function(rowModel, record) { |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
105 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
|
106 record.get('netzbetreiberId')) && |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
107 record.get('netzbetreiberId') !== '') { |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
108 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
|
109 grid.rowEditing.cancelEdit(); |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
110 return; |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
111 } |
1049
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
112 }, |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
113 |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
114 /** |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
115 * 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
|
116 * the record. |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
117 * 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
|
118 * 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
|
119 */ |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
120 gridSave: function(editor, context) { |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
121 var i18n = Lada.getApplication().bundle; |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
122 context.record.save({ |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
123 success: function(record, response) { |
1130
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
124 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
|
125 grid.store.reload(); |
1049
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
126 }, |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
127 failure: function(record, response) { |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
128 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
|
129 if (json) { |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
130 if (json.message){ |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
131 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
|
132 +' #'+json.message, |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
133 i18n.getMsg(json.message)); |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
134 } else { |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
135 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
|
136 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
|
137 } |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
138 } |
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 }); |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
141 }, |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
142 |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
143 /** |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
144 * When the edit was canceled, |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
145 * 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
|
146 */ |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
147 cancelEdit: function(editor, context) { |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
148 if (!context.record.get('id') || |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
149 context.record.get('id') === '') { |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
150 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
|
151 } |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
152 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
|
153 }, |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
154 |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
155 /** |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
156 * 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
|
157 **/ |
1130
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
158 buttonToggle: function(rowModel, record) { |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
159 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
|
160 return; |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
161 } |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
162 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
|
163 if (!record || |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
164 !Ext.Array.contains(Lada.netzbetreiber, |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
165 record.get('netzbetreiberId'))) { |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
166 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
|
167 return; |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
168 } |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
169 if (record.get('readonly') || |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
170 rowModel.selected.items.length === 0) { |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
171 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
|
172 } |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
173 else { |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
174 if (grid.getPlugin('rowedit').editing) { |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
175 //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
|
176 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
|
177 } |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
178 else { |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
179 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
|
180 } |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
181 } |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
182 /* |
1050
e0b5e64928c9
Use rowediting plugin for orte grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1049
diff
changeset
|
183 if (!enabled && |
e0b5e64928c9
Use rowediting plugin for orte grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1049
diff
changeset
|
184 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
|
185 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
|
186 } |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
187 else { |
1050
e0b5e64928c9
Use rowediting plugin for orte grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1049
diff
changeset
|
188 if (panel.down('ortstammdatengrid').getPlugin('rowedit') && |
e0b5e64928c9
Use rowediting plugin for orte grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1049
diff
changeset
|
189 !panel.down('ortstammdatengrid').getPlugin('rowedit').editing && |
e0b5e64928c9
Use rowediting plugin for orte grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1049
diff
changeset
|
190 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
|
191 //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
|
192 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
|
193 } |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
194 //else turn them off again! |
1051
981339d774b8
merged stammdatengrids to default.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1050
diff
changeset
|
195 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
|
196 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
|
197 } |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
198 } |
1130
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
199 */ |
1049
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
200 } |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
201 }); |