Mercurial > lada > lada-client
annotate app/controller/Ort.js @ 1434:ff5a402cd63d tip
set version to 2.7-SNAPSHOT for default branch
author | Marco Lechner, Bundesamt fuer Strahlenschutz, SW 2.1 <mlechner@bfs.de> |
---|---|
date | Fri, 07 Apr 2017 11:32:26 +0200 |
parents | 94d35d5a7913 |
children |
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 |
1049
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 }); |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
34 }, |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
35 |
1130
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
36 activateDraw: function(button) { |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
37 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
|
38 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
|
39 map.activateDraw(record); |
1049
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
40 }, |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
41 |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
42 addRecord: function(button) { |
1361
5c2d6812d85a
Merge behaviour of Stammdaten panel and ortszuordnungs grid
Maximilian Krambach <mkrambach@intevation.de>
parents:
1329
diff
changeset
|
43 Ext.create('Lada.view.window.Ortserstellung',{ |
5c2d6812d85a
Merge behaviour of Stammdaten panel and ortszuordnungs grid
Maximilian Krambach <mkrambach@intevation.de>
parents:
1329
diff
changeset
|
44 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
|
45 parentWindow: button.up('ortpanel') |
5c2d6812d85a
Merge behaviour of Stammdaten panel and ortszuordnungs grid
Maximilian Krambach <mkrambach@intevation.de>
parents:
1329
diff
changeset
|
46 }).show(); |
1130
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
47 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
|
48 // if (grid.getCollapsed()) { |
5c2d6812d85a
Merge behaviour of Stammdaten panel and ortszuordnungs grid
Maximilian Krambach <mkrambach@intevation.de>
parents:
1329
diff
changeset
|
49 // grid.expand(); |
5c2d6812d85a
Merge behaviour of Stammdaten panel and ortszuordnungs grid
Maximilian Krambach <mkrambach@intevation.de>
parents:
1329
diff
changeset
|
50 // } |
1049
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 |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
53 deleteItem: function(button) { |
1130
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'); |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
55 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
|
56 var i18n = Lada.getApplication().bundle; |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
57 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
|
58 i18n.getMsg('confirmation.question'), |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
59 function(btn) { |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
60 if (btn === 'yes') { |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
61 selection.destroy({ |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
62 success: function() { |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
63 //DO NOTHING |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
64 }, |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
65 failure: function(request, response) { |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
66 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
|
67 if (json) { |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
68 if (json.message){ |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
69 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
|
70 +' #'+json.message, |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
71 i18n.getMsg(json.message)); |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
72 } else { |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
73 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
|
74 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
|
75 } |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
76 } else { |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
77 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
|
78 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
|
79 } |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
80 } |
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 } |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
83 }); |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
84 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
|
85 }, |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
86 |
1329
053bd0cd9744
check the correct grid to avoid editing.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1315
diff
changeset
|
87 selectPanel: function(rowModel, record) { |
053bd0cd9744
check the correct grid to avoid editing.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1315
diff
changeset
|
88 this.checkEditPanel(rowModel, record); |
1130
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
89 this.buttonToggle(rowModel, record); |
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 |
1329
053bd0cd9744
check the correct grid to avoid editing.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1315
diff
changeset
|
92 selectWindow: function(rowModel, record) { |
053bd0cd9744
check the correct grid to avoid editing.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1315
diff
changeset
|
93 this.checkEditWindow(rowModel, record); |
053bd0cd9744
check the correct grid to avoid editing.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1315
diff
changeset
|
94 this.buttonToggle(rowModel, record); |
053bd0cd9744
check the correct grid to avoid editing.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1315
diff
changeset
|
95 }, |
053bd0cd9744
check the correct grid to avoid editing.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1315
diff
changeset
|
96 |
053bd0cd9744
check the correct grid to avoid editing.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1315
diff
changeset
|
97 checkEditWindow: function(rowModel, record) { |
053bd0cd9744
check the correct grid to avoid editing.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1315
diff
changeset
|
98 if (!Ext.Array.contains(Lada.netzbetreiber, |
053bd0cd9744
check the correct grid to avoid editing.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1315
diff
changeset
|
99 record.get('netzbetreiberId')) && |
053bd0cd9744
check the correct grid to avoid editing.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1315
diff
changeset
|
100 record.get('netzbetreiberId') !== '') { |
053bd0cd9744
check the correct grid to avoid editing.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1315
diff
changeset
|
101 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
|
102 grid.rowEditing.cancelEdit(); |
053bd0cd9744
check the correct grid to avoid editing.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1315
diff
changeset
|
103 return; |
053bd0cd9744
check the correct grid to avoid editing.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1315
diff
changeset
|
104 } |
053bd0cd9744
check the correct grid to avoid editing.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1315
diff
changeset
|
105 }, |
053bd0cd9744
check the correct grid to avoid editing.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1315
diff
changeset
|
106 |
053bd0cd9744
check the correct grid to avoid editing.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1315
diff
changeset
|
107 checkEditPanel: function(rowModel, record) { |
1130
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
108 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
|
109 record.get('netzbetreiberId')) && |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
110 record.get('netzbetreiberId') !== '') { |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
111 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
|
112 grid.rowEditing.cancelEdit(); |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
113 return; |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
114 } |
1049
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
115 }, |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
116 |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
117 /** |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
118 * 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
|
119 * the record. |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
120 * 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
|
121 * 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
|
122 */ |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
123 gridSave: function(editor, context) { |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
124 var i18n = Lada.getApplication().bundle; |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
125 context.record.save({ |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
126 success: function(record, response) { |
1373
94d35d5a7913
update other panels if ortegrid changes
Maximilian Krambach <mkrambach@intevation.de>
parents:
1369
diff
changeset
|
127 Ext.StoreManager.get('orte').load(); |
1130
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('ortstammdatengrid')[0]; |
1373
94d35d5a7913
update other panels if ortegrid changes
Maximilian Krambach <mkrambach@intevation.de>
parents:
1369
diff
changeset
|
129 grid.store.load({ |
94d35d5a7913
update other panels if ortegrid changes
Maximilian Krambach <mkrambach@intevation.de>
parents:
1369
diff
changeset
|
130 callback: function() { |
94d35d5a7913
update other panels if ortegrid changes
Maximilian Krambach <mkrambach@intevation.de>
parents:
1369
diff
changeset
|
131 var map = Ext.ComponentQuery.query('map')[0]; |
94d35d5a7913
update other panels if ortegrid changes
Maximilian Krambach <mkrambach@intevation.de>
parents:
1369
diff
changeset
|
132 map.addLocations(grid.store); |
94d35d5a7913
update other panels if ortegrid changes
Maximilian Krambach <mkrambach@intevation.de>
parents:
1369
diff
changeset
|
133 var parentPanel = grid.up('panel').ownerCt; |
94d35d5a7913
update other panels if ortegrid changes
Maximilian Krambach <mkrambach@intevation.de>
parents:
1369
diff
changeset
|
134 if (parentPanel){ |
94d35d5a7913
update other panels if ortegrid changes
Maximilian Krambach <mkrambach@intevation.de>
parents:
1369
diff
changeset
|
135 if (parentPanel.ortstore) { |
94d35d5a7913
update other panels if ortegrid changes
Maximilian Krambach <mkrambach@intevation.de>
parents:
1369
diff
changeset
|
136 parentPanel.ortstore.load(); |
94d35d5a7913
update other panels if ortegrid changes
Maximilian Krambach <mkrambach@intevation.de>
parents:
1369
diff
changeset
|
137 } |
94d35d5a7913
update other panels if ortegrid changes
Maximilian Krambach <mkrambach@intevation.de>
parents:
1369
diff
changeset
|
138 var ozf = parentPanel.down('ortszuordnungform'); |
94d35d5a7913
update other panels if ortegrid changes
Maximilian Krambach <mkrambach@intevation.de>
parents:
1369
diff
changeset
|
139 if (ozf){ |
94d35d5a7913
update other panels if ortegrid changes
Maximilian Krambach <mkrambach@intevation.de>
parents:
1369
diff
changeset
|
140 ozf.setOrt(null, record); |
94d35d5a7913
update other panels if ortegrid changes
Maximilian Krambach <mkrambach@intevation.de>
parents:
1369
diff
changeset
|
141 } |
94d35d5a7913
update other panels if ortegrid changes
Maximilian Krambach <mkrambach@intevation.de>
parents:
1369
diff
changeset
|
142 } |
94d35d5a7913
update other panels if ortegrid changes
Maximilian Krambach <mkrambach@intevation.de>
parents:
1369
diff
changeset
|
143 } |
94d35d5a7913
update other panels if ortegrid changes
Maximilian Krambach <mkrambach@intevation.de>
parents:
1369
diff
changeset
|
144 }); |
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) { |
1373
94d35d5a7913
update other panels if ortegrid changes
Maximilian Krambach <mkrambach@intevation.de>
parents:
1369
diff
changeset
|
147 var json = response.request.scope.reader.jsonData; |
94d35d5a7913
update other panels if ortegrid changes
Maximilian Krambach <mkrambach@intevation.de>
parents:
1369
diff
changeset
|
148 if (json) { |
94d35d5a7913
update other panels if ortegrid changes
Maximilian Krambach <mkrambach@intevation.de>
parents:
1369
diff
changeset
|
149 if (json.message){ |
94d35d5a7913
update other panels if ortegrid changes
Maximilian Krambach <mkrambach@intevation.de>
parents:
1369
diff
changeset
|
150 Ext.Msg.alert(i18n.getMsg('err.msg.save.title') |
94d35d5a7913
update other panels if ortegrid changes
Maximilian Krambach <mkrambach@intevation.de>
parents:
1369
diff
changeset
|
151 +' #'+json.message, |
94d35d5a7913
update other panels if ortegrid changes
Maximilian Krambach <mkrambach@intevation.de>
parents:
1369
diff
changeset
|
152 i18n.getMsg(json.message)); |
94d35d5a7913
update other panels if ortegrid changes
Maximilian Krambach <mkrambach@intevation.de>
parents:
1369
diff
changeset
|
153 } else { |
94d35d5a7913
update other panels if ortegrid changes
Maximilian Krambach <mkrambach@intevation.de>
parents:
1369
diff
changeset
|
154 Ext.Msg.alert(i18n.getMsg('err.msg.save.title'), |
94d35d5a7913
update other panels if ortegrid changes
Maximilian Krambach <mkrambach@intevation.de>
parents:
1369
diff
changeset
|
155 i18n.getMsg('err.msg.generic.body')); |
94d35d5a7913
update other panels if ortegrid changes
Maximilian Krambach <mkrambach@intevation.de>
parents:
1369
diff
changeset
|
156 } |
94d35d5a7913
update other panels if ortegrid changes
Maximilian Krambach <mkrambach@intevation.de>
parents:
1369
diff
changeset
|
157 } |
1049
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]; |
1366
993e542796fd
Fixed type error in ortszuordnung when user has 'funktion = 4'
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1361
diff
changeset
|
182 if (!grid.up('ortpanel')) { |
993e542796fd
Fixed type error in ortszuordnung when user has 'funktion = 4'
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1361
diff
changeset
|
183 return; |
993e542796fd
Fixed type error in ortszuordnung when user has 'funktion = 4'
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1361
diff
changeset
|
184 } |
1130
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
185 if (!record || |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
186 !Ext.Array.contains(Lada.netzbetreiber, |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
187 record.get('netzbetreiberId'))) { |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
188 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
|
189 return; |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
190 } |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
191 if (record.get('readonly') || |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
192 rowModel.selected.items.length === 0) { |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
193 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
|
194 } |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
195 else { |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
196 if (grid.getPlugin('rowedit').editing) { |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
197 //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
|
198 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
|
199 } |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
200 else { |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
201 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
|
202 } |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
203 } |
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
204 /* |
1050
e0b5e64928c9
Use rowediting plugin for orte grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1049
diff
changeset
|
205 if (!enabled && |
e0b5e64928c9
Use rowediting plugin for orte grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1049
diff
changeset
|
206 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
|
207 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
|
208 } |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
209 else { |
1050
e0b5e64928c9
Use rowediting plugin for orte grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1049
diff
changeset
|
210 if (panel.down('ortstammdatengrid').getPlugin('rowedit') && |
e0b5e64928c9
Use rowediting plugin for orte grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1049
diff
changeset
|
211 !panel.down('ortstammdatengrid').getPlugin('rowedit').editing && |
e0b5e64928c9
Use rowediting plugin for orte grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1049
diff
changeset
|
212 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
|
213 //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
|
214 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
|
215 } |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
216 //else turn them off again! |
1051
981339d774b8
merged stammdatengrids to default.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1050
diff
changeset
|
217 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
|
218 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
|
219 } |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
220 } |
1130
e4952906634d
Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1051
diff
changeset
|
221 */ |
1049
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
222 } |
1bd4c0709bd6
Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
223 }); |