annotate app/view/window/OrtEdit.js @ 695:d6ef146e1a9f

Added simple handling for Failure-Messages
author Dustin Demuth <dustin@intevation.de>
date Thu, 26 Mar 2015 16:24:13 +0100
parents e88381fb3bdb
children 6f6d2df00130
rev   line source
606
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
1 /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
2 * Software engineering by Intevation GmbH
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
3 *
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
4 * This file is Free Software under the GNU GPL (v>=3)
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
6 * the documentation coming with IMIS-Labordaten-Application for details.
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
7 */
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
8
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
9 /*
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
10 * Window to edit a Messung
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
11 */
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
12 Ext.define('Lada.view.window.OrtEdit', {
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
13 extend: 'Ext.window.Window',
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
14 alias: 'widget.ortedit',
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
15
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
16 requires: [
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
17 'Lada.view.panel.Map',
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
18 'Lada.view.form.Ort',
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
19 'Lada.view.form.Location'
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
20 ],
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
21
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
22 collapsible: true,
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
23 maximizable: true,
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
24 autoshow: true,
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
25 layout: 'border',
688
6a6d1b02a1a3 constrain windows to viewport
Dustin Demuth <dustin@intevation.de>
parents: 644
diff changeset
26 constrain: true,
606
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
27
690
e88381fb3bdb Use treeModiefied timestamp to determine if working with 'old' objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 688
diff changeset
28 parentWindow: null,
e88381fb3bdb Use treeModiefied timestamp to determine if working with 'old' objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 688
diff changeset
29 probe: null,
606
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
30 record: null,
644
71e8b84d7829 Reload grids on messung or ort changed/added.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 614
diff changeset
31 grid: null,
606
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
32
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
33 initComponent: function() {
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
34 if (this.record === null) {
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
35 Ext.Msg.alert('Kein valider Ort ausgewählt!');
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
36 this.callParent(arguments);
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
37 return;
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
38 }
690
e88381fb3bdb Use treeModiefied timestamp to determine if working with 'old' objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 688
diff changeset
39 if (this.probe === null) {
e88381fb3bdb Use treeModiefied timestamp to determine if working with 'old' objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 688
diff changeset
40 Ext.Msg.alert('Zu dem Ort existiert keine Probe!');
e88381fb3bdb Use treeModiefied timestamp to determine if working with 'old' objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 688
diff changeset
41 this.callParent(arguments);
e88381fb3bdb Use treeModiefied timestamp to determine if working with 'old' objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 688
diff changeset
42 return;
e88381fb3bdb Use treeModiefied timestamp to determine if working with 'old' objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 688
diff changeset
43 }
606
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
44 this.title = 'Ort';
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
45 this.buttons = [{
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
46 text: 'Schließen',
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
47 scope: this,
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
48 handler: this.close
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
49 }];
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
50 this.width = 900;
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
51 this.height = 515;
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
52 this.bodyStyle = {background: '#fff'};
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
53
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
54 this.items = [{
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
55 region: 'west',
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
56 border: 0,
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
57 layout: 'vbox',
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
58 items: [{
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
59 xtype: 'ortform',
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
60 margin: 5,
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
61 recordId: this.record.get('id')
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
62 }, {
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
63 xtype: 'locationform',
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
64 margin: 5,
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
65 recordId: this.record.get('id')
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
66 }]
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
67 }, {
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
68 xtype: 'fset',
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
69 bodyStyle: {
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
70 background: '#fff'
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
71 },
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
72 layout: 'border',
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
73 name: 'mapfield',
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
74 title: 'Karte',
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
75 region: 'center',
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
76 padding: '5, 5',
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
77 margin: 5,
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
78 items: [{
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
79 xtype: 'map',
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
80 region: 'center',
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
81 layout: 'border',
614
04e380ce4d73 Load locations as layer on the map, set selections based on the selected 'ort'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 606
diff changeset
82 record: this.record,
606
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
83 bodyStyle: {
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
84 background: '#fff'
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
85 },
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
86 name: 'map'
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
87 }]
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
88 }];
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
89 this.callParent(arguments);
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
90 },
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
91
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
92 initData: function() {
690
e88381fb3bdb Use treeModiefied timestamp to determine if working with 'old' objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 688
diff changeset
93 Ext.ClassManager.get('Lada.model.Ort').load(this.record.get('id'), {
e88381fb3bdb Use treeModiefied timestamp to determine if working with 'old' objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 688
diff changeset
94 failure: function(record, action) {
e88381fb3bdb Use treeModiefied timestamp to determine if working with 'old' objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 688
diff changeset
95 // TODO
e88381fb3bdb Use treeModiefied timestamp to determine if working with 'old' objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 688
diff changeset
96 },
e88381fb3bdb Use treeModiefied timestamp to determine if working with 'old' objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 688
diff changeset
97 success: function(record, response) {
e88381fb3bdb Use treeModiefied timestamp to determine if working with 'old' objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 688
diff changeset
98 var me = this;
e88381fb3bdb Use treeModiefied timestamp to determine if working with 'old' objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 688
diff changeset
99 if (this.probe.get('treeModified') < record.get('treeModified')) {
e88381fb3bdb Use treeModiefied timestamp to determine if working with 'old' objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 688
diff changeset
100 Ext.Msg.show({
e88381fb3bdb Use treeModiefied timestamp to determine if working with 'old' objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 688
diff changeset
101 title: 'Probe nicht aktuell!',
e88381fb3bdb Use treeModiefied timestamp to determine if working with 'old' objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 688
diff changeset
102 msg: 'Die zugehörige Probe wurde verändert.\nMöchten Sie zu der Probe zurückkehren und neu laden?\nOhne das erneute Laden der Probe wird das Speichern des Ortes nicht möglich sein.',
e88381fb3bdb Use treeModiefied timestamp to determine if working with 'old' objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 688
diff changeset
103 buttons: Ext.Msg.OKCANCEL,
e88381fb3bdb Use treeModiefied timestamp to determine if working with 'old' objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 688
diff changeset
104 icon: Ext.Msg.WARNING,
e88381fb3bdb Use treeModiefied timestamp to determine if working with 'old' objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 688
diff changeset
105 closable: false,
e88381fb3bdb Use treeModiefied timestamp to determine if working with 'old' objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 688
diff changeset
106 fn: function(button) {
e88381fb3bdb Use treeModiefied timestamp to determine if working with 'old' objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 688
diff changeset
107 if (button === 'ok') {
e88381fb3bdb Use treeModiefied timestamp to determine if working with 'old' objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 688
diff changeset
108 me.close();
e88381fb3bdb Use treeModiefied timestamp to determine if working with 'old' objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 688
diff changeset
109 me.parentWindow.initData();
e88381fb3bdb Use treeModiefied timestamp to determine if working with 'old' objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 688
diff changeset
110 }
e88381fb3bdb Use treeModiefied timestamp to determine if working with 'old' objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 688
diff changeset
111 else {
e88381fb3bdb Use treeModiefied timestamp to determine if working with 'old' objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 688
diff changeset
112 me.record.set('treeModified', me.probe.get('treeModified'));
e88381fb3bdb Use treeModiefied timestamp to determine if working with 'old' objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 688
diff changeset
113 }
e88381fb3bdb Use treeModiefied timestamp to determine if working with 'old' objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 688
diff changeset
114 }
e88381fb3bdb Use treeModiefied timestamp to determine if working with 'old' objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 688
diff changeset
115 });
e88381fb3bdb Use treeModiefied timestamp to determine if working with 'old' objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 688
diff changeset
116 }
e88381fb3bdb Use treeModiefied timestamp to determine if working with 'old' objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 688
diff changeset
117 this.down('ortform').setRecord(record);
e88381fb3bdb Use treeModiefied timestamp to determine if working with 'old' objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 688
diff changeset
118 this.record = record;
e88381fb3bdb Use treeModiefied timestamp to determine if working with 'old' objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 688
diff changeset
119 },
e88381fb3bdb Use treeModiefied timestamp to determine if working with 'old' objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 688
diff changeset
120 scope: this
e88381fb3bdb Use treeModiefied timestamp to determine if working with 'old' objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 688
diff changeset
121 });
606
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
122 Ext.ClassManager.get('Lada.model.Location').load(this.record.get('ort'), {
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
123 failure: function(record, action) {
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
124 // TODO
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
125 },
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
126 success: function(record, response) {
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
127 this.down('locationform').setRecord(record);
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
128 this.down('locationform').setReadOnly(true);
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
129 },
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
130 scope: this
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
131 });
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
132 },
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
133
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
134 setMessages: function(errors, warnings) {
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
135 //todo this is a stub
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
136 },
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
137
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
138 clearMessages: function() {
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
139 //todo this is a stub
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
140 }
2b2d284bd6e4 Added ort edit window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
141 });

http://lada.wald.intevation.org