Mercurial > lada > lada-client
comparison app/controller/MKommentare.js @ 207:62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
mostly duplicated code for MKommentare.
author | Torsten Irländer <torsten.irlaender@intevation.de> |
---|---|
date | Tue, 09 Jul 2013 15:26:29 +0200 |
parents | cd8cd3ac0231 |
children | e95662994c50 |
comparison
equal
deleted
inserted
replaced
206:32e1356cf391 | 207:62e116cd3e3b |
---|---|
1 Ext.define('Lada.controller.MKommentare', { | 1 Ext.define('Lada.controller.MKommentare', { |
2 extend: 'Lada.controller.Kommentare', | 2 extend: 'Ext.app.Controller', |
3 views: [ | |
4 'mkommentare.Create' | |
5 ], | |
3 stores: [ | 6 stores: [ |
4 'MKommentare' | 7 'MKommentare' |
5 ], | 8 ], |
6 models: [ | 9 models: [ |
7 'MKommentar' | 10 'MKommentar' |
8 ], | 11 ], |
12 init: function() { | |
13 console.log('Initialising the MKommentare controller'); | |
14 this.control({ | |
15 // CSS like selector to select element in the viewport. See | |
16 // ComponentQuery documentation for more details. | |
17 'mkommentarelist': { | |
18 itemdblclick: this.editKommentar | |
19 }, | |
20 'mkommentarelist toolbar button[action=add]': { | |
21 click: this.addKommentar | |
22 }, | |
23 'mkommentarelist toolbar button[action=delete]': { | |
24 click: this.deleteKommentar | |
25 }, | |
26 'mkommentarecreate button[action=save]': { | |
27 click: this.saveKommentar | |
28 }, | |
29 'mkommentarecreate form': { | |
30 savesuccess: this.createSuccess, | |
31 savefailure: this.createFailure | |
32 } | |
33 }); | |
34 }, | |
35 saveKommentar: function(button) { | |
36 console.log('Saving MKommentar'); | |
37 var form = button.up('window').down('form'); | |
38 form.commit(); | |
39 }, | |
9 addKommentar: function(button) { | 40 addKommentar: function(button) { |
10 console.log('Adding new Kommentar for Messung ' + button.parentId + ' Probe ' + button.probeId); | 41 console.log('Adding new MKommentar for Messung ' + button.parentId + ' Probe ' + button.probeId); |
11 var kommentar = Ext.create('Lada.model.MKommentar'); | 42 var kommentar = Ext.create('Lada.model.MKommentar'); |
12 kommentar.set('probeId', button.probeId); | 43 kommentar.set('probeId', button.probeId); |
13 kommentar.set('messungsId', button.parentId); | 44 kommentar.set('messungsId', button.parentId); |
14 var view = Ext.widget('kommentarecreate', {model: kommentar}); | 45 var view = Ext.widget('mkommentarecreate', {model: kommentar}); |
46 }, | |
47 editKommentar: function(grid, record) { | |
48 console.log('Editing Kommentar'); | |
49 var view = Ext.widget('mkommentarecreate', {model: record}); | |
50 console.log("Loaded MKommentar with ID " + record.getId()); //outputs ID | |
51 }, | |
52 deleteKommentar: function(button) { | |
53 // Get selected item in grid | |
54 var grid = button.up('grid'); | |
55 var selection = grid.getView().getSelectionModel().getSelection()[0]; | |
56 Ext.MessageBox.confirm('Löschen', 'Sind Sie sicher?', function(btn){ | |
57 if(btn === 'yes'){ | |
58 var store = grid.getStore(); | |
59 var deleteUrl = selection.getProxy().url + selection.getEidi(); | |
60 Ext.Ajax.request({ | |
61 url: deleteUrl, | |
62 method: 'DELETE', | |
63 success: function(response, opts) { | |
64 store.reload(); | |
65 } | |
66 }); | |
67 console.log('Deleting MKommentar'); | |
68 } else { | |
69 console.log('Cancel Deleting MKommentar'); | |
70 } | |
71 }); | |
15 }, | 72 }, |
16 createSuccess: function(form, record, operation) { | 73 createSuccess: function(form, record, operation) { |
17 // Reload store | 74 // Reload store |
18 var store = this.getMKommentareStore(); | 75 var store = this.getMKommentareStore(); |
19 store.reload(); | 76 store.reload(); |
20 var win = form.up('window'); | 77 var win = form.up('window'); |
21 win.close(); | 78 win.close(); |
22 }, | 79 }, |
23 editSuccess: function(form, record, operation) { | 80 createFailure: function(form, record, operation) { |
24 // Reload store | 81 Ext.MessageBox.show({ |
25 var store = this.getMKommentareStore(); | 82 title: 'Fehler beim Speichern', |
26 store.reload(); | 83 msg: form.message, |
27 var win = form.up('window'); | 84 icon: Ext.MessageBox.ERROR, |
28 win.close(); | 85 buttons: Ext.Msg.OK |
86 }); | |
29 } | 87 } |
30 }); | 88 }); |