annotate app/view/window/OrtCreate.js @ 1037:56922c5c21fd

Preselect erzeuger if combobox contains only one object.
author Raimund Renkert <raimund.renkert@intevation.de>
date Thu, 18 Feb 2016 13:35:54 +0100
parents def27cdd0dfa
children
rev   line source
642
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
1 /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
2 * Software engineering by Intevation GmbH
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
3 *
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
4 * This file is Free Software under the GNU GPL (v>=3)
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
6 * the documentation coming with IMIS-Labordaten-Application for details.
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
7 */
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
8
796
7267bae1d43f made window-panel recyclable, fwd openlayers events to ext
Dustin Demuth <dustin@intevation.de>
parents: 709
diff changeset
9 /**
7267bae1d43f made window-panel recyclable, fwd openlayers events to ext
Dustin Demuth <dustin@intevation.de>
parents: 709
diff changeset
10 * Window to create a Ort
642
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
11 */
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
12 Ext.define('Lada.view.window.OrtCreate', {
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
13 extend: 'Ext.window.Window',
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
14 alias: 'widget.ortcreate',
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
15
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
16 requires: [
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
17 'Lada.view.panel.Map',
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
18 'Lada.view.form.Ort',
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
19 'Lada.view.form.Location'
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
20 ],
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
21
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
22 collapsible: true,
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
23 maximizable: true,
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
24 autoshow: true,
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
25 layout: 'border',
688
6a6d1b02a1a3 constrain windows to viewport
Dustin Demuth <dustin@intevation.de>
parents: 642
diff changeset
26 constrain: true,
642
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
27
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
28 record: null,
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
29 grid: null,
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
30
890
def27cdd0dfa Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents: 796
diff changeset
31 /**
def27cdd0dfa Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents: 796
diff changeset
32 * This function initialises the Window
def27cdd0dfa Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents: 796
diff changeset
33 */
642
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
34 initComponent: function() {
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
35 this.title = 'Ort';
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
36 this.buttons = [{
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
37 text: 'Schließen',
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
38 scope: this,
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
39 handler: this.close
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
40 }];
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
41 this.width = 900;
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
42 this.height = 515;
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
43 this.bodyStyle = {background: '#fff'};
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
44
709
6f6d2df00130 Added some CSS to make distinction between active and inactice windows more simple for the user
Dustin Demuth <dustin@intevation.de>
parents: 688
diff changeset
45 // add listeners to change the window appearence when it becomes inactive
6f6d2df00130 Added some CSS to make distinction between active and inactice windows more simple for the user
Dustin Demuth <dustin@intevation.de>
parents: 688
diff changeset
46 this.on({
6f6d2df00130 Added some CSS to make distinction between active and inactice windows more simple for the user
Dustin Demuth <dustin@intevation.de>
parents: 688
diff changeset
47 activate: function(){
6f6d2df00130 Added some CSS to make distinction between active and inactice windows more simple for the user
Dustin Demuth <dustin@intevation.de>
parents: 688
diff changeset
48 this.getEl().removeCls('window-inactive');
6f6d2df00130 Added some CSS to make distinction between active and inactice windows more simple for the user
Dustin Demuth <dustin@intevation.de>
parents: 688
diff changeset
49 },
6f6d2df00130 Added some CSS to make distinction between active and inactice windows more simple for the user
Dustin Demuth <dustin@intevation.de>
parents: 688
diff changeset
50 deactivate: function(){
6f6d2df00130 Added some CSS to make distinction between active and inactice windows more simple for the user
Dustin Demuth <dustin@intevation.de>
parents: 688
diff changeset
51 this.getEl().addCls('window-inactive');
6f6d2df00130 Added some CSS to make distinction between active and inactice windows more simple for the user
Dustin Demuth <dustin@intevation.de>
parents: 688
diff changeset
52 }
6f6d2df00130 Added some CSS to make distinction between active and inactice windows more simple for the user
Dustin Demuth <dustin@intevation.de>
parents: 688
diff changeset
53 });
6f6d2df00130 Added some CSS to make distinction between active and inactice windows more simple for the user
Dustin Demuth <dustin@intevation.de>
parents: 688
diff changeset
54
642
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
55 this.items = [{
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
56 region: 'west',
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
57 border: 0,
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
58 layout: 'vbox',
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
59 items: [{
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
60 xtype: 'ortform',
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
61 margin: 5
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
62 }, {
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
63 xtype: 'locationform',
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
64 margin: 5
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
65 }]
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
66 }, {
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
67 xtype: 'fset',
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
68 bodyStyle: {
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
69 background: '#fff'
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
70 },
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
71 layout: 'border',
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
72 name: 'mapfield',
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
73 title: 'Karte',
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
74 region: 'center',
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
75 padding: '5, 5',
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
76 margin: 5,
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
77 items: [{
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
78 xtype: 'map',
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
79 region: 'center',
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
80 layout: 'border',
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
81 bodyStyle: {
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
82 background: '#fff'
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
83 },
796
7267bae1d43f made window-panel recyclable, fwd openlayers events to ext
Dustin Demuth <dustin@intevation.de>
parents: 709
diff changeset
84 name: 'map',
7267bae1d43f made window-panel recyclable, fwd openlayers events to ext
Dustin Demuth <dustin@intevation.de>
parents: 709
diff changeset
85 listeners: { //A listener which listens to the mappanels featureselected event
7267bae1d43f made window-panel recyclable, fwd openlayers events to ext
Dustin Demuth <dustin@intevation.de>
parents: 709
diff changeset
86 featureselected: this.selectedFeature
7267bae1d43f made window-panel recyclable, fwd openlayers events to ext
Dustin Demuth <dustin@intevation.de>
parents: 709
diff changeset
87 }
642
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
88 }]
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
89 }];
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
90 this.callParent(arguments);
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
91 },
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
92
890
def27cdd0dfa Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents: 796
diff changeset
93 /**
def27cdd0dfa Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents: 796
diff changeset
94 * Initialise the Data of this Window
def27cdd0dfa Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents: 796
diff changeset
95 */
642
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
96 initData: function() {
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
97 var ort = Ext.create('Lada.model.Ort', {
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
98 probeId: this.record.get('id')
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
99 });
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
100 this.down('ortform').setRecord(ort);
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
101 },
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
102
796
7267bae1d43f made window-panel recyclable, fwd openlayers events to ext
Dustin Demuth <dustin@intevation.de>
parents: 709
diff changeset
103 /**
7267bae1d43f made window-panel recyclable, fwd openlayers events to ext
Dustin Demuth <dustin@intevation.de>
parents: 709
diff changeset
104 * @private
7267bae1d43f made window-panel recyclable, fwd openlayers events to ext
Dustin Demuth <dustin@intevation.de>
parents: 709
diff changeset
105 * Override to display and update the map view in the panel.
7267bae1d43f made window-panel recyclable, fwd openlayers events to ext
Dustin Demuth <dustin@intevation.de>
parents: 709
diff changeset
106 */
7267bae1d43f made window-panel recyclable, fwd openlayers events to ext
Dustin Demuth <dustin@intevation.de>
parents: 709
diff changeset
107 afterRender: function(){
7267bae1d43f made window-panel recyclable, fwd openlayers events to ext
Dustin Demuth <dustin@intevation.de>
parents: 709
diff changeset
108 this.superclass.afterRender.apply(this, arguments);
7267bae1d43f made window-panel recyclable, fwd openlayers events to ext
Dustin Demuth <dustin@intevation.de>
parents: 709
diff changeset
109 var map = this.down('map');
7267bae1d43f made window-panel recyclable, fwd openlayers events to ext
Dustin Demuth <dustin@intevation.de>
parents: 709
diff changeset
110 map.map.zoomToMaxExtent();
7267bae1d43f made window-panel recyclable, fwd openlayers events to ext
Dustin Demuth <dustin@intevation.de>
parents: 709
diff changeset
111 },
7267bae1d43f made window-panel recyclable, fwd openlayers events to ext
Dustin Demuth <dustin@intevation.de>
parents: 709
diff changeset
112
7267bae1d43f made window-panel recyclable, fwd openlayers events to ext
Dustin Demuth <dustin@intevation.de>
parents: 709
diff changeset
113 /**
7267bae1d43f made window-panel recyclable, fwd openlayers events to ext
Dustin Demuth <dustin@intevation.de>
parents: 709
diff changeset
114 * This function is used by the MapPanel, when a Feature was selected
7267bae1d43f made window-panel recyclable, fwd openlayers events to ext
Dustin Demuth <dustin@intevation.de>
parents: 709
diff changeset
115 */
7267bae1d43f made window-panel recyclable, fwd openlayers events to ext
Dustin Demuth <dustin@intevation.de>
parents: 709
diff changeset
116 selectedFeature: function(context, args) {
7267bae1d43f made window-panel recyclable, fwd openlayers events to ext
Dustin Demuth <dustin@intevation.de>
parents: 709
diff changeset
117 var feature = args[0];
7267bae1d43f made window-panel recyclable, fwd openlayers events to ext
Dustin Demuth <dustin@intevation.de>
parents: 709
diff changeset
118 if (feature.attributes.id &&
7267bae1d43f made window-panel recyclable, fwd openlayers events to ext
Dustin Demuth <dustin@intevation.de>
parents: 709
diff changeset
119 feature.attributes.id !== '') {
7267bae1d43f made window-panel recyclable, fwd openlayers events to ext
Dustin Demuth <dustin@intevation.de>
parents: 709
diff changeset
120 var record = Ext.data.StoreManager.get('locations').getById(feature.attributes.id);
7267bae1d43f made window-panel recyclable, fwd openlayers events to ext
Dustin Demuth <dustin@intevation.de>
parents: 709
diff changeset
121 context.up('window').down('locationform').setRecord(record);
7267bae1d43f made window-panel recyclable, fwd openlayers events to ext
Dustin Demuth <dustin@intevation.de>
parents: 709
diff changeset
122 context.up('window').down('locationform').setReadOnly(true);
7267bae1d43f made window-panel recyclable, fwd openlayers events to ext
Dustin Demuth <dustin@intevation.de>
parents: 709
diff changeset
123 context.up('window').down('ortform').down('combobox').setValue(record.id);
7267bae1d43f made window-panel recyclable, fwd openlayers events to ext
Dustin Demuth <dustin@intevation.de>
parents: 709
diff changeset
124 }
7267bae1d43f made window-panel recyclable, fwd openlayers events to ext
Dustin Demuth <dustin@intevation.de>
parents: 709
diff changeset
125 else {
7267bae1d43f made window-panel recyclable, fwd openlayers events to ext
Dustin Demuth <dustin@intevation.de>
parents: 709
diff changeset
126 context.up('window').down('locationform').setRecord(this.locationRecord);
7267bae1d43f made window-panel recyclable, fwd openlayers events to ext
Dustin Demuth <dustin@intevation.de>
parents: 709
diff changeset
127 context.up('window').down('locationform').setReadOnly(false);
7267bae1d43f made window-panel recyclable, fwd openlayers events to ext
Dustin Demuth <dustin@intevation.de>
parents: 709
diff changeset
128 }
7267bae1d43f made window-panel recyclable, fwd openlayers events to ext
Dustin Demuth <dustin@intevation.de>
parents: 709
diff changeset
129 },
7267bae1d43f made window-panel recyclable, fwd openlayers events to ext
Dustin Demuth <dustin@intevation.de>
parents: 709
diff changeset
130
890
def27cdd0dfa Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents: 796
diff changeset
131 /**
def27cdd0dfa Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents: 796
diff changeset
132 * Instructs the fields / forms listed in this method to set a message.
def27cdd0dfa Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents: 796
diff changeset
133 * @param errors These Errors shall be shown
def27cdd0dfa Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents: 796
diff changeset
134 * @param warnings These Warning shall be shown
def27cdd0dfa Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents: 796
diff changeset
135 */
642
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
136 setMessages: function(errors, warnings) {
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
137 //todo this is a stub
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
138 },
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
139
890
def27cdd0dfa Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents: 796
diff changeset
140 /**
def27cdd0dfa Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents: 796
diff changeset
141 * Instructs the fields / forms listed in this method to clear their messages.
def27cdd0dfa Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents: 796
diff changeset
142 */
642
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
143 clearMessages: function() {
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
144 //todo this is a stub
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
145 }
bd151c8b7ad1 Added window to create a new ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
146 });

http://lada.wald.intevation.org