Mercurial > lada > lada-client
comparison app/view/window/MessprogrammOrt.js @ 1288:08085b7d1d0b
Ortszuordnung: Search, new orte, display and validity check
author | Maximilian Krambach <mkrambach@intevation.de> |
---|---|
date | Fri, 27 Jan 2017 13:25:14 +0100 |
parents | 0a47e8af9006 |
children | c1b7db04b39c |
comparison
equal
deleted
inserted
replaced
1287:e317ba349204 | 1288:08085b7d1d0b |
---|---|
7 */ | 7 */ |
8 | 8 |
9 /** | 9 /** |
10 * Window to add a Ort to a Messprogramm | 10 * Window to add a Ort to a Messprogramm |
11 */ | 11 */ |
12 // TODO: This is >80% identical to Lada.view.form.Ortszuordnung. | |
13 // Differences: This has no ortszuordnung record. It only receives and sends | |
14 // an ortId | |
15 | |
12 Ext.define('Lada.view.window.MessprogrammOrt', { | 16 Ext.define('Lada.view.window.MessprogrammOrt', { |
13 extend: 'Ext.window.Window', | 17 extend: 'Ext.window.Window', |
14 alias: 'widget.messprogrammort', | 18 alias: 'widget.messprogrammort', |
15 | 19 |
16 requires: [ | 20 requires: [ |
17 'Lada.model.Ort', | 21 'Lada.view.form.Ortserstellung', |
18 'Lada.view.panel.Map', | 22 'Lada.view.panel.Map', |
19 'Lada.view.widget.Location', | 23 'Lada.view.grid.Orte' |
20 'Lada.view.form.Location' | |
21 ], | 24 ], |
22 | 25 |
23 collapsible: true, | 26 collapsible: true, |
24 maximizable: true, | 27 maximizable: true, |
25 autoshow: true, | 28 autoshow: true, |
26 layout: 'border', | 29 layout: 'fit', |
27 constrain: true, | 30 constrain: true, |
28 | 31 |
29 parentWindow: null, | 32 parentWindow: null, |
30 record: null, | 33 |
34 ortId: null, | |
31 | 35 |
32 /** | 36 /** |
33 * This function initialises the Window | 37 * This function initialises the Window |
34 */ | 38 */ |
35 initComponent: function() { | 39 initComponent: function() { |
47 this.close(); | 51 this.close(); |
48 this.parentWindow.down('messprogrammform') | 52 this.parentWindow.down('messprogrammform') |
49 .ortWindow = null; | 53 .ortWindow = null; |
50 } | 54 } |
51 }]; | 55 }]; |
52 this.width = 900; | |
53 this.height = 515; | |
54 this.bodyStyle = {background: '#fff'}; | |
55 | 56 |
56 // add listeners to change the window appearence when it becomes inactive | 57 // add listeners to change the window appearence when it becomes inactive |
57 this.on({ | 58 this.on({ |
58 activate: function(){ | 59 activate: function(){ |
59 this.getEl().removeCls('window-inactive'); | 60 this.getEl().removeCls('window-inactive'); |
66 .ortWindow = null; | 67 .ortWindow = null; |
67 } | 68 } |
68 }); | 69 }); |
69 | 70 |
70 this.items = [{ | 71 this.items = [{ |
71 region: 'west', | 72 layout: 'border', |
73 bodyStyle: {background: '#fff'}, | |
72 border: 0, | 74 border: 0, |
73 layout: 'vbox', | |
74 items: [{ | |
75 xtype: 'fieldset', | |
76 title: i18n.getMsg('ortId'), | |
77 margin: 5, | |
78 items: [{ | |
79 border: 0, | |
80 margin: '0, 0, 10, 0', | |
81 items: [{ | |
82 xtype: 'location', | |
83 fieldLabel: i18n.getMsg('ortId'), | |
84 labelWidth: 80, | |
85 width: 280, | |
86 forceSelection: true, | |
87 name: 'ortId', | |
88 listeners: {//Update MapPanel etc... | |
89 select: this.updateDetails | |
90 } | |
91 }] | |
92 }] | |
93 }, { | |
94 xtype: 'locationform', | |
95 margin: 5, | |
96 recordId: this.record.get('ortId') | |
97 }] | |
98 }, { | |
99 xtype: 'fset', | |
100 bodyStyle: { | |
101 background: '#fff' | |
102 }, | |
103 layout: 'border', | |
104 name: 'mapfield', | |
105 title: 'Karte', | |
106 region: 'center', | |
107 padding: '5, 5', | |
108 margin: 5, | |
109 items: [{ | 75 items: [{ |
110 xtype: 'map', | 76 xtype: 'map', |
111 region: 'center', | 77 region: 'center', |
112 layout: 'border', | 78 layout: 'border', |
113 record: this.record.get('ortId') ? this.record : null, | 79 margin: '13, 5, 10, 5', |
114 bodyStyle: { | 80 minHeight: 380, |
115 background: '#fff' | 81 externalOrteStore: true |
116 }, | 82 }, { |
117 name: 'map', | 83 xtype: 'panel', |
118 listeners: { //A listener which listens to the mappanels featureselected event | 84 layout: 'hbox', |
119 featureselected: this.selectedFeature | 85 border: 0, |
120 } | 86 margin: '0, 0, 10, 0', |
87 dockedItems: [{ | |
88 xtype: 'toolbar', | |
89 dock: 'bottom', | |
90 border: '0, 1, 1, 1', | |
91 style: { | |
92 borderBottom: '1px solid #b5b8c8 !important', | |
93 borderLeft: '1px solid #b5b8c8 !important', | |
94 borderRight: '1px solid #b5b8c8 !important' | |
95 }, | |
96 items: [{ | |
97 text: i18n.getMsg('ortszuordnung.form.setOrt'), | |
98 tooltip: i18n.getMsg('ortszuordnung.form.setOrt.qtip'), | |
99 icon: 'resources/img/dialog-ok-apply.png', | |
100 action: 'setOrt', | |
101 enableToggle: true, | |
102 disabled: true | |
103 }, '->', { | |
104 text: i18n.getMsg('save'), | |
105 tooltip: i18n.getMsg('save.qtip'), | |
106 icon: 'resources/img/dialog-ok-apply.png', | |
107 action: 'save', | |
108 disabled: true | |
109 }, { | |
110 text: i18n.getMsg('discard'), | |
111 tooltip: i18n.getMsg('discard.qtip'), | |
112 icon: 'resources/img/dialog-cancel.png', | |
113 action: 'discard', | |
114 disabled: true | |
115 }] | |
116 }], | |
117 items: [Ext.create('Lada.view.form.OrtInfo')] | |
118 }, { | |
119 region: 'south', | |
120 border: 0, | |
121 layout: 'fit', | |
122 name: 'ortgrid', | |
123 hidden: true, | |
124 maxHeight: 240, | |
125 items: [{ | |
126 xtype: 'ortstammdatengrid' | |
127 }], | |
128 dockedItems: [{ | |
129 xtype: 'toolbar', | |
130 dock: 'bottom', | |
131 border: '0, 1, 1, 1', | |
132 style: { | |
133 borderBottom: '1px solid #b5b8c8 !important', | |
134 borderLeft: '1px solid #b5b8c8 !important', | |
135 borderRight: '1px solid #b5b8c8 !important' | |
136 }, | |
137 items: [{ | |
138 xtype: 'textfield', | |
139 name: 'search', | |
140 labelWidth: 50, | |
141 enableKeyEvents: true, | |
142 fieldLabel: i18n.getMsg('ortszuordnung.ortsuche'), | |
143 }, '->', { | |
144 text: i18n.getMsg('orte.new'), | |
145 action: 'createort' | |
146 }, { | |
147 text: i18n.getMsg('orte.frommap'), | |
148 action: 'frommap' | |
149 }, { | |
150 text: i18n.getMsg('orte.clone'), | |
151 action: 'clone' | |
152 }] | |
153 }] | |
121 }] | 154 }] |
122 }]; | 155 }]; |
123 this.callParent(arguments); | 156 this.callParent(arguments); |
124 }, | 157 //TODO: load the passed OrtId |
125 | 158 }, |
126 /** | 159 |
127 * Initialise the Data of this Window. | |
128 */ | |
129 initData: function() { | |
130 //Only do this if an OrtId exists... | |
131 var ortId = this.record.get('ortId'); | |
132 | |
133 if (ortId) { | |
134 Ext.ClassManager.get('Lada.model.Ort').load(ortId, { | |
135 failure: function(record, action) { | |
136 // TODO | |
137 }, | |
138 success: function(record, response) { | |
139 var me = this; | |
140 if (record.get('treeModified') < record.get('parentModified')) { | |
141 Ext.Msg.show({ | |
142 title: 'Messprogramm nicht aktuell!', | |
143 msg: 'Das zugehörige Messprogramm wurde verändert.\nMöchten Sie zu dem Messprogramm zurückkehren und neu laden?\nOhne das erneute Laden des Messprogrammes wird das Speichern des Ortes nicht möglich sein.', | |
144 buttons: Ext.Msg.OKCANCEL, | |
145 icon: Ext.Msg.WARNING, | |
146 closable: false, | |
147 fn: function(button) { | |
148 if (button === 'ok') { | |
149 me.close(); | |
150 me.parentWindow.initData(); | |
151 me.parentWindow.down('messprogrammform') | |
152 .ortWindow = null; | |
153 } | |
154 else { | |
155 me.record.set('treeModified', me.probe.get('treeModified')); | |
156 } | |
157 } | |
158 }); | |
159 } | |
160 this.record = record; | |
161 }, | |
162 scope: this | |
163 }); | |
164 } | |
165 }, | |
166 | |
167 /** | |
168 * @private | |
169 * Override to display and update the map view in the panel. | |
170 */ | |
171 afterRender: function(){ | |
172 this.superclass.afterRender.apply(this, arguments); | |
173 var map = this.down('map'); | |
174 if (this.record.get('ortId')) { | |
175 map.selectFeature(this.record.get('ortId')); | |
176 } | |
177 else { | |
178 map.map.zoomToMaxExtent(); | |
179 } | |
180 }, | |
181 | |
182 /** | |
183 * This function is used by the MapPanel, when a Feature was selected | |
184 */ | |
185 selectedFeature: function(context, args) { | 160 selectedFeature: function(context, args) { |
186 var feature = args[0]; | 161 var feature = args[0]; |
187 if (feature.attributes.id && | 162 if (feature.attributes.id && |
188 feature.attributes.id !== '') { | 163 feature.attributes.id !== '') { |
189 var record = Ext.data.StoreManager.get('orte').getById(feature.attributes.id); | 164 var record = Ext.data.StoreManager.get('orte').getById(feature.attributes.id); |