comparison app/controller/ProbeForm.js @ 548:d47ee7439f44

Added new js files.
author Raimund Renkert <raimund.renkert@intevation.de>
date Fri, 06 Mar 2015 12:43:52 +0100
parents
children bff49c2fc3df
comparison
equal deleted inserted replaced
547:f172b35a3b92 548:d47ee7439f44
1 /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
2 * Software engineering by Intevation GmbH
3 *
4 * This file is Free Software under the GNU GPL (v>=3)
5 * and comes with ABSOLUTELY NO WARRANTY! Check out
6 * the documentation coming with IMIS-Labordaten-Application for details.
7 */
8
9 Ext.define('Lada.controller.ProbeForm', {
10 extend: 'Ext.app.Controller',
11
12 init: function() {
13 this.control({
14 'probeform button[action=save]': {
15 click: this.save
16 },
17 'probeform button[action=discard]': {
18 click: this.discard
19 },
20 'probeform': {
21 dirtychange: this.dirtyForm
22 }
23 });
24 },
25
26 save: function(button) {
27 var formPanel = button.up('form');
28 var data = formPanel.getForm().getFieldValues(true);
29 for (var key in data) {
30 formPanel.getForm().getRecord().set(key, data[key]);
31 }
32 formPanel.getForm().getRecord().save({
33 success: function(record, response) {
34 var json = Ext.decode(response.response.responseText);
35 if (response.action !== 'create' &&
36 json &&
37 json.success) {
38 formPanel.setRecord(record);
39 formPanel.setMessages(json.errors, json.warnings);
40 }
41 },
42 failure: function(record, response) {
43 console.log('failed...');
44 var json = response.request.scope.reader.jsonData;
45 if (json) {
46 formPanel.setMessages(json.errors, json.warnings);
47 }
48 }
49 });
50 console.log('save');
51 },
52
53 discard: function(button) {
54 var formPanel = button.up('form');
55 formPanel.getForm().loadRecord(formPanel.getForm().getRecord());
56 },
57
58 dirtyForm: function(form, dirty) {
59 if (dirty) {
60 form.owner.down('button[action=save]').setDisabled(false);
61 form.owner.down('button[action=discard]').setDisabled(false);
62 }
63 else {
64 form.owner.down('button[action=save]').setDisabled(true);
65 form.owner.down('button[action=discard]').setDisabled(true);
66 }
67 }
68 });

http://lada.wald.intevation.org