annotate app/controller/Ort.js @ 1364:b58868c47f02

reintroduced filtered display of Stammdaten panel
author Maximilian Krambach <mkrambach@intevation.de>
date Wed, 08 Feb 2017 12:53:24 +0100
parents 5c2d6812d85a
children 993e542796fd
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) {
1361
5c2d6812d85a Merge behaviour of Stammdaten panel and ortszuordnungs grid
Maximilian Krambach <mkrambach@intevation.de>
parents: 1329
diff changeset
58 Ext.create('Lada.view.window.Ortserstellung',{
5c2d6812d85a Merge behaviour of Stammdaten panel and ortszuordnungs grid
Maximilian Krambach <mkrambach@intevation.de>
parents: 1329
diff changeset
59 record: Ext.create('Lada.model.Ort', {ortTyp: 1}),
5c2d6812d85a Merge behaviour of Stammdaten panel and ortszuordnungs grid
Maximilian Krambach <mkrambach@intevation.de>
parents: 1329
diff changeset
60 parentWindow: button.up('ortpanel')
5c2d6812d85a Merge behaviour of Stammdaten panel and ortszuordnungs grid
Maximilian Krambach <mkrambach@intevation.de>
parents: 1329
diff changeset
61 }).show();
1130
e4952906634d Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1051
diff changeset
62 var grid = button.up('ortpanel').down('ortstammdatengrid');
1361
5c2d6812d85a Merge behaviour of Stammdaten panel and ortszuordnungs grid
Maximilian Krambach <mkrambach@intevation.de>
parents: 1329
diff changeset
63 // if (grid.getCollapsed()) {
5c2d6812d85a Merge behaviour of Stammdaten panel and ortszuordnungs grid
Maximilian Krambach <mkrambach@intevation.de>
parents: 1329
diff changeset
64 // grid.expand();
5c2d6812d85a Merge behaviour of Stammdaten panel and ortszuordnungs grid
Maximilian Krambach <mkrambach@intevation.de>
parents: 1329
diff changeset
65 // }
1049
1bd4c0709bd6 Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
66 },
1bd4c0709bd6 Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
67
1bd4c0709bd6 Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
68 deleteItem: function(button) {
1130
e4952906634d Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1051
diff changeset
69 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
70 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
71 var i18n = Lada.getApplication().bundle;
e4952906634d Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1051
diff changeset
72 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
73 i18n.getMsg('confirmation.question'),
e4952906634d Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1051
diff changeset
74 function(btn) {
e4952906634d Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1051
diff changeset
75 if (btn === 'yes') {
e4952906634d Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1051
diff changeset
76 selection.destroy({
e4952906634d Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1051
diff changeset
77 success: function() {
e4952906634d Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1051
diff changeset
78 //DO NOTHING
e4952906634d Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1051
diff changeset
79 },
e4952906634d Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1051
diff changeset
80 failure: function(request, response) {
e4952906634d Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1051
diff changeset
81 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
82 if (json) {
e4952906634d Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1051
diff changeset
83 if (json.message){
e4952906634d Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1051
diff changeset
84 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
85 +' #'+json.message,
e4952906634d Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1051
diff changeset
86 i18n.getMsg(json.message));
e4952906634d Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1051
diff changeset
87 } else {
e4952906634d Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1051
diff changeset
88 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
89 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
90 }
e4952906634d Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1051
diff changeset
91 } else {
e4952906634d Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1051
diff changeset
92 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
93 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
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 });
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 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
100 },
e4952906634d Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1051
diff changeset
101
1329
053bd0cd9744 check the correct grid to avoid editing.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1315
diff changeset
102 selectPanel: function(rowModel, record) {
053bd0cd9744 check the correct grid to avoid editing.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1315
diff changeset
103 this.checkEditPanel(rowModel, record);
1130
e4952906634d Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1051
diff changeset
104 this.buttonToggle(rowModel, record);
e4952906634d Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1051
diff changeset
105 },
e4952906634d Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1051
diff changeset
106
1329
053bd0cd9744 check the correct grid to avoid editing.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1315
diff changeset
107 selectWindow: function(rowModel, record) {
053bd0cd9744 check the correct grid to avoid editing.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1315
diff changeset
108 this.checkEditWindow(rowModel, record);
053bd0cd9744 check the correct grid to avoid editing.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1315
diff changeset
109 this.buttonToggle(rowModel, record);
053bd0cd9744 check the correct grid to avoid editing.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1315
diff changeset
110 },
053bd0cd9744 check the correct grid to avoid editing.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1315
diff changeset
111
053bd0cd9744 check the correct grid to avoid editing.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1315
diff changeset
112 checkEditWindow: function(rowModel, record) {
053bd0cd9744 check the correct grid to avoid editing.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1315
diff changeset
113 if (!Ext.Array.contains(Lada.netzbetreiber,
053bd0cd9744 check the correct grid to avoid editing.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1315
diff changeset
114 record.get('netzbetreiberId')) &&
053bd0cd9744 check the correct grid to avoid editing.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1315
diff changeset
115 record.get('netzbetreiberId') !== '') {
053bd0cd9744 check the correct grid to avoid editing.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1315
diff changeset
116 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
117 grid.rowEditing.cancelEdit();
053bd0cd9744 check the correct grid to avoid editing.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1315
diff changeset
118 return;
053bd0cd9744 check the correct grid to avoid editing.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1315
diff changeset
119 }
053bd0cd9744 check the correct grid to avoid editing.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1315
diff changeset
120 },
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 checkEditPanel: function(rowModel, record) {
1130
e4952906634d Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1051
diff changeset
123 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
124 record.get('netzbetreiberId')) &&
e4952906634d Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1051
diff changeset
125 record.get('netzbetreiberId') !== '') {
e4952906634d Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1051
diff changeset
126 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
127 grid.rowEditing.cancelEdit();
e4952906634d Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1051
diff changeset
128 return;
e4952906634d Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1051
diff changeset
129 }
1049
1bd4c0709bd6 Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
130 },
1bd4c0709bd6 Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
131
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 * 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
134 * the record.
1bd4c0709bd6 Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
135 * 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
136 * 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
137 */
1bd4c0709bd6 Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
138 gridSave: function(editor, context) {
1bd4c0709bd6 Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
139 var i18n = Lada.getApplication().bundle;
1bd4c0709bd6 Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
140 context.record.save({
1bd4c0709bd6 Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
141 success: function(record, response) {
1130
e4952906634d Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1051
diff changeset
142 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
143 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
144 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
145 },
1bd4c0709bd6 Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
146 failure: function(record, response) {
1bd4c0709bd6 Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
147 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
148 if (json) {
1bd4c0709bd6 Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
149 if (json.message){
1bd4c0709bd6 Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
150 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
151 +' #'+json.message,
1bd4c0709bd6 Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
152 i18n.getMsg(json.message));
1bd4c0709bd6 Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
153 } else {
1bd4c0709bd6 Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
154 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
155 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
156 }
1bd4c0709bd6 Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
157 }
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 * When the edit was canceled,
1bd4c0709bd6 Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
164 * 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
165 */
1bd4c0709bd6 Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
166 cancelEdit: function(editor, context) {
1bd4c0709bd6 Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
167 if (!context.record.get('id') ||
1bd4c0709bd6 Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
168 context.record.get('id') === '') {
1bd4c0709bd6 Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
169 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
170 }
1bd4c0709bd6 Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
171 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
172 },
1bd4c0709bd6 Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
173
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 * 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
176 **/
1130
e4952906634d Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1051
diff changeset
177 buttonToggle: function(rowModel, record) {
e4952906634d Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1051
diff changeset
178 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
179 return;
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 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
182 if (!record ||
e4952906634d Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1051
diff changeset
183 !Ext.Array.contains(Lada.netzbetreiber,
e4952906634d Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1051
diff changeset
184 record.get('netzbetreiberId'))) {
e4952906634d Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1051
diff changeset
185 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
186 return;
e4952906634d Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1051
diff changeset
187 }
e4952906634d Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1051
diff changeset
188 if (record.get('readonly') ||
e4952906634d Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1051
diff changeset
189 rowModel.selected.items.length === 0) {
e4952906634d Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1051
diff changeset
190 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
191 }
e4952906634d Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1051
diff changeset
192 else {
e4952906634d Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1051
diff changeset
193 if (grid.getPlugin('rowedit').editing) {
e4952906634d Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1051
diff changeset
194 //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
195 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
196 }
e4952906634d Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1051
diff changeset
197 else {
e4952906634d Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1051
diff changeset
198 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
199 }
e4952906634d Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1051
diff changeset
200 }
e4952906634d Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1051
diff changeset
201 /*
1050
e0b5e64928c9 Use rowediting plugin for orte grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1049
diff changeset
202 if (!enabled &&
e0b5e64928c9 Use rowediting plugin for orte grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1049
diff changeset
203 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
204 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
205 }
1bd4c0709bd6 Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
206 else {
1050
e0b5e64928c9 Use rowediting plugin for orte grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1049
diff changeset
207 if (panel.down('ortstammdatengrid').getPlugin('rowedit') &&
e0b5e64928c9 Use rowediting plugin for orte grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1049
diff changeset
208 !panel.down('ortstammdatengrid').getPlugin('rowedit').editing &&
e0b5e64928c9 Use rowediting plugin for orte grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1049
diff changeset
209 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
210 //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
211 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
212 }
1bd4c0709bd6 Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
213 //else turn them off again!
1051
981339d774b8 merged stammdatengrids to default.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1050
diff changeset
214 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
215 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
216 }
1bd4c0709bd6 Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
217 }
1130
e4952906634d Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1051
diff changeset
218 */
1049
1bd4c0709bd6 Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
219 }
1bd4c0709bd6 Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
220 });

http://lada.wald.intevation.org