Mercurial > lada > lada-client
comparison app/controller/Kommentare.js @ 144:7b1140bd8b3d
Re-Added Kommentare
author | Torsten Irländer <torsten.irlaender@intevation.de> |
---|---|
date | Mon, 01 Jul 2013 10:15:00 +0200 |
parents | 6273b73b4b27 |
children | 4a79323336c6 |
comparison
equal
deleted
inserted
replaced
143:62b757ccdd8f | 144:7b1140bd8b3d |
---|---|
1 Ext.define('Lada.controller.Kommentare', { | 1 Ext.define('Lada.controller.Kommentare', { |
2 extend: 'Ext.app.Controller', | 2 extend: 'Ext.app.Controller', |
3 views: [ | 3 views: [ |
4 'kommentare.List', | |
5 'kommentare.Create' | 4 'kommentare.Create' |
6 ], | 5 ], |
7 stores: [ | 6 stores: [ |
8 'Kommentare' | 7 'Kommentare' |
9 ], | 8 ], |
22 click: this.addKommentar | 21 click: this.addKommentar |
23 }, | 22 }, |
24 'kommentarelist toolbar button[action=delete]': { | 23 'kommentarelist toolbar button[action=delete]': { |
25 click: this.deleteKommentar | 24 click: this.deleteKommentar |
26 }, | 25 }, |
26 'kommentarecreate button[action=save]': { | |
27 click: this.saveKommentar | |
28 }, | |
27 'kommentarecreate form': { | 29 'kommentarecreate form': { |
28 savesuccess: this.createSuccess, | 30 savesuccess: this.createSuccess, |
29 savefailure: this.createFailure | 31 savefailure: this.createFailure |
30 }, | 32 }, |
31 'kommentareedit form': { | 33 'kommentareedit form': { |
32 savesuccess: this.editSuccess, | 34 savesuccess: this.editSuccess, |
33 savefailure: this.editFailure | 35 savefailure: this.editFailure |
34 } | 36 } |
35 }); | 37 }); |
36 }, | 38 }, |
39 saveKommentar: function(button) { | |
40 console.log('Saving Kommentar'); | |
41 var form = button.up('window').down('form'); | |
42 form.commit(); | |
43 }, | |
37 addKommentar: function(button) { | 44 addKommentar: function(button) { |
38 console.log('Adding new Kommentar'); | 45 console.log('Adding new Kommentar for Probe ' + button.probeId); |
39 var view = Ext.widget('kommentarecreate'); | 46 var kommentar = Ext.create('Lada.model.Kommentar'); |
47 kommentar.set('probeId', button.probeId); | |
48 var view = Ext.widget('kommentarecreate', {model: kommentar}); | |
40 }, | 49 }, |
41 editKommentar: function(grid, record) { | 50 editKommentar: function(grid, record) { |
42 console.log('Editing Kommentar'); | 51 console.log('Editing Kommentar'); |
43 var view = Ext.widget('kommentarecreate', {model: record}); | 52 var view = Ext.widget('kommentarecreate', {model: record}); |
44 console.log("Loaded Kommentar with ID " + record.getId()); //outputs ID | 53 console.log("Loaded Kommentar with ID " + record.getId()); //outputs ID |
48 var grid = button.up('grid'); | 57 var grid = button.up('grid'); |
49 var selection = grid.getView().getSelectionModel().getSelection()[0]; | 58 var selection = grid.getView().getSelectionModel().getSelection()[0]; |
50 Ext.MessageBox.confirm('Löschen', 'Sind Sie sicher?', function(btn){ | 59 Ext.MessageBox.confirm('Löschen', 'Sind Sie sicher?', function(btn){ |
51 if(btn === 'yes'){ | 60 if(btn === 'yes'){ |
52 var store = grid.getStore(); | 61 var store = grid.getStore(); |
53 store.remove(selection); | 62 var deleteUrl = selection.getProxy().url + selection.getEidi(); |
54 store.sync(); | 63 Ext.Ajax.request({ |
64 url: deleteUrl, | |
65 method: 'DELETE', | |
66 success: function(response, opts) { | |
67 store.reload(); | |
68 } | |
69 }); | |
55 console.log('Deleting Kommentar'); | 70 console.log('Deleting Kommentar'); |
56 } else { | 71 } else { |
57 console.log('Cancel Deleting Kommentar'); | 72 console.log('Cancel Deleting Kommentar'); |
58 } | 73 } |
59 }); | 74 }); |