Mercurial > lada > lada-client
annotate app/controller/form/Messung.js @ 715:605bc34b45a0
Disable the Fertig-Flag Checkbox in a Messung when the User is not the owner. Do not enable Form-Children when readonly is set to true. Parse login-response in app.js
author | Dustin Demuth <dustin@intevation.de> |
---|---|
date | Wed, 08 Apr 2015 15:28:25 +0200 |
parents | 2e478b3a587a |
children | c2a6f7caa71b |
rev | line source |
---|---|
611
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
1 /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz |
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
2 * Software engineering by Intevation GmbH |
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
3 * |
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
4 * This file is Free Software under the GNU GPL (v>=3) |
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out |
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
6 * the documentation coming with IMIS-Labordaten-Application for details. |
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
7 */ |
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
8 |
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
9 Ext.define('Lada.controller.form.Messung', { |
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
10 extend: 'Ext.app.Controller', |
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
11 |
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
12 init: function() { |
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
13 this.control({ |
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
14 'messungform button[action=save]': { |
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
15 click: this.save |
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
16 }, |
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
17 'messungform button[action=discard]': { |
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
18 click: this.discard |
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
19 }, |
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
20 'messungform': { |
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
21 dirtychange: this.dirtyForm |
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
22 } |
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
23 }); |
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
24 }, |
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
25 |
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
26 save: function(button) { |
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
27 var formPanel = button.up('form'); |
713
2e478b3a587a
Set some loading masks.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
712
diff
changeset
|
28 formPanel.setLoading(true); |
611
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
29 var data = formPanel.getForm().getFieldValues(true); |
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
30 for (var key in data) { |
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
31 formPanel.getForm().getRecord().set(key, data[key]); |
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
32 } |
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
33 formPanel.getForm().getRecord().save({ |
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
34 success: function(record, response) { |
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
35 var json = Ext.decode(response.response.responseText); |
622
ee92e352be20
Open messung create window on button click.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
611
diff
changeset
|
36 if (json) { |
611
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
37 button.setDisabled(true); |
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
38 button.up('toolbar').down('button[action=discard]') |
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
39 .setDisabled(true); |
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
40 formPanel.clearMessages(); |
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
41 formPanel.setRecord(record); |
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
42 formPanel.setMessages(json.errors, json.warnings); |
710
f204f30b824a
Handle readonly mode and refresh operations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
701
diff
changeset
|
43 formPanel.up('window').initData(); |
644
71e8b84d7829
Reload grids on messung or ort changed/added.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
639
diff
changeset
|
44 formPanel.up('window').grid.store.reload(); |
710
f204f30b824a
Handle readonly mode and refresh operations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
701
diff
changeset
|
45 var parentWin = button.up('window').grid.up('window'); |
f204f30b824a
Handle readonly mode and refresh operations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
701
diff
changeset
|
46 parentWin.initData(); |
639
fdaabab6f4cc
Open Probe-/Messung-Edit window automatically if a new item was saved
Raimund Renkert <raimund.renkert@intevation.de>
parents:
622
diff
changeset
|
47 if (response.action === 'create' && json.success) { |
710
f204f30b824a
Handle readonly mode and refresh operations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
701
diff
changeset
|
48 var oldWin = button.up('window'); |
f204f30b824a
Handle readonly mode and refresh operations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
701
diff
changeset
|
49 var probe = oldWin.record; |
f204f30b824a
Handle readonly mode and refresh operations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
701
diff
changeset
|
50 oldWin.close(); |
639
fdaabab6f4cc
Open Probe-/Messung-Edit window automatically if a new item was saved
Raimund Renkert <raimund.renkert@intevation.de>
parents:
622
diff
changeset
|
51 var win = Ext.create('Lada.view.window.MessungEdit', { |
710
f204f30b824a
Handle readonly mode and refresh operations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
701
diff
changeset
|
52 probe: probe, |
f204f30b824a
Handle readonly mode and refresh operations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
701
diff
changeset
|
53 parentWindow: parentWin, |
f204f30b824a
Handle readonly mode and refresh operations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
701
diff
changeset
|
54 grid: oldWin.grid, |
639
fdaabab6f4cc
Open Probe-/Messung-Edit window automatically if a new item was saved
Raimund Renkert <raimund.renkert@intevation.de>
parents:
622
diff
changeset
|
55 record: record |
fdaabab6f4cc
Open Probe-/Messung-Edit window automatically if a new item was saved
Raimund Renkert <raimund.renkert@intevation.de>
parents:
622
diff
changeset
|
56 }); |
fdaabab6f4cc
Open Probe-/Messung-Edit window automatically if a new item was saved
Raimund Renkert <raimund.renkert@intevation.de>
parents:
622
diff
changeset
|
57 win.show(); |
fdaabab6f4cc
Open Probe-/Messung-Edit window automatically if a new item was saved
Raimund Renkert <raimund.renkert@intevation.de>
parents:
622
diff
changeset
|
58 win.initData(); |
fdaabab6f4cc
Open Probe-/Messung-Edit window automatically if a new item was saved
Raimund Renkert <raimund.renkert@intevation.de>
parents:
622
diff
changeset
|
59 } |
611
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
60 } |
713
2e478b3a587a
Set some loading masks.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
712
diff
changeset
|
61 formPanel.setLoading(false); |
611
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
62 }, |
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
63 failure: function(record, response) { |
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
64 button.setDisabled(true); |
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
65 button.up('toolbar').down('button[action=discard]') |
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
66 .setDisabled(true); |
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
67 formPanel.getForm().loadRecord(formPanel.getForm().getRecord()); |
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
68 var json = response.request.scope.reader.jsonData; |
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
69 if (json) { |
712 | 70 if (json.errors.totalCount > 0 || json.warnings.totalCount > 0) { |
693 | 71 formPanel.setMessages(json.errors, json.warnings); |
72 } | |
73 | |
712 | 74 if (json.message) { |
701
f0bc5387abcc
Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents:
695
diff
changeset
|
75 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.save.title') |
712 | 76 + ' #' + json.message, |
695
d6ef146e1a9f
Added simple handling for Failure-Messages
Dustin Demuth <dustin@intevation.de>
parents:
693
diff
changeset
|
77 Lada.getApplication().bundle.getMsg(json.message)); |
712 | 78 } |
79 else { | |
701
f0bc5387abcc
Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents:
695
diff
changeset
|
80 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.save.title'), |
f0bc5387abcc
Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents:
695
diff
changeset
|
81 Lada.getApplication().bundle.getMsg('err.msg.generic.body')); |
693 | 82 } |
712 | 83 } |
84 else { | |
701
f0bc5387abcc
Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents:
695
diff
changeset
|
85 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.save.title'), |
f0bc5387abcc
Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents:
695
diff
changeset
|
86 Lada.getApplication().bundle.getMsg('err.msg.response.body')); |
611
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
87 } |
713
2e478b3a587a
Set some loading masks.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
712
diff
changeset
|
88 formPanel.setLoading(false); |
611
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
89 } |
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
90 }); |
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
91 }, |
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
92 |
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
93 discard: function(button) { |
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
94 var formPanel = button.up('form'); |
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
95 formPanel.getForm().loadRecord(formPanel.getForm().getRecord()); |
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
96 }, |
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
97 |
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
98 dirtyForm: function(form, dirty) { |
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
99 if (dirty) { |
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
100 form.owner.down('button[action=save]').setDisabled(false); |
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
101 form.owner.down('button[action=discard]').setDisabled(false); |
687
aedf0709af92
Applied ReadOnlyParadigm to a Messung Window
Dustin Demuth <dustin@intevation.de>
parents:
644
diff
changeset
|
102 form.owner.up('window').disableChildren(); |
611
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
103 } |
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
104 else { |
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
105 form.owner.down('button[action=save]').setDisabled(true); |
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
106 form.owner.down('button[action=discard]').setDisabled(true); |
715
605bc34b45a0
Disable the Fertig-Flag Checkbox in a Messung when the User is not the owner. Do not enable Form-Children when readonly is set to true. Parse login-response in app.js
Dustin Demuth <dustin@intevation.de>
parents:
713
diff
changeset
|
107 //Only enable children if the form was not readOnly |
605bc34b45a0
Disable the Fertig-Flag Checkbox in a Messung when the User is not the owner. Do not enable Form-Children when readonly is set to true. Parse login-response in app.js
Dustin Demuth <dustin@intevation.de>
parents:
713
diff
changeset
|
108 if (!form.getRecord().get('readonly')) { |
605bc34b45a0
Disable the Fertig-Flag Checkbox in a Messung when the User is not the owner. Do not enable Form-Children when readonly is set to true. Parse login-response in app.js
Dustin Demuth <dustin@intevation.de>
parents:
713
diff
changeset
|
109 form.owner.up('window').enableChildren(); |
605bc34b45a0
Disable the Fertig-Flag Checkbox in a Messung when the User is not the owner. Do not enable Form-Children when readonly is set to true. Parse login-response in app.js
Dustin Demuth <dustin@intevation.de>
parents:
713
diff
changeset
|
110 } |
611
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
111 } |
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
112 } |
8a156a7fbe67
added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
113 }); |