Mercurial > lada > lada-client
annotate app/view/window/GenProbenFromMessprogramm.js @ 1204:95d24315d68e
Improve readability.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Fri, 30 Sep 2016 10:36:47 +0200 |
parents | 39d98891881c |
children | 613e48a3fef9 |
rev | line source |
---|---|
760
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
1 /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz |
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
2 * Software engineering by Intevation GmbH |
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
3 * |
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
4 * This file is Free Software under the GNU GPL (v>=3) |
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out |
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
6 * the documentation coming with IMIS-Labordaten-Application for details. |
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
7 */ |
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
8 |
891 | 9 /** |
760
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
10 * Window to generate Proben from a Messprogramm |
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
11 */ |
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
12 Ext.define('Lada.view.window.GenProbenFromMessprogramm', { |
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
13 extend: 'Ext.window.Window', |
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
14 alias: 'widget.genpfm', |
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
15 |
1195
39d98891881c
Add missing requirement.
Tom Gottfried <tom@intevation.de>
parents:
1191
diff
changeset
|
16 requires: [ |
39d98891881c
Add missing requirement.
Tom Gottfried <tom@intevation.de>
parents:
1191
diff
changeset
|
17 'Lada.store.Proben' |
39d98891881c
Add missing requirement.
Tom Gottfried <tom@intevation.de>
parents:
1191
diff
changeset
|
18 ], |
39d98891881c
Add missing requirement.
Tom Gottfried <tom@intevation.de>
parents:
1191
diff
changeset
|
19 |
760
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
20 collapsible: true, |
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
21 maximizable: true, |
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
22 autoShow: true, |
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
23 autoScroll: true, |
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
24 layout: 'fit', |
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
25 constrain: true, |
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
26 |
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
27 record: null, |
818
097d4edc2f00
Genprobenwindow can only be created once, also fixed messprogrammortewindow 'close with x and can not reopen' bug
Dustin Demuth <dustin@intevation.de>
parents:
812
diff
changeset
|
28 parentWindow: null, |
760
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
29 |
890
def27cdd0dfa
Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents:
882
diff
changeset
|
30 /** |
def27cdd0dfa
Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents:
882
diff
changeset
|
31 * This function initialises the Window |
def27cdd0dfa
Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents:
882
diff
changeset
|
32 */ |
760
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
33 initComponent: function() { |
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
34 var i18n = Lada.getApplication().bundle; |
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
35 |
818
097d4edc2f00
Genprobenwindow can only be created once, also fixed messprogrammortewindow 'close with x and can not reopen' bug
Dustin Demuth <dustin@intevation.de>
parents:
812
diff
changeset
|
36 // add listeners to change the window appearence when it becomes inactive |
097d4edc2f00
Genprobenwindow can only be created once, also fixed messprogrammortewindow 'close with x and can not reopen' bug
Dustin Demuth <dustin@intevation.de>
parents:
812
diff
changeset
|
37 this.on({ |
097d4edc2f00
Genprobenwindow can only be created once, also fixed messprogrammortewindow 'close with x and can not reopen' bug
Dustin Demuth <dustin@intevation.de>
parents:
812
diff
changeset
|
38 activate: function(){ |
097d4edc2f00
Genprobenwindow can only be created once, also fixed messprogrammortewindow 'close with x and can not reopen' bug
Dustin Demuth <dustin@intevation.de>
parents:
812
diff
changeset
|
39 this.getEl().removeCls('window-inactive'); |
097d4edc2f00
Genprobenwindow can only be created once, also fixed messprogrammortewindow 'close with x and can not reopen' bug
Dustin Demuth <dustin@intevation.de>
parents:
812
diff
changeset
|
40 }, |
097d4edc2f00
Genprobenwindow can only be created once, also fixed messprogrammortewindow 'close with x and can not reopen' bug
Dustin Demuth <dustin@intevation.de>
parents:
812
diff
changeset
|
41 deactivate: function(){ |
097d4edc2f00
Genprobenwindow can only be created once, also fixed messprogrammortewindow 'close with x and can not reopen' bug
Dustin Demuth <dustin@intevation.de>
parents:
812
diff
changeset
|
42 this.getEl().addCls('window-inactive'); |
097d4edc2f00
Genprobenwindow can only be created once, also fixed messprogrammortewindow 'close with x and can not reopen' bug
Dustin Demuth <dustin@intevation.de>
parents:
812
diff
changeset
|
43 } |
097d4edc2f00
Genprobenwindow can only be created once, also fixed messprogrammortewindow 'close with x and can not reopen' bug
Dustin Demuth <dustin@intevation.de>
parents:
812
diff
changeset
|
44 }); |
097d4edc2f00
Genprobenwindow can only be created once, also fixed messprogrammortewindow 'close with x and can not reopen' bug
Dustin Demuth <dustin@intevation.de>
parents:
812
diff
changeset
|
45 |
760
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
46 this.title = i18n.getMsg('gpfm.window.title'); |
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
47 var me = this; |
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
48 this.buttons = [{ |
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
49 text: i18n.getMsg('cancel'), |
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
50 scope: this, |
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
51 handler: this.close |
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
52 }, { |
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
53 text: i18n.getMsg('generateproben'), |
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
54 handler: function() { |
1191
62f374ea7ab7
Use UTC date in messprogramm to generate probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1162
diff
changeset
|
55 var startDate = new Date(me.down('datefield[name=start]').getValue()); |
62f374ea7ab7
Use UTC date in messprogramm to generate probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1162
diff
changeset
|
56 var startUTC = Date.UTC( |
62f374ea7ab7
Use UTC date in messprogramm to generate probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1162
diff
changeset
|
57 startDate.getFullYear(), startDate.getMonth(), startDate.getDate()); |
62f374ea7ab7
Use UTC date in messprogramm to generate probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1162
diff
changeset
|
58 var endDate = new Date(me.down('datefield[name=end]').getValue()); |
62f374ea7ab7
Use UTC date in messprogramm to generate probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1162
diff
changeset
|
59 var endUTC = Date.UTC( |
62f374ea7ab7
Use UTC date in messprogramm to generate probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1162
diff
changeset
|
60 endDate.getFullYear(), endDate.getMonth(), endDate.getDate()); |
760
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
61 var jsondata = { |
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
62 id: me.record.id, |
1191
62f374ea7ab7
Use UTC date in messprogramm to generate probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1162
diff
changeset
|
63 start: startUTC, |
62f374ea7ab7
Use UTC date in messprogramm to generate probe objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1162
diff
changeset
|
64 end: endUTC |
760
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
65 }; |
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
66 |
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
67 Ext.Ajax.request({ |
999 | 68 url: 'lada-server/rest/probe/messprogramm', |
760
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
69 method: 'POST', |
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
70 jsonData: jsondata, |
1204 | 71 success: me.onSuccess, |
72 failure: me.onFailure, | |
760
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
73 }); |
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
74 } |
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
75 }]; |
834
2214aea9fd3a
Patched correct file of r. 832
Dustin Demuth <dustin@intevation.de>
parents:
833
diff
changeset
|
76 this.width = 350; |
2214aea9fd3a
Patched correct file of r. 832
Dustin Demuth <dustin@intevation.de>
parents:
833
diff
changeset
|
77 this.height = 250; |
760
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
78 |
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
79 // add listeners to change the window appearence when it becomes inactive |
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
80 this.on({ |
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
81 activate: function(){ |
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
82 this.getEl().removeCls('window-inactive'); |
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
83 }, |
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
84 deactivate: function(){ |
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
85 this.getEl().addCls('window-inactive'); |
818
097d4edc2f00
Genprobenwindow can only be created once, also fixed messprogrammortewindow 'close with x and can not reopen' bug
Dustin Demuth <dustin@intevation.de>
parents:
812
diff
changeset
|
86 }, |
097d4edc2f00
Genprobenwindow can only be created once, also fixed messprogrammortewindow 'close with x and can not reopen' bug
Dustin Demuth <dustin@intevation.de>
parents:
812
diff
changeset
|
87 close: function () { |
860
03f39ddae596
Restructured Filterresultgrid button-dock, added button to generate Proben from a selection of messprogramme.
Dustin Demuth <dustin@intevation.de>
parents:
855
diff
changeset
|
88 if (this.parentWindow) { |
03f39ddae596
Restructured Filterresultgrid button-dock, added button to generate Proben from a selection of messprogramme.
Dustin Demuth <dustin@intevation.de>
parents:
855
diff
changeset
|
89 this.parentWindow.probenWindow = null; |
03f39ddae596
Restructured Filterresultgrid button-dock, added button to generate Proben from a selection of messprogramme.
Dustin Demuth <dustin@intevation.de>
parents:
855
diff
changeset
|
90 } |
760
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
91 } |
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
92 }); |
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
93 |
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
94 // InitialConfig is the config object passed to the constructor on |
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
95 // creation of this window. We need to pass it throuh to the form as |
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
96 // we need the "Id" param to load the correct item. |
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
97 this.items = [{ |
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
98 border: 0, |
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
99 autoScroll: true, |
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
100 items: [{ |
807 | 101 xtype: 'panel', |
102 border: 0, | |
103 margin: 5, | |
104 layout: 'fit', | |
105 html: '<p>' | |
106 + i18n.getMsg('nameofmessprogramm') | |
107 + '<br/>' | |
108 + this.record.get('name') | |
109 + '</p>' | |
760
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
110 }, { |
807 | 111 xtype: 'panel', |
112 border: 0, | |
113 margin: 5, | |
114 layout: 'fit', | |
115 html: '<p>' + i18n.getMsg('messprogtimeperiod') + '</p>' | |
760
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
116 }, { |
1105
953b359748bb
change time range format in GenProbenFromMessprogramm
Michael Stanko <mstanko@bfs.de>
parents:
999
diff
changeset
|
117 xtype: 'datefield', |
760
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
118 fieldLabel: i18n.getMsg('from'), |
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
119 labelWidth: 90, |
807 | 120 margin: 5, |
1105
953b359748bb
change time range format in GenProbenFromMessprogramm
Michael Stanko <mstanko@bfs.de>
parents:
999
diff
changeset
|
121 width: 200, |
760
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
122 name: 'start', |
1105
953b359748bb
change time range format in GenProbenFromMessprogramm
Michael Stanko <mstanko@bfs.de>
parents:
999
diff
changeset
|
123 format: 'd.m.Y', |
760
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
124 period: 'start' |
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
125 }, { |
1105
953b359748bb
change time range format in GenProbenFromMessprogramm
Michael Stanko <mstanko@bfs.de>
parents:
999
diff
changeset
|
126 xtype: 'datefield', |
760
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
127 fieldLabel: i18n.getMsg('to'), |
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
128 labelWidth: 90, |
807 | 129 margin: 5, |
1105
953b359748bb
change time range format in GenProbenFromMessprogramm
Michael Stanko <mstanko@bfs.de>
parents:
999
diff
changeset
|
130 width: 200, |
760
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
131 name: 'end', |
1105
953b359748bb
change time range format in GenProbenFromMessprogramm
Michael Stanko <mstanko@bfs.de>
parents:
999
diff
changeset
|
132 format: 'd.m.Y', |
760
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
133 period: 'end' |
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
134 }] |
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
135 }]; |
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
136 this.callParent(arguments); |
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
137 }, |
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
138 |
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
139 /** |
1204 | 140 * Callback on success of request (HTTP status 200) |
141 */ | |
142 onSuccess: function(response) { | |
143 var i18n = Lada.getApplication().bundle; | |
144 | |
145 var json = Ext.JSON.decode(response.responseText); | |
146 var radio = Ext.ComponentQuery.query('modeswitcher')[0] | |
147 .down('radiofield[inputValue=proben]'); | |
148 radio.setValue(true); | |
149 | |
150 var contentPanel = Ext.ComponentQuery.query('panel[name=main]')[0] | |
151 .down('panel[name=contentpanel]'); | |
152 contentPanel.removeAll(); //clear the panel: make space for new grids | |
153 var gridstore = Ext.create('Lada.store.Proben'); | |
154 var frgrid = Ext.create('Lada.view.grid.ProbeList', { | |
155 plugins: [{ | |
156 ptype: 'gridrowexpander', | |
157 gridType: 'Lada.view.grid.Messung', | |
158 expandOnDblClick: false, | |
159 gridConfig: { | |
160 bottomBar: false | |
161 } | |
162 }] | |
163 }); | |
164 | |
165 var columns = [{ | |
166 header: i18n.getMsg('prnId'), | |
167 dataIndex: 'probeIdAlt' | |
168 }, { | |
169 header: i18n.getMsg('netzbetreiberId'), | |
170 dataIndex: 'netzbetreiberId', | |
171 renderer: function(value) { | |
172 var r = ''; | |
173 if (!value || value === '') { | |
174 r = 'Error'; | |
175 } | |
176 var store = Ext.data.StoreManager.get('netzbetreiber'); | |
177 var record = store.getById(value); | |
178 if (record) { | |
179 r = record.get('netzbetreiber'); | |
180 } | |
181 return r; | |
182 } | |
183 }, { | |
184 header: i18n.getMsg('mstId'), | |
185 dataIndex: 'mstId', | |
186 renderer: function(value) { | |
187 var r = ''; | |
188 if (!value || value === '') { | |
189 r = 'Error'; | |
190 } | |
191 var store = Ext.data.StoreManager.get('messstellen'); | |
192 var record = store.getById(value); | |
193 if (record) { | |
194 r = record.get('messStelle'); | |
195 } | |
196 return r; | |
197 } | |
198 }, { | |
199 header: i18n.getMsg('datenbasisId'), | |
200 dataIndex: 'datenbasisId', | |
201 renderer: function(value) { | |
202 var r = ''; | |
203 if (!value || value === '') { | |
204 r = value; | |
205 } | |
206 var store = Ext.data.StoreManager.get('datenbasis'); | |
207 var record = store.getById(value); | |
208 if (record) { | |
209 r = record.get('datenbasis'); | |
210 } | |
211 return r; | |
212 } | |
213 }, { | |
214 header: i18n.getMsg('baId'), | |
215 dataIndex: 'baId', | |
216 renderer: function(value) { | |
217 var r = ''; | |
218 if (!value || value === '') { | |
219 r = ''; | |
220 } | |
221 var store = Ext.create('Ext.data.Store', { | |
222 fields: ['betriebsartId', 'betriebsart'], | |
223 data: [{ | |
224 'betriebsartId': '1', | |
225 'betriebsart': 'Normal-/Routinebetrieb' | |
226 }, { | |
227 'betriebsartId': '2', | |
228 'betriebsart': 'Störfall/Intensivbetrieb' | |
229 }] | |
230 }); | |
231 var record = store.getById(value); | |
232 if (record) { | |
233 r = record.get('betriebsart'); | |
234 } | |
235 return r; | |
236 } | |
237 }, { | |
238 header: i18n.getMsg('probenartId'), | |
239 dataIndex: 'probenartId', | |
240 renderer: function(value) { | |
241 var r = ''; | |
242 if (!value || value === '') { | |
243 r = value; | |
244 } | |
245 var store = Ext.data.StoreManager.get('probenarten'); | |
246 var record = store.getById(value); | |
247 if (record) { | |
248 r = record.get('probenart'); | |
249 } | |
250 return r; | |
251 } | |
252 }, { | |
253 header: i18n.getMsg('sollVon'), | |
254 dataIndex: 'solldatumBeginn', | |
255 renderer: function(value) { | |
256 if (!value) { | |
257 return ''; | |
258 } | |
259 return Ext.Date.format(value, 'd.m.Y'); | |
260 } | |
261 }, { | |
262 header: i18n.getMsg('sollBis'), | |
263 dataIndex: 'solldatumEnde', | |
264 renderer: function(value) { | |
265 if (!value) { | |
266 return ''; | |
267 } | |
268 return Ext.Date.format(value, 'd.m.Y'); | |
269 } | |
270 }]; | |
271 frgrid.reconfigure(gridstore, columns); | |
272 | |
273 gridstore.loadData(json.data); | |
274 contentPanel.add(frgrid); | |
275 Ext.Msg.show({ | |
276 title: i18n.getMsg('success'), | |
277 autoScroll: true, | |
278 msg: me.evalResponse(json), | |
279 buttons: Ext.Msg.OK | |
280 }); | |
281 me.close(); | |
282 }, | |
283 | |
284 /** | |
285 * Callback on failure of request (HTTP status != 200) | |
286 */ | |
287 onFailure: function(response) { | |
288 var i18n = Lada.getApplication().bundle; | |
289 | |
290 var json = null; | |
291 try { | |
292 json = Ext.JSON.decode(response.responseText); | |
293 } | |
294 catch(err){ | |
295 Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'), | |
296 i18n.getMsg('err.msg.response.body')); | |
297 } | |
298 if (json) { | |
299 if(json.errors.totalCount > 0 || json.warnings.totalCount > 0){ | |
300 formPanel.setMessages(json.errors, json.warnings); | |
301 } | |
302 /* | |
303 SSO will send a 302 if the Client is not authenticated | |
304 unfortunately this seems to be filtered by the browser. | |
305 We assume that a 302 was send when the follwing statement | |
306 is true. | |
307 */ | |
308 if (response.status == 0 && response.responseText === "") { | |
309 Ext.MessageBox.confirm( | |
310 'Erneutes Login erforderlich', | |
311 'Ihre Session ist abgelaufen.<br/>' | |
312 + 'Für ein erneutes Login muss die Anwendung ' | |
313 + 'neu geladen werden.<br/>' | |
314 + 'Alle ungesicherten Daten gehen dabei verloren.<br/>' | |
315 + 'Soll die Anwendung jetzt neu geladen werden?', | |
316 this.reload); | |
317 } | |
318 // further error handling | |
319 if(json.message){ | |
320 Ext.Msg.alert(i18n.getMsg('err.msg.generic.title') | |
321 +' #'+json.message, | |
322 i18n.getMsg(json.message)); | |
323 } else { | |
324 Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'), | |
325 i18n.getMsg('err.msg.generic.body')); | |
326 } | |
327 } else { | |
328 Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'), | |
329 i18n.getMsg('err.msg.response.body')); | |
330 } | |
331 }, | |
332 | |
333 | |
334 /** | |
890
def27cdd0dfa
Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents:
882
diff
changeset
|
335 * Initiatlise the Data |
760
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
336 */ |
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
337 initData: function() { |
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
338 var i18n = Lada.getApplication().bundle; |
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
339 me = this; |
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
340 }, |
809
3bc19188fc3a
Added some todos, Enhanced Proge-Generation Success Msg.
Dustin Demuth <dustin@intevation.de>
parents:
807
diff
changeset
|
341 |
3bc19188fc3a
Added some todos, Enhanced Proge-Generation Success Msg.
Dustin Demuth <dustin@intevation.de>
parents:
807
diff
changeset
|
342 /** |
3bc19188fc3a
Added some todos, Enhanced Proge-Generation Success Msg.
Dustin Demuth <dustin@intevation.de>
parents:
807
diff
changeset
|
343 * Parse ServerResponse when Proben have been generated |
3bc19188fc3a
Added some todos, Enhanced Proge-Generation Success Msg.
Dustin Demuth <dustin@intevation.de>
parents:
807
diff
changeset
|
344 */ |
3bc19188fc3a
Added some todos, Enhanced Proge-Generation Success Msg.
Dustin Demuth <dustin@intevation.de>
parents:
807
diff
changeset
|
345 evalResponse: function(response) { |
3bc19188fc3a
Added some todos, Enhanced Proge-Generation Success Msg.
Dustin Demuth <dustin@intevation.de>
parents:
807
diff
changeset
|
346 var i18n = Lada.getApplication().bundle; |
3bc19188fc3a
Added some todos, Enhanced Proge-Generation Success Msg.
Dustin Demuth <dustin@intevation.de>
parents:
807
diff
changeset
|
347 var r = ''; |
812
188a9faf96e0
Added Errorhandling for AJAX-Requests, especially Authentication Issues.
Dustin Demuth <dustin@intevation.de>
parents:
809
diff
changeset
|
348 r += response.data.length; |
809
3bc19188fc3a
Added some todos, Enhanced Proge-Generation Success Msg.
Dustin Demuth <dustin@intevation.de>
parents:
807
diff
changeset
|
349 r += ' ' + i18n.getMsg('probecreated'); |
3bc19188fc3a
Added some todos, Enhanced Proge-Generation Success Msg.
Dustin Demuth <dustin@intevation.de>
parents:
807
diff
changeset
|
350 r += '<br/>'; |
3bc19188fc3a
Added some todos, Enhanced Proge-Generation Success Msg.
Dustin Demuth <dustin@intevation.de>
parents:
807
diff
changeset
|
351 return r; |
812
188a9faf96e0
Added Errorhandling for AJAX-Requests, especially Authentication Issues.
Dustin Demuth <dustin@intevation.de>
parents:
809
diff
changeset
|
352 }, |
188a9faf96e0
Added Errorhandling for AJAX-Requests, especially Authentication Issues.
Dustin Demuth <dustin@intevation.de>
parents:
809
diff
changeset
|
353 |
890
def27cdd0dfa
Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents:
882
diff
changeset
|
354 /** |
def27cdd0dfa
Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents:
882
diff
changeset
|
355 * Reload the Application |
def27cdd0dfa
Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents:
882
diff
changeset
|
356 */ |
812
188a9faf96e0
Added Errorhandling for AJAX-Requests, especially Authentication Issues.
Dustin Demuth <dustin@intevation.de>
parents:
809
diff
changeset
|
357 reload: function(btn) { |
188a9faf96e0
Added Errorhandling for AJAX-Requests, especially Authentication Issues.
Dustin Demuth <dustin@intevation.de>
parents:
809
diff
changeset
|
358 if (btn === 'yes') { |
188a9faf96e0
Added Errorhandling for AJAX-Requests, especially Authentication Issues.
Dustin Demuth <dustin@intevation.de>
parents:
809
diff
changeset
|
359 location.reload(); |
188a9faf96e0
Added Errorhandling for AJAX-Requests, especially Authentication Issues.
Dustin Demuth <dustin@intevation.de>
parents:
809
diff
changeset
|
360 } |
809
3bc19188fc3a
Added some todos, Enhanced Proge-Generation Success Msg.
Dustin Demuth <dustin@intevation.de>
parents:
807
diff
changeset
|
361 } |
760
2e7e1a8bf79f
Added a Window and Buttons to generate Proben from a Messprogramm
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
362 }); |