comparison app/controller/Orte.js @ 447:12231f31c112

Apply new workflow in orte dialog.
author Raimund Renkert <raimund.renkert@intevation.de>
date Thu, 05 Dec 2013 09:57:57 +0100
parents 6a7a9267e00f
children edb9dee114f8
comparison
equal deleted inserted replaced
446:b3e806045a5a 447:12231f31c112
3 */ 3 */
4 Ext.define('Lada.controller.Orte', { 4 Ext.define('Lada.controller.Orte', {
5 extend: 'Lada.controller.Base', 5 extend: 'Lada.controller.Base',
6 views: [ 6 views: [
7 'orte.List', 7 'orte.List',
8 'orte.Create' 8 'orte.Create',
9 'orte.CreateOrt'
9 ], 10 ],
10 stores: [ 11 stores: [
11 'Orte', 12 'Orte',
12 'Ortedetails', 13 'Ortedetails',
13 'Staaten', 14 'Staaten',
32 click: this.deleteItem 33 click: this.deleteItem
33 }, 34 },
34 'ortecreate button[action=save]': { 35 'ortecreate button[action=save]': {
35 click: this.saveItem 36 click: this.saveItem
36 }, 37 },
38 'ortecreate form button[action=newort]': {
39 click: this.createOrt
40 },
41 'createortdetail button[action=save]': {
42 click: this.saveNewOrt
43 },
37 'ortecreate form': { 44 'ortecreate form': {
38 savesuccess: this.createSuccess, 45 savesuccess: this.createSuccess,
39 savefailure: this.createFailure 46 savefailure: this.createFailure
40 }, 47 },
41 'orteedit form': { 48 'orteedit form': {
42 savesuccess: this.editSuccess, 49 savesuccess: this.editSuccess,
43 savefailure: this.editFailure 50 savefailure: this.editFailure
51 }
52 });
53 },
54 createOrt: function(button) {
55 console.log('button clicked');
56 var win = Ext.create('Lada.view.orte.CreateOrt',{});
57 win.show();
58 },
59 saveNewOrt: function(button) {
60 console.log('button clicked');
61
62 var form = button.up('window').down('form').getForm();
63 var ortdetailstore = Ext.getStore('Ortedetails');
64 var ortdetail = Ext.create('Lada.model.Ortdetail');
65 var fields = ['beschreibung', 'hoeheLand',
66 'latitude', 'longitude', 'staatId', 'gemId'];
67 for (var i = fields.length - 1; i >= 0; i--){
68 var ffield = form.findField("ort_"+fields[i]);
69 ortdetail.set(fields[i], ffield.getValue());
70 }
71 ortdetailstore.add(ortdetail);
72 ortdetailstore.sync({
73 success: function(batch, options) {
74 console.log(batch);
75 var od = Ext.ComponentQuery.query('ortdetail');
76 console.log(od);
77 batch.operations[0].resultSet.records[0].data;
78 var response = batch.operations[0].resultSet.records[0].data;
79 od[0].setValue(response.ortId);
80 console.log('id:' + response.ortId);
81 button.up('window').close();
82 },
83 failure: function() {
84 console.log('Error on saving Ortdetails');
85 ortdetailstore.remove(ortdetail);
44 } 86 }
45 }); 87 });
46 }, 88 },
47 saveItem: function(button) { 89 saveItem: function(button) {
48 console.log('Saving Ort'); 90 console.log('Saving Ort');
98 console.log('Editing Ort'); 140 console.log('Editing Ort');
99 record.getAuthInfo(this.initEditWindow) 141 record.getAuthInfo(this.initEditWindow)
100 console.log("Loaded Ort with ID " + record.getId()); //outputs ID 142 console.log("Loaded Ort with ID " + record.getId()); //outputs ID
101 }, 143 },
102 initEditWindow: function(record, readonly, owner) { 144 initEditWindow: function(record, readonly, owner) {
103 var view = Ext.widget('ortecreate', {model: record}); 145 var view = Ext.widget('ortecreate', {model: record, edit: true});
104 var ignore = Array(); 146 var ignore = Array();
105 if (readonly) { 147 if (readonly) {
106 var form = view.down('form'); 148 var form = view.down('form');
107 form.setReadOnly(true, ignore); 149 form.setReadOnly(true, ignore);
108 } 150 }

http://lada.wald.intevation.org