[Lada-commits] [PATCH] Ortszuordnung window: create, change and display (wip)
Wald Commits
scm-commit at wald.intevation.org
Wed Jan 18 11:42:18 CET 2017
# HG changeset patch
# User Maximilian Krambach <mkrambach at intevation.de>
# Date 1484736110 -3600
# Node ID 291df00378354af52f1fe786392edc5fee4a1415
# Parent cb9609380056d84aaabae95e2ac740a8090d2025
Ortszuordnung window: create, change and display (wip)
diff -r cb9609380056 -r 291df0037835 app/controller/grid/Ortszuordnung.js
--- a/app/controller/grid/Ortszuordnung.js Mon Jan 16 14:53:00 2017 +0100
+++ b/app/controller/grid/Ortszuordnung.js Wed Jan 18 11:41:50 2017 +0100
@@ -13,7 +13,8 @@
extend: 'Ext.app.Controller',
requires: [
- 'Lada.view.window.Ortszuordnung'
+ 'Lada.view.window.Ortszuordnung',
+ 'Lada.view.form.Ortserstellung'
],
/**
@@ -30,6 +31,15 @@
},
'ortszuordnunggrid button[action=delete]': {
click: this.remove
+ },
+ 'ortszuordnungwindow toolbar button[action=createort]':{
+ click: this.createort
+ },
+ 'ortszuordnungwindow toolbar button[action=frommap]':{
+ click: this.frommap
+ },
+ 'ortszuordnungwindow toolbar button[action=clone]':{
+ click: this.cloneort
}
});
},
@@ -42,7 +52,7 @@
var probe = grid.up('window').record;
var win = Ext.create('Lada.view.window.Ortszuordnung', {
parentWindow: grid.up('window'),
- probe: grid.up('window').down('probeform').record,
+ probe: probe,
record: record,
grid: grid
});
@@ -103,5 +113,42 @@
}
});
grid.down('button[action=delete]').disable();
+ },
+
+ /**
+ * Opens the form for a new Messpunkt
+ */
+ createort: function() {
+ Ext.create('Lada.view.form.Ortserstellung').show();
+ },
+
+ /**
+ *
+ * Opens the form for a new Messpunkt, with prefilled coordinates.
+ * TODO Not functional yet
+ */
+ frommap: function(button) {
+ var map = button.up('ortszuordnungwindow').down('map');
+ // map.getClick();
+ //TODO: wait for click return
+ Ext.create('Lada.view.form.Ortserstellung', {
+ presets: {
+ kda_id: 4,
+ koord_x_extern: 35000000, //TODO dummy values
+ koord_y_extern: 1000000
+ }
+ }).show();
+ },
+
+ /**
+ * Opens the form for a new Messpunkt, with all values prefilled from the currently
+ * selected item
+ */
+ cloneort: function(button) {
+ var grid = button.up('ortszuordnungwindow').down('ortstammdatengrid').getView();
+ var selected = grid.getSelectionModel().getSelection()[0];
+ Ext.create('Lada.view.form.Ortserstellung', {
+ presets: selected.data
+ }).show();
}
});
diff -r cb9609380056 -r 291df0037835 app/view/form/Ortserstellung.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/app/view/form/Ortserstellung.js Wed Jan 18 11:41:50 2017 +0100
@@ -0,0 +1,286 @@
+/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
+ * Software engineering by Intevation GmbH
+ *
+ * This file is Free Software under the GNU GPL (v>=3)
+ * and comes with ABSOLUTELY NO WARRANTY! Check out
+ * the documentation coming with IMIS-Labordaten-Application for details.
+ */
+
+/**
+ * Form to create a new Messpunkt
+ * TODO: layout, saving, model
+ */
+Ext.define('Lada.view.form.Ortserstellung', {
+ extend: 'Ext.form.Panel',
+ alias: 'widget.ortserstellungsform',
+
+ model: 'Lada.model.Ortszuordnung',//TODO correct model needed
+ requires: [
+ 'Lada.view.widget.Verwaltungseinheit',
+ 'Lada.view.widget.Staat'
+ ],
+
+ width: 900,
+ height: 700,
+ bodyStyle: {background: '#fff'},
+ layout: 'vbox',
+ scrollable: true,
+ margin: '5, 5, 0, 5',
+ border: 0,
+ floating: true,
+ closable: true,
+
+ /**
+ * Preset values
+ */
+ presets: null,
+
+ initComponent: function() {
+ var i18n = Lada.getApplication().bundle;
+ var me = this;
+ this.items = [{ //TODO: layout and input types
+ title: 'Neuen Messpunkt anlegen',
+ dockedItems : [{
+ xtype: 'toolbar',
+ dock: 'bottom',
+ border: '0, 1, 1, 1',
+ style: {
+ borderBottom: '1px solid #b5b8c8 !important',
+ borderLeft: '1px solid #b5b8c8 !important',
+ borderRight: '1px solid #b5b8c8 !important'
+ },
+ items: ['->', {
+ text: i18n.getMsg('save'),
+ disabled: true,
+ action: 'save',
+ handler: me.saveOrt
+ }, {
+ text: i18n.getMsg('close'),
+ action: 'close',
+ handler: function() {
+ me.close();
+ }
+ }]
+ }],
+ items : [{
+ xtype: 'netzbetreiber',
+ editable: false,
+ readOnly: true,
+ submitValue: true,
+ fieldLabel: i18n.getMsg('netzbetreiberId'),
+ margin : '0, 5, 5, 5',
+ labelWidth: 80,
+ // value: XXX
+ // TODO: get netzbetreiber of current user
+ }, {
+ xtype: 'checkbox',
+ name: 'aktiv',
+ fieldLabel: 'aktiv:',
+ value: me.presets.aktiv? me.presets.aktiv:null
+ }, {
+ xtype: 'displayfield',
+ value: 'D',
+ labelWidth: 125,
+ maxLength: 1,
+ name: 'messpunktart',
+ fieldLabel: 'Art des Messpunktes:'
+ },{
+ xtype: 'displayfield',
+ labelWidth: 125,
+ maxLength: 100,
+ name: 'OrtID',
+ fieldLabel: 'Ort/Messpunkt-ID:',
+ // TODO: needed? We can't set it, and it is not yet given
+ // for a new messpunkt
+ editable: false
+ }, {
+ xtype: 'staat',
+ labelWidth: 100,
+ fieldLabel: i18n.getMsg('staat'),
+ name: 'staatId',
+ width: 160,
+ listeners: {
+ change: {
+ fn: function() { me.checkCommitEnabled() }
+ }
+ }
+ }, {
+ xtype: 'verwaltungseinheit',
+ labelWidth: 125,
+ fieldLabel: i18n.getMsg('orte.gemeinde'),
+ name: 'gemeinde',
+ listeners: {
+ change: {
+ fn: function() { me.checkCommitEnabled() }
+ }
+ }
+ }, {
+ xtype: 'displayfield',
+ labelWidth: 125,
+ fieldLabel: i18n.getMsg('orte.kda'),
+ name: 'kdaId',
+ listeners: {
+ change: {
+ fn: function() { me.checkCommitEnabled() }
+ }
+ }
+ }, {
+ xtype: 'displayfield',
+ labelWidth: 125,
+ fieldLabel: i18n.getMsg('orte.koordx'),
+ name: 'koordXExtern',
+ listeners: {
+ change: {
+ fn: function() { me.checkCommitEnabled() }
+ }
+ }
+ }, {
+ xtype: 'displayfield',
+ labelWidth: 125,
+ fieldLabel: i18n.getMsg('orte.koordy'),
+ name: 'koordYExtern',
+ listeners: {
+ change: {
+ fn: function() { me.checkCommitEnabled() }
+ }
+ }
+ }, {
+ xtype: 'displayfield',
+ labelWidth: 125,
+ fieldLabel: 'Höhe:',
+ name: 'hoehe', //TODO: hohe_ueber_NN?
+ }, {
+ xtype: 'displayfield',
+ labelWidth: 125,
+ maxLength: 100,
+ name: 'kurztext',
+ fieldLabel: 'Kurztext:'
+ },{
+ xtype: 'displayfield',
+ labelWidth: 125,
+ fieldLabel: i18n.getMsg('orte.langtext'),
+ name: 'langtext'
+ },{
+ xtype: 'displayfield',
+ labelWidth: 125,
+ fieldLabel: 'Berichtstext:',
+ name: 'berichtstext'
+ }]
+ }];
+//TODO:
+// 'Anlage:'?
+// zone
+// sektor
+// zustaendigkeit
+// Messregime (mpArt)
+// 'Prog.-Punkt:', ?
+// nutsCode
+// Ortszusatz-ID (ozId)
+ me.callParent(arguments);
+ this.prefillForm();
+ },
+
+ /**
+ * checks Messpunktart and if the Messpunkt can be committed.
+ * Disables the save button if false
+ */
+ // TODO messpunktart is not yet finally defined
+ checkCommitEnabled: function() {
+ var savebutton = this.down('toolbar').down('button[action=save]');
+ var form = this.getForm();
+ if (this.checkCoordinates()) {
+ form.findField('messpunktart').setValue('D');
+ savebutton.setDisabled(false);
+ } else if (form.findField('gemeinde').getValue()) {
+ form.findField('messpunktart').setValue('V');
+ savebutton.setDisabled(false);
+ } else if (form.findField('staatId')) {
+ form.findField('messpunktart').setValue('S');
+ savebutton.setDisabled(false);
+ } else {
+ form.findField('messpunktart').setValue('D');
+ savebutton.setDisabled(true);
+ }
+ },
+
+ /**
+ * Validates the coordinate fields kdaId, koordXExtern, koordYExtern
+ */
+ checkCoordinates: function() {
+ var x = this.getForm().findField('koordXExtern').getValue();
+ var y = this.getForm().findField('koordYExtern').getValue();
+ var kda = this.getForm().findField('kdaId').getValue();
+ if (x && y && kda) {
+ if (kda === 4){
+ if (x > -180 && x < 180
+ && y > -90 && y < 90) {
+ return true;
+ } else {
+ // TODO: WGS84 (degrees- decimal), coordinates invalid
+ return false;
+ }
+ } else if (kda === 5){
+ if (x >= 1000000 && x < 61000000 &&
+ y > -10000000 && y < 10000000) {
+ return true;
+ } else {
+ // TODO: UTM, coordinates invalid
+ return false;
+ }
+ } else {
+ // TODO KDA not supported
+ return false;
+ }
+ } else {
+ // TODO: not all fields filled in
+ return false;
+ }
+ },
+
+ saveOrt: function(){
+ // TODO not yet implemented
+ alert("save!");
+ },
+
+ /**
+ * Fill the form with values passed by presets.
+ // TODO Find a shorter way of setting all these
+ */
+ prefillForm: function() {
+ var form = this.getForm();
+ if (this.presets.aktiv) {
+ form.findField('aktiv').setValue(this.presets.aktiv);
+ }
+ if (this.presets.staatId) {
+ // TODO: staatID != staatISO
+ form.findField('staatId').setValue(me.presets.staatId);
+ }
+ if (this.presets.gemeinde) {
+ // TODO: ortId != gemeinde
+ form.findField('gemeinde').setValue(this.presets.gemeinde);
+ }
+ if (this.presets.kdaId) {
+ form.findField('kdaId').setValue(this.presets.kdaId);
+ }
+ if (this.presets.koordXExtern) {
+ form.findField('koordXExtern').setValue(this.presets.koordXExtern);
+ }
+ if (this.presets.koordYExtern) {
+ form.findField('koordYExtern').setValue(this.presets.koordYExtern);
+ }
+ if (this.presets.hoehe) {
+ // TODO hohe_ueber_NN?
+ form.findField('hoehe').setValue(me.presets.hoehe);
+ }
+ if (this.presets.kurztext) {
+ form.findField('kurztext').setValue(this.presets.kurztext);
+ }
+ if (this.presets.langtext) {
+ form.findField('langtext').setValue(this.presets.langtext);
+ }
+ if (this.presets.berichtstext) {
+ form.findField('berichtstext').setValue(this.presets.berichtstext);
+ }
+ }
+});
+
diff -r cb9609380056 -r 291df0037835 app/view/panel/Map.js
--- a/app/view/panel/Map.js Mon Jan 16 14:53:00 2017 +0100
+++ b/app/view/panel/Map.js Wed Jan 18 11:41:50 2017 +0100
@@ -27,11 +27,12 @@
/**
* @cfg
* OpenLayers map options.
+ * Please note that TMS zoom levels are roughly as this:
+ * 7 = 1:4000000 14 = 1:35000
*/
mapOptions: {
maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34),
- //scales: [5000000, 3000000, 2000000, 1000000, 500000, 250000, 100000, 25000],
- //numZoomLevels: 7,
+ numZoomLevels: 15,
projection: 'EPSG:3857',
displayProjection: new OpenLayers.Projection('EPSG:4326')
},
@@ -59,7 +60,10 @@
this.map = new OpenLayers.Map('map_' + id, {
controls: [],
tileManager: null,
- zoomMethod: null
+ zoomMethod: null,
+ // initializing with view centered on germany
+ center: new OpenLayers.LonLat(1160000,6694000),
+ zoom: 7
});
this.map.setOptions(this.mapOptions);
this.map.addLayers(this.layers);
@@ -89,12 +93,20 @@
if (!record.get('id') || record.get('id') === '') {
return;
}
- var feature = this.featureLayer.getFeaturesByAttribute('id', record.get('id'));
+ var feature = this.featureLayer.getFeaturesByAttribute('id', record.get('id'))[0];
this.map.setCenter(
- new OpenLayers.LonLat(feature[0].geometry.x, feature[0].geometry.y));
- this.map.zoomToScale(this.mapOptions.scales[5]);
- this.selectControl.unselectAll();
- this.selectControl.select(feature[0]);
+ new OpenLayers.LonLat(feature.geometry.x, feature.geometry.y));
+ this.map.zoomTo(12);
+
+ if (this.selectedFeatureLayer) {
+ if (this.selectedFeatureLayer.features.lenght > 0) {
+ this.featureLayer.addFeatures(this.selectedFeatureLayer.features);
+ }
+ this.selectedFeatureLayer.addFeatures([feature]);
+ } else {
+ this.selectControl.select(feature);
+ }
+ //TODO: the text of new features is still drawn on top of the old feature's text
},
activateDraw: function(record) {
@@ -138,7 +150,7 @@
// Create a new Feature Layer and add it to the map
if (!this.featureLayer) {
- this.featureLayer = new OpenLayers.Layer.Vector('alle Messpunkte', {
+ this.featureLayer = new OpenLayers.Layer.Vector( 'alle Messpunkte', {
styleMap: new OpenLayers.StyleMap({
'default': new OpenLayers.Style(OpenLayers.Util.applyDefaults({
externalGraphic: 'resources/lib/OpenLayers/img/marker-green.png',
@@ -158,9 +170,10 @@
fontWeight: 'bold'
})
}),
- projection: new OpenLayers.Projection('EPSG:4326'),
+ projection: new OpenLayers.Projection('EPSG:3857'),
preFeatureInsert: function(feature) {
- feature.geometry.transform(new OpenLayers.Projection('EPSG:4326'), new OpenLayers.Projection('EPSG:3857'));
+ feature.geometry.transform(new OpenLayers.Projection('EPSG:4326'),
+ new OpenLayers.Projection('EPSG:3857'));
}
});
this.selectControl = new OpenLayers.Control.SelectFeature(this.featureLayer, {
@@ -169,6 +182,7 @@
multiple: false,
hover: false,
onSelect: me.selectedFeature,
+ layers: [me.featureLayer],
scope: me
});
this.map.addControl(this.selectControl);
@@ -177,10 +191,9 @@
this.featureLayer.removeAllFeatures();
this.featureLayer.addFeatures(locationFeatures);
this.map.addLayer(this.featureLayer);
-
+ this.featureLayer.setZIndex(500);
},
-
/**
* @private
* Override to display and update the map view in the panel.
@@ -197,7 +210,8 @@
/**
* Forward OpenlayersEvent to EXT
*/
- selectedFeature: function() {
+ selectedFeature: function(feature) {
+ this.selectControl.unselectAll({except:feature});
this.fireEvent('featureselected', this, arguments);
},
diff -r cb9609380056 -r 291df0037835 app/view/panel/Ort.js
--- a/app/view/panel/Ort.js Mon Jan 16 14:53:00 2017 +0100
+++ b/app/view/panel/Ort.js Wed Jan 18 11:41:50 2017 +0100
@@ -95,7 +95,7 @@
afterRender: function() {
this.superclass.afterRender.apply(this, arguments);
- this.down('map').map.zoomToMaxExtent();
+ this.down('map').map.zoomTo(6);
},
setStore: function(store) {
diff -r cb9609380056 -r 291df0037835 app/view/window/Ortszuordnung.js
--- a/app/view/window/Ortszuordnung.js Mon Jan 16 14:53:00 2017 +0100
+++ b/app/view/window/Ortszuordnung.js Wed Jan 18 11:41:50 2017 +0100
@@ -15,6 +15,7 @@
requires: [
'Lada.view.form.Ortszuordnung',
+ 'Lada.view.form.Ortserstellung',
'Lada.view.panel.Ort'
],
@@ -103,10 +104,9 @@
layout: 'fit',
name: 'ortgrid',
hidden: true,
- maxHeight: '45%',
+ maxHeight: 240,
items: [{
- xtype: 'ortstammdatengrid',
- maxHeight: '45%'
+ xtype: 'ortstammdatengrid'
}],
dockedItems: [{
xtype: 'toolbar',
@@ -123,20 +123,18 @@
fieldLabel: i18n.getMsg('ortszuordnung.ortsuche'),
}, '->', {
text: i18n.getMsg('orte.new'),
- action: 'createort',
+ action: 'createort'
}, {
text: i18n.getMsg('orte.frommap'),
- action: 'frommap',
+ action: 'frommap'
}, {
text: i18n.getMsg('orte.clone'),
- action: 'clone',
- }, {
- text: i18n.getMsg('orte.select'),
- action: 'select',
+ action: 'clone'
}]
}]
}]
}];
+
this.callParent(arguments);
},
@@ -170,19 +168,35 @@
osg.setLoading(false);
map.setLoading(false);
osg.setStore(ortstore);
- var store = Ext.create('Lada.store.Orte', {
- autoLoad: false
- });
- store.add(ortstore.getRange());
- var rec = store.getById(me.record.get('ortId'));
- store.remove(rec);
- console.log(rec);
- map.addLocations(store);
+ map.addLocations(ortstore);
+ map.featureLayer.setVisibility(false);
+ map.selectedFeatureLayer = new OpenLayers.Layer.Vector(
+ 'gewählter Messpunkt', {
+ styleMap: new OpenLayers.StyleMap({
+ externalGraphic: 'resources/lib/OpenLayers/img/marker-blue.png',
+ pointRadius: 10,
+ label: '${bez}',
+ labelAlign: 'rt',
+ fontColor: 'blue',
+ fontWeight: 'bold',
+ }),
+ displayInLayerSwitcher: false,
+ projection: new OpenLayers.Projection('EPSG:3857')
+ });
+ map.map.addLayer(map.selectedFeatureLayer);
+ map.selectedFeatureLayer.setZIndex(499);
+ var ortId = me.record.get('ortId');
+ if (ortId){
+ var feat = map.featureLayer.getFeaturesByAttribute('id', ortId)[0];
+ map.selectControl.select(feat);
+ }
}
}
}
});
ortstore.load();
+ map.addListener('featureselected', osg.selectOrt, osg);
+ osg.addListener('select', map.selectFeature, map);
},
/**
@@ -193,7 +207,6 @@
this.superclass.afterRender.apply(this, arguments);
var map = this.down('map');
map.map.addControl(new OpenLayers.Control.LayerSwitcher());
- //map.map.zoomToMaxExtent();
},
/**
More information about the Lada-commits
mailing list