Mercurial > lada > lada-client
comparison app/controller/Messwert.js @ 497:7c0653e8d9f7
Fixed some js related issues (unused vars, arrays, etc.) and code style.
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Thu, 06 Nov 2014 10:38:17 +0100 |
parents | d07e5086a64b |
children | 8b4ec61c5752 |
comparison
equal
deleted
inserted
replaced
496:d07e5086a64b | 497:7c0653e8d9f7 |
---|---|
1 /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz | 1 /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz |
2 * Software engineering by Intevation GmbH | 2 * Software engineering by Intevation GmbH |
3 * | 3 * |
4 * This file is Free Software under the GNU GPL (v>=3) | 4 * This file is Free Software under the GNU GPL (v>=3) |
5 * and comes with ABSOLUTELY NO WARRANTY! Check out | 5 * and comes with ABSOLUTELY NO WARRANTY! Check out |
6 * the documentation coming with IMIS-Labordaten-Application for details. | 6 * the documentation coming with IMIS-Labordaten-Application for details. |
7 */ | 7 */ |
8 | 8 |
9 /** | 9 /** |
10 * Controller for Messwerte | 10 * Controller for Messwerte |
11 */ | 11 */ |
56 | 56 |
57 addItem: function(button) { | 57 addItem: function(button) { |
58 var messung = Ext.create('Lada.model.Messwert'); | 58 var messung = Ext.create('Lada.model.Messwert'); |
59 messung.set('probeId', button.probeId); | 59 messung.set('probeId', button.probeId); |
60 messung.set('messungsId', button.parentId); | 60 messung.set('messungsId', button.parentId); |
61 var view = Ext.widget('messwertecreate', {model: messung}); | 61 Ext.widget('messwertecreate', { |
62 model: messung | |
63 }); | |
62 }, | 64 }, |
63 | 65 |
64 editItem: function(grid, record) { | 66 editItem: function(grid, record) { |
65 console.log('Editing Messwert'); | 67 console.log('Editing Messwert'); |
66 var mstore = Ext.data.StoreManager.get('Messungen'); | 68 var mstore = Ext.data.StoreManager.get('Messungen'); |
67 var pstore = Ext.data.StoreManager.get('Proben'); | 69 var messung = mstore.getById(record.get('messungsId')); |
68 var messung = mstore.getById(record.get('messungsId')) | |
69 record.getAuthInfo(this.initEditWindow, messung.get('probeId')); | 70 record.getAuthInfo(this.initEditWindow, messung.get('probeId')); |
70 console.log("Loaded Messwert with ID " + record.getId()); //outputs ID | 71 console.log('Loaded Messwert with ID ' + record.getId()); |
71 }, | 72 }, |
72 | 73 |
73 initEditWindow: function(record, readonly, owner) { | 74 initEditWindow: function(record, readonly) { |
74 var view = Ext.widget('messwertecreate', { | 75 var view = Ext.widget('messwertecreate', { |
75 model: record | 76 model: record |
76 }); | 77 }); |
77 var ignore = Array(); | 78 var ignore = []; |
78 if (readonly) { | 79 if (readonly) { |
79 var form = view.down('form'); | 80 var form = view.down('form'); |
80 form.setReadOnly(true, ignore); | 81 form.setReadOnly(true, ignore); |
81 } | 82 } |
82 }, | 83 }, |
89 var store = grid.getStore(); | 90 var store = grid.getStore(); |
90 var deleteUrl = selection.getProxy().url + selection.getId(); | 91 var deleteUrl = selection.getProxy().url + selection.getId(); |
91 Ext.Ajax.request({ | 92 Ext.Ajax.request({ |
92 url: deleteUrl, | 93 url: deleteUrl, |
93 method: 'DELETE', | 94 method: 'DELETE', |
94 success: function(response, opts) { | 95 success: function() { |
95 store.reload(); | 96 store.reload(); |
96 } | 97 } |
97 }); | 98 }); |
98 console.log('Deleting Messwert'); | 99 console.log('Deleting Messwert'); |
99 } else { | 100 } |
101 else { | |
100 console.log('Cancel Deleting Messwert'); | 102 console.log('Cancel Deleting Messwert'); |
101 } | 103 } |
102 }); | 104 }); |
103 }, | 105 }, |
104 | 106 |
105 createSuccess: function(form, record, operation) { | 107 createSuccess: function(form) { |
106 // Reload store | 108 // Reload store |
107 var store = this.getMesswerteStore(); | 109 var store = this.getMesswerteStore(); |
108 store.reload(); | 110 store.reload(); |
109 var win = form.up('window'); | 111 var win = form.up('window'); |
110 win.close(); | 112 win.close(); |
111 }, | 113 }, |
112 | 114 |
113 createFailure: function(form, record, operation) { | 115 createFailure: function(form) { |
114 Ext.MessageBox.show({ | 116 Ext.MessageBox.show({ |
115 title: 'Fehler beim Speichern', | 117 title: 'Fehler beim Speichern', |
116 msg: form.message, | 118 msg: form.message, |
117 icon: Ext.MessageBox.ERROR, | 119 icon: Ext.MessageBox.ERROR, |
118 buttons: Ext.Msg.OK | 120 buttons: Ext.Msg.OK |
119 }); | 121 }); |
120 }, | 122 }, |
121 | 123 |
122 editSuccess: function(form, record, operation) { | 124 editSuccess: function(form) { |
123 // Reload store | 125 // Reload store |
124 var store = this.getMesswerteStore(); | 126 var store = this.getMesswerteStore(); |
125 store.reload(); | 127 store.reload(); |
126 var win = form.up('window'); | 128 var win = form.up('window'); |
127 win.close(); | 129 win.close(); |
128 }, | 130 }, |
129 | 131 |
130 editFailure: function(form, record, operation) { | 132 editFailure: function(form) { |
131 Ext.MessageBox.show({ | 133 Ext.MessageBox.show({ |
132 title: 'Fehler beim Speichern', | 134 title: 'Fehler beim Speichern', |
133 msg: form.message, | 135 msg: form.message, |
134 icon: Ext.MessageBox.ERROR, | 136 icon: Ext.MessageBox.ERROR, |
135 buttons: Ext.Msg.OK | 137 buttons: Ext.Msg.OK |