annotate app/controller/form/Probe.js @ 664:6fe3cef53e74

Field Validity in MKommentar Grid
author Dustin Demuth <dustin@intevation.de>
date Thu, 19 Mar 2015 11:25:38 +0100
parents fdaabab6f4cc
children a24db43b13b5
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
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
9 Ext.define('Lada.controller.form.Probe', {
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
10 extend: 'Ext.app.Controller',
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
11
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
12 init: function() {
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
13 this.control({
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
14 'probeform button[action=save]': {
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
15 click: this.save
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
16 },
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
17 'probeform button[action=discard]': {
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
18 click: this.discard
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
19 },
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
20 'probeform': {
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
21 dirtychange: this.dirtyForm
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
22 }
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
23 });
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
24 },
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
25
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
26 save: function(button) {
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
27 var formPanel = button.up('form');
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
28 var data = formPanel.getForm().getFieldValues(true);
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
29 for (var key in data) {
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
30 formPanel.getForm().getRecord().set(key, data[key]);
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
31 }
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
32 formPanel.getForm().getRecord().save({
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
33 success: function(record, response) {
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
34 var json = Ext.decode(response.response.responseText);
620
e0b966b32163 Open probe create window on button click.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 587
diff changeset
35 if (json) {
587
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
36 button.setDisabled(true);
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
37 button.up('toolbar').down('button[action=discard]')
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
38 .setDisabled(true);
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
39 formPanel.clearMessages();
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
40 formPanel.setRecord(record);
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
41 formPanel.setMessages(json.errors, json.warnings);
639
fdaabab6f4cc Open Probe-/Messung-Edit window automatically if a new item was saved
Raimund Renkert <raimund.renkert@intevation.de>
parents: 620
diff changeset
42 if (response.action === 'create' && json.success) {
fdaabab6f4cc Open Probe-/Messung-Edit window automatically if a new item was saved
Raimund Renkert <raimund.renkert@intevation.de>
parents: 620
diff changeset
43 button.up('window').close();
fdaabab6f4cc Open Probe-/Messung-Edit window automatically if a new item was saved
Raimund Renkert <raimund.renkert@intevation.de>
parents: 620
diff changeset
44 var win = Ext.create('Lada.view.window.ProbeEdit', {
fdaabab6f4cc Open Probe-/Messung-Edit window automatically if a new item was saved
Raimund Renkert <raimund.renkert@intevation.de>
parents: 620
diff changeset
45 record: record
fdaabab6f4cc Open Probe-/Messung-Edit window automatically if a new item was saved
Raimund Renkert <raimund.renkert@intevation.de>
parents: 620
diff changeset
46 });
fdaabab6f4cc Open Probe-/Messung-Edit window automatically if a new item was saved
Raimund Renkert <raimund.renkert@intevation.de>
parents: 620
diff changeset
47 win.show();
fdaabab6f4cc Open Probe-/Messung-Edit window automatically if a new item was saved
Raimund Renkert <raimund.renkert@intevation.de>
parents: 620
diff changeset
48 win.initData();
fdaabab6f4cc Open Probe-/Messung-Edit window automatically if a new item was saved
Raimund Renkert <raimund.renkert@intevation.de>
parents: 620
diff changeset
49 }
587
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
50 }
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
51 },
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
52 failure: function(record, response) {
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
53 button.setDisabled(true);
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
54 button.up('toolbar').down('button[action=discard]')
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
55 .setDisabled(true);
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
56 formPanel.getForm().loadRecord(formPanel.getForm().getRecord());
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
57 var json = response.request.scope.reader.jsonData;
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
58 if (json) {
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
59 formPanel.setMessages(json.errors, json.warnings);
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 });
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
63 console.log('save');
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
64 },
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
65
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
66 discard: function(button) {
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
67 var formPanel = button.up('form');
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
68 formPanel.getForm().loadRecord(formPanel.getForm().getRecord());
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
69 },
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
70
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
71 dirtyForm: function(form, dirty) {
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
72 if (dirty) {
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
73 form.owner.down('button[action=save]').setDisabled(false);
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
74 form.owner.down('button[action=discard]').setDisabled(false);
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
75 }
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
76 else {
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
77 form.owner.down('button[action=save]').setDisabled(true);
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
78 form.owner.down('button[action=discard]').setDisabled(true);
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
79 }
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
80 }
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
81 });

http://lada.wald.intevation.org