annotate app/controller/grid/Ortszuordnung.js @ 1287:e317ba349204

Added search for orte, verwaltungseinheiten and staaten.
author Raimund Renkert <raimund.renkert@intevation.de>
date Thu, 26 Jan 2017 17:33:56 +0100
parents faecbb446a04
children 08085b7d1d0b
rev   line source
587
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
1 /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
2 * Software engineering by Intevation GmbH
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
3 *
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
4 * This file is Free Software under the GNU GPL (v>=3)
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
6 * the documentation coming with IMIS-Labordaten-Application for details.
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
7 */
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
8
742
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
9 /**
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
10 * This is a controller for a grid of Orte
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
11 */
1012
2adc329d90fe Replaced Locations with Ortszuordnung
Dustin Demuth <dustin@intevation.de>
parents: 826
diff changeset
12 Ext.define('Lada.controller.grid.Ortszuordnung', {
587
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
13 extend: 'Ext.app.Controller',
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
14
602
e1ab24758392 Updated the ort grid controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 587
diff changeset
15 requires: [
1279
291df0037835 Ortszuordnung window: create, change and display (wip)
Maximilian Krambach <mkrambach@intevation.de>
parents: 1051
diff changeset
16 'Lada.view.window.Ortszuordnung',
1287
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
17 'Lada.view.form.Ortserstellung',
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
18 'Lada.view.window.OrtFilter'
602
e1ab24758392 Updated the ort grid controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 587
diff changeset
19 ],
e1ab24758392 Updated the ort grid controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 587
diff changeset
20
1287
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
21 resultPanel: null,
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
22 searchField: null,
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
23
742
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
24 /**
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
25 * Inhitialize the controller
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
26 * It has 3 listeners
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
27 */
587
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
28 init: function() {
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
29 this.control({
1012
2adc329d90fe Replaced Locations with Ortszuordnung
Dustin Demuth <dustin@intevation.de>
parents: 826
diff changeset
30 'ortszuordnunggrid': {
602
e1ab24758392 Updated the ort grid controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 587
diff changeset
31 itemdblclick: this.open
587
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
32 },
1012
2adc329d90fe Replaced Locations with Ortszuordnung
Dustin Demuth <dustin@intevation.de>
parents: 826
diff changeset
33 'ortszuordnunggrid button[action=add]': {
587
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
34 click: this.add
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
35 },
1012
2adc329d90fe Replaced Locations with Ortszuordnung
Dustin Demuth <dustin@intevation.de>
parents: 826
diff changeset
36 'ortszuordnunggrid button[action=delete]': {
587
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
37 click: this.remove
1279
291df0037835 Ortszuordnung window: create, change and display (wip)
Maximilian Krambach <mkrambach@intevation.de>
parents: 1051
diff changeset
38 },
291df0037835 Ortszuordnung window: create, change and display (wip)
Maximilian Krambach <mkrambach@intevation.de>
parents: 1051
diff changeset
39 'ortszuordnungwindow toolbar button[action=createort]':{
291df0037835 Ortszuordnung window: create, change and display (wip)
Maximilian Krambach <mkrambach@intevation.de>
parents: 1051
diff changeset
40 click: this.createort
291df0037835 Ortszuordnung window: create, change and display (wip)
Maximilian Krambach <mkrambach@intevation.de>
parents: 1051
diff changeset
41 },
291df0037835 Ortszuordnung window: create, change and display (wip)
Maximilian Krambach <mkrambach@intevation.de>
parents: 1051
diff changeset
42 'ortszuordnungwindow toolbar button[action=frommap]':{
291df0037835 Ortszuordnung window: create, change and display (wip)
Maximilian Krambach <mkrambach@intevation.de>
parents: 1051
diff changeset
43 click: this.frommap
291df0037835 Ortszuordnung window: create, change and display (wip)
Maximilian Krambach <mkrambach@intevation.de>
parents: 1051
diff changeset
44 },
291df0037835 Ortszuordnung window: create, change and display (wip)
Maximilian Krambach <mkrambach@intevation.de>
parents: 1051
diff changeset
45 'ortszuordnungwindow toolbar button[action=clone]':{
291df0037835 Ortszuordnung window: create, change and display (wip)
Maximilian Krambach <mkrambach@intevation.de>
parents: 1051
diff changeset
46 click: this.cloneort
1287
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
47 },
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
48 'ortszuordnungwindow toolbar textfield[name=search]': {
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
49 keyup: this.search
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
50 },
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
51 'ortfilterwindow grid[name=messpunkte]': {
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
52 itemdblclick: this.selectedMesspunkt
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
53 },
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
54 'ortfilterwindow grid[name=verwaltungseinheiten]': {
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
55 itemdblclick: this.selectedVerwaltungseinheit
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
56 },
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
57 'ortfilterwindow grid[name=staaten]': {
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
58 itemdblclick: this.selectedStaat
587
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
59 }
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
60 });
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
61 },
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
62
742
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
63 /**
1013
75ce503ab296 Added a Ortszuordnungwindow and Form
Dustin Demuth <dustin@intevation.de>
parents: 1012
diff changeset
64 * When open is called, a {@link Lada.view.window.Ortszuordnung}
742
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
65 * is created which allows to edit the Orte
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
66 */
602
e1ab24758392 Updated the ort grid controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 587
diff changeset
67 open: function(grid, record) {
690
e88381fb3bdb Use treeModiefied timestamp to determine if working with 'old' objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 644
diff changeset
68 var probe = grid.up('window').record;
1013
75ce503ab296 Added a Ortszuordnungwindow and Form
Dustin Demuth <dustin@intevation.de>
parents: 1012
diff changeset
69 var win = Ext.create('Lada.view.window.Ortszuordnung', {
690
e88381fb3bdb Use treeModiefied timestamp to determine if working with 'old' objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 644
diff changeset
70 parentWindow: grid.up('window'),
1279
291df0037835 Ortszuordnung window: create, change and display (wip)
Maximilian Krambach <mkrambach@intevation.de>
parents: 1051
diff changeset
71 probe: probe,
1028
2e7adc19b4fe Do not copy the Record to the Ortszuordnungwin
Dustin Demuth <dustin@intevation.de>
parents: 1022
diff changeset
72 record: record,
644
71e8b84d7829 Reload grids on messung or ort changed/added.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 643
diff changeset
73 grid: grid
587
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
74 });
602
e1ab24758392 Updated the ort grid controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 587
diff changeset
75 win.show();
e1ab24758392 Updated the ort grid controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 587
diff changeset
76 win.initData();
587
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
77 },
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
78
742
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
79 /**
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
80 * This function adds a new row to add an Ort
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
81 */
643
477379250512 Open the ort create window on button click.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 602
diff changeset
82 add: function(button) {
477379250512 Open the ort create window on button click.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 602
diff changeset
83 var probe = button.up('window').record;
1013
75ce503ab296 Added a Ortszuordnungwindow and Form
Dustin Demuth <dustin@intevation.de>
parents: 1012
diff changeset
84 var win = Ext.create('Lada.view.window.Ortszuordnung', {
75ce503ab296 Added a Ortszuordnungwindow and Form
Dustin Demuth <dustin@intevation.de>
parents: 1012
diff changeset
85 parentWindow: button.up('window'),
75ce503ab296 Added a Ortszuordnungwindow and Form
Dustin Demuth <dustin@intevation.de>
parents: 1012
diff changeset
86 probe: probe,
75ce503ab296 Added a Ortszuordnungwindow and Form
Dustin Demuth <dustin@intevation.de>
parents: 1012
diff changeset
87 record: null,
1012
2adc329d90fe Replaced Locations with Ortszuordnung
Dustin Demuth <dustin@intevation.de>
parents: 826
diff changeset
88 grid: button.up('ortszuordnung')
643
477379250512 Open the ort create window on button click.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 602
diff changeset
89 });
477379250512 Open the ort create window on button click.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 602
diff changeset
90 win.show();
477379250512 Open the ort create window on button click.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 602
diff changeset
91 win.initData();
587
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
92 },
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
93
742
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
94 /**
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
95 * A Ort-row can be removed from the grid with the remove
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
96 * function. It asks the user for confirmation
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
97 * If the removal was confirmed, it reloads the parent window on success,
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
98 * on failure, an error message is shown.
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
99 */
587
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
100 remove: function(button) {
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
101 var grid = button.up('grid');
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
102 var selection = grid.getView().getSelectionModel().getSelection()[0];
1012
2adc329d90fe Replaced Locations with Ortszuordnung
Dustin Demuth <dustin@intevation.de>
parents: 826
diff changeset
103 var i18n = Lada.getApplication().bundle;
2adc329d90fe Replaced Locations with Ortszuordnung
Dustin Demuth <dustin@intevation.de>
parents: 826
diff changeset
104 Ext.MessageBox.confirm(i18n.getMsg('delete'), i18n.getMsg('confirmation.question'),
2adc329d90fe Replaced Locations with Ortszuordnung
Dustin Demuth <dustin@intevation.de>
parents: 826
diff changeset
105 function(btn) {
2adc329d90fe Replaced Locations with Ortszuordnung
Dustin Demuth <dustin@intevation.de>
parents: 826
diff changeset
106 if (btn === 'yes') {
587
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
107 selection.destroy({
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
108 success: function() {
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
109 button.up('window').initData();
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
110 },
701
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 690
diff changeset
111 failure: function(request, response) {
1012
2adc329d90fe Replaced Locations with Ortszuordnung
Dustin Demuth <dustin@intevation.de>
parents: 826
diff changeset
112 var i18n = Lada.getApplication().bundle;
701
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 690
diff changeset
113 var json = response.request.scope.reader.jsonData;
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 690
diff changeset
114 if (json) {
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 690
diff changeset
115 if (json.message){
1012
2adc329d90fe Replaced Locations with Ortszuordnung
Dustin Demuth <dustin@intevation.de>
parents: 826
diff changeset
116 Ext.Msg.alert(i18n.getMsg('err.msg.delete.title')
701
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 690
diff changeset
117 +' #'+json.message,
1012
2adc329d90fe Replaced Locations with Ortszuordnung
Dustin Demuth <dustin@intevation.de>
parents: 826
diff changeset
118 i18n.getMsg(json.message));
701
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 690
diff changeset
119 } else {
1012
2adc329d90fe Replaced Locations with Ortszuordnung
Dustin Demuth <dustin@intevation.de>
parents: 826
diff changeset
120 Ext.Msg.alert(i18n.getMsg('err.msg.delete.title'),
2adc329d90fe Replaced Locations with Ortszuordnung
Dustin Demuth <dustin@intevation.de>
parents: 826
diff changeset
121 i18n.getMsg('err.msg.generic.body'));
701
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 690
diff changeset
122 }
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 690
diff changeset
123 } else {
1012
2adc329d90fe Replaced Locations with Ortszuordnung
Dustin Demuth <dustin@intevation.de>
parents: 826
diff changeset
124 Ext.Msg.alert(i18n.getMsg('err.msg.delete.title'),
2adc329d90fe Replaced Locations with Ortszuordnung
Dustin Demuth <dustin@intevation.de>
parents: 826
diff changeset
125 i18n.getMsg('err.msg.response.body'));
701
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 690
diff changeset
126 }
587
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
127 }
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
128 });
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
129 }
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
130 });
826
2362f8ab1e9f disable remove button after a item is deleted from grid
Dustin Demuth <dustin@intevation.de>
parents: 742
diff changeset
131 grid.down('button[action=delete]').disable();
1279
291df0037835 Ortszuordnung window: create, change and display (wip)
Maximilian Krambach <mkrambach@intevation.de>
parents: 1051
diff changeset
132 },
291df0037835 Ortszuordnung window: create, change and display (wip)
Maximilian Krambach <mkrambach@intevation.de>
parents: 1051
diff changeset
133
291df0037835 Ortszuordnung window: create, change and display (wip)
Maximilian Krambach <mkrambach@intevation.de>
parents: 1051
diff changeset
134 /**
291df0037835 Ortszuordnung window: create, change and display (wip)
Maximilian Krambach <mkrambach@intevation.de>
parents: 1051
diff changeset
135 * Opens the form for a new Messpunkt
291df0037835 Ortszuordnung window: create, change and display (wip)
Maximilian Krambach <mkrambach@intevation.de>
parents: 1051
diff changeset
136 */
291df0037835 Ortszuordnung window: create, change and display (wip)
Maximilian Krambach <mkrambach@intevation.de>
parents: 1051
diff changeset
137 createort: function() {
1287
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
138 Ext.create('Lada.view.form.Ortserstellung').show();
1279
291df0037835 Ortszuordnung window: create, change and display (wip)
Maximilian Krambach <mkrambach@intevation.de>
parents: 1051
diff changeset
139 },
291df0037835 Ortszuordnung window: create, change and display (wip)
Maximilian Krambach <mkrambach@intevation.de>
parents: 1051
diff changeset
140
291df0037835 Ortszuordnung window: create, change and display (wip)
Maximilian Krambach <mkrambach@intevation.de>
parents: 1051
diff changeset
141 /**
291df0037835 Ortszuordnung window: create, change and display (wip)
Maximilian Krambach <mkrambach@intevation.de>
parents: 1051
diff changeset
142 *
1287
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
143 * Opens the form for a new Messpunkt, with prefilled coordinates.
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
144 * TODO Not functional yet
1279
291df0037835 Ortszuordnung window: create, change and display (wip)
Maximilian Krambach <mkrambach@intevation.de>
parents: 1051
diff changeset
145 */
291df0037835 Ortszuordnung window: create, change and display (wip)
Maximilian Krambach <mkrambach@intevation.de>
parents: 1051
diff changeset
146 frommap: function(button) {
291df0037835 Ortszuordnung window: create, change and display (wip)
Maximilian Krambach <mkrambach@intevation.de>
parents: 1051
diff changeset
147 var map = button.up('ortszuordnungwindow').down('map');
1287
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
148 // map.getClick();
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
149 //TODO: wait for click return
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
150 Ext.create('Lada.view.form.Ortserstellung', {
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
151 presets: {
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
152 kda_id: 4,
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
153 koord_x_extern: 35000000, //TODO dummy values
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
154 koord_y_extern: 1000000
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
155 }
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
156 }).show();
1279
291df0037835 Ortszuordnung window: create, change and display (wip)
Maximilian Krambach <mkrambach@intevation.de>
parents: 1051
diff changeset
157 },
291df0037835 Ortszuordnung window: create, change and display (wip)
Maximilian Krambach <mkrambach@intevation.de>
parents: 1051
diff changeset
158
291df0037835 Ortszuordnung window: create, change and display (wip)
Maximilian Krambach <mkrambach@intevation.de>
parents: 1051
diff changeset
159 /**
291df0037835 Ortszuordnung window: create, change and display (wip)
Maximilian Krambach <mkrambach@intevation.de>
parents: 1051
diff changeset
160 * Opens the form for a new Messpunkt, with all values prefilled from the currently
291df0037835 Ortszuordnung window: create, change and display (wip)
Maximilian Krambach <mkrambach@intevation.de>
parents: 1051
diff changeset
161 * selected item
291df0037835 Ortszuordnung window: create, change and display (wip)
Maximilian Krambach <mkrambach@intevation.de>
parents: 1051
diff changeset
162 */
291df0037835 Ortszuordnung window: create, change and display (wip)
Maximilian Krambach <mkrambach@intevation.de>
parents: 1051
diff changeset
163 cloneort: function(button) {
291df0037835 Ortszuordnung window: create, change and display (wip)
Maximilian Krambach <mkrambach@intevation.de>
parents: 1051
diff changeset
164 var grid = button.up('ortszuordnungwindow').down('ortstammdatengrid').getView();
291df0037835 Ortszuordnung window: create, change and display (wip)
Maximilian Krambach <mkrambach@intevation.de>
parents: 1051
diff changeset
165 var selected = grid.getSelectionModel().getSelection()[0];
1287
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
166 Ext.create('Lada.view.form.Ortserstellung', {
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
167 presets: selected.data
1284
faecbb446a04 Ortserstellung: new Messpunkt from map, clone or form
Maximilian Krambach <mkrambach@intevation.de>
parents: 1279
diff changeset
168 }).show();
faecbb446a04 Ortserstellung: new Messpunkt from map, clone or form
Maximilian Krambach <mkrambach@intevation.de>
parents: 1279
diff changeset
169 },
faecbb446a04 Ortserstellung: new Messpunkt from map, clone or form
Maximilian Krambach <mkrambach@intevation.de>
parents: 1279
diff changeset
170
faecbb446a04 Ortserstellung: new Messpunkt from map, clone or form
Maximilian Krambach <mkrambach@intevation.de>
parents: 1279
diff changeset
171 /**
1287
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
172 * Search triggered by textfield key event.
1284
faecbb446a04 Ortserstellung: new Messpunkt from map, clone or form
Maximilian Krambach <mkrambach@intevation.de>
parents: 1279
diff changeset
173 */
1287
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
174 search: function(field, evt, opts) {
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
175 this.searchField = field;
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
176 if ((evt.getKey() == 13 || evt.getKey() == 8) && field.getValue() && field.getValue().length > 0) {
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
177 this.execSearch(field, field.getValue());
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
178 }
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
179 if (field.getValue().length === 0) {
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
180 this.resultPanel.hide();
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
181 return;
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
182 }
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
183 if (field.getValue().length < 3) {
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
184 return;
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
185 }
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
186 this.execSearch(field, field.getValue());
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
187 },
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
188
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
189 /*
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
190 * Execute search in stores (ort, verwaltungseinheit and staat) and
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
191 * display the resultset.
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
192 */
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
193 execSearch: function(field, filter) {
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
194 // Filter stores
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
195 var messpunkte = Ext.data.StoreManager.get('orte');
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
196 var verwaltungseinheiten = Ext.data.StoreManager.get('verwaltungseinheiten');
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
197 var staaten = Ext.data.StoreManager.get('staaten');
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
198 messpunkte.clearFilter(true);
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
199 verwaltungseinheiten.clearFilter(true);
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
200 staaten.clearFilter(true);
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
201 messpunkte.filter({filterFn: function(item) {
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
202 if (item.get('ortId').indexOf(filter) > -1) {
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
203 return true;
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
204 }
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
205 if (item.get('kurztext').indexOf(filter) > -1) {
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
206 return true;
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
207 }
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
208 if (item.get('langtext').indexOf(filter) > -1) {
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
209 return true;
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
210 }
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
211 if (item.get('berichtstext') &&
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
212 item.get('berichtstext').indexOf(filter) > -1) {
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
213 return true;
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
214 }
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
215 if (item.get('gemId').indexOf(filter) > -1) {
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
216 return true;
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
217 }
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
218 }});
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
219 verwaltungseinheiten.filter('bezeichnung', filter);
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
220 staaten.filter('staat', filter);
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
221
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
222 if (!this.resultPanel) {
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
223 this.resultPanel = Ext.create('Lada.view.window.OrtFilter', {
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
224 x: 500,
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
225 y: 500,
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
226 alwaysOnTop: true
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
227 });
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
228 }
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
229 this.resultPanel.show();
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
230 this.resultPanel.updateGrids(messpunkte, verwaltungseinheiten, staaten);
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
231 this.resultPanel.reposition(field.getX() + field.getLabelWidth(), field.getY());
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
232 field.focus();
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
233 },
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
234
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
235 selectedMesspunkt: function(grid, record) {
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
236 var win = grid.up('window');
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
237 win.hide();
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
238 this.searchField.reset();
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
239 var grid = this.searchField.up('panel').down('ortstammdatengrid');
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
240 grid.getSelectionModel().select(record);
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
241 grid.getView().focusRow(record);
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
242 console.log(record);
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
243 },
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
244
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
245 selectedVerwaltungseinheit: function(grid, record) {
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
246 var win = grid.up('window');
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
247 win.hide();
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
248 this.searchField.reset();
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
249 console.log(record);
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
250 },
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
251
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
252 selectedStaat: function(grid, record) {
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
253 var win = grid.up('window');
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
254 win.hide();
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
255 this.searchField.reset();
e317ba349204 Added search for orte, verwaltungseinheiten and staaten.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1284
diff changeset
256 console.log(record);
587
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
257 }
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
258 });

http://lada.wald.intevation.org