Mercurial > lada > lada-client
annotate app/controller/Kommentare.js @ 59:9e23eca8dfc7
Added function to delete kommentare
author | Torsten Irländer <torsten.irlaender@intevation.de> |
---|---|
date | Wed, 29 May 2013 15:27:07 +0200 |
parents | 4fa3fba50f79 |
children | 5db7ab34af6d |
rev | line source |
---|---|
54
3c7bfff8bd64
Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
1 Ext.define('Lada.controller.Kommentare', { |
3c7bfff8bd64
Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
2 extend: 'Ext.app.Controller', |
3c7bfff8bd64
Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
3 views: [ |
55
4fa3fba50f79
Added dialog for editing kommentare. Open the dialog on double click on a
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
54
diff
changeset
|
4 'kommentare.List', |
4fa3fba50f79
Added dialog for editing kommentare. Open the dialog on double click on a
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
54
diff
changeset
|
5 'kommentare.Edit' |
54
3c7bfff8bd64
Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
6 ], |
3c7bfff8bd64
Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
7 stores: [ |
3c7bfff8bd64
Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
8 'Kommentare' |
3c7bfff8bd64
Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
9 ], |
3c7bfff8bd64
Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
10 models: [ |
3c7bfff8bd64
Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
11 'Kommentar' |
3c7bfff8bd64
Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
12 ], |
3c7bfff8bd64
Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
13 init: function() { |
3c7bfff8bd64
Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
14 console.log('Initialising the Kommentare controller'); |
3c7bfff8bd64
Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
15 this.control({ |
3c7bfff8bd64
Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
16 // CSS like selector to select element in the viewport. See |
3c7bfff8bd64
Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
17 // ComponentQuery documentation for more details. |
55
4fa3fba50f79
Added dialog for editing kommentare. Open the dialog on double click on a
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
54
diff
changeset
|
18 'kommentarelist': { |
4fa3fba50f79
Added dialog for editing kommentare. Open the dialog on double click on a
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
54
diff
changeset
|
19 // Map Doubleclick on rows of the probenlist. |
4fa3fba50f79
Added dialog for editing kommentare. Open the dialog on double click on a
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
54
diff
changeset
|
20 itemdblclick: this.editKommentar |
59
9e23eca8dfc7
Added function to delete kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
55
diff
changeset
|
21 }, |
9e23eca8dfc7
Added function to delete kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
55
diff
changeset
|
22 'kommentarelist toolbar button[action=delete]': { |
9e23eca8dfc7
Added function to delete kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
55
diff
changeset
|
23 click: this.deleteKommentar |
55
4fa3fba50f79
Added dialog for editing kommentare. Open the dialog on double click on a
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
54
diff
changeset
|
24 } |
54
3c7bfff8bd64
Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
25 //'probenedit button[action=save]': { |
3c7bfff8bd64
Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
26 // click: this.updateProbe |
3c7bfff8bd64
Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
27 //} |
3c7bfff8bd64
Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
28 }); |
3c7bfff8bd64
Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
29 }, |
59
9e23eca8dfc7
Added function to delete kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
55
diff
changeset
|
30 deleteKommentar: function(button) { |
9e23eca8dfc7
Added function to delete kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
55
diff
changeset
|
31 // Get selected item in grid |
9e23eca8dfc7
Added function to delete kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
55
diff
changeset
|
32 var grid = button.up('grid'); |
9e23eca8dfc7
Added function to delete kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
55
diff
changeset
|
33 var selection = grid.getView().getSelectionModel().getSelection()[0]; |
9e23eca8dfc7
Added function to delete kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
55
diff
changeset
|
34 console.log("Searching grid"); |
9e23eca8dfc7
Added function to delete kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
55
diff
changeset
|
35 Ext.MessageBox.confirm('Löschen', 'Sind Sie sicher?', function(btn){ |
9e23eca8dfc7
Added function to delete kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
55
diff
changeset
|
36 if(btn === 'yes'){ |
9e23eca8dfc7
Added function to delete kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
55
diff
changeset
|
37 var store = grid.getStore(); |
9e23eca8dfc7
Added function to delete kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
55
diff
changeset
|
38 store.remove(selection); |
9e23eca8dfc7
Added function to delete kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
55
diff
changeset
|
39 store.sync(); |
9e23eca8dfc7
Added function to delete kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
55
diff
changeset
|
40 console.log('Deleting Kommentar'); |
9e23eca8dfc7
Added function to delete kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
55
diff
changeset
|
41 } else { |
9e23eca8dfc7
Added function to delete kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
55
diff
changeset
|
42 console.log('Cancel Deleting Kommentar'); |
9e23eca8dfc7
Added function to delete kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
55
diff
changeset
|
43 } |
9e23eca8dfc7
Added function to delete kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
55
diff
changeset
|
44 }); |
9e23eca8dfc7
Added function to delete kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
55
diff
changeset
|
45 }, |
54
3c7bfff8bd64
Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
46 editKommentar: function(grid, record) { |
55
4fa3fba50f79
Added dialog for editing kommentare. Open the dialog on double click on a
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
54
diff
changeset
|
47 console.log('Double click on ' + record.get('id')); |
4fa3fba50f79
Added dialog for editing kommentare. Open the dialog on double click on a
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
54
diff
changeset
|
48 // Create new window to edit the seletced record. |
4fa3fba50f79
Added dialog for editing kommentare. Open the dialog on double click on a
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
54
diff
changeset
|
49 var view = Ext.widget('kommentaredit'); |
4fa3fba50f79
Added dialog for editing kommentare. Open the dialog on double click on a
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
54
diff
changeset
|
50 var form = view.down('form'); |
4fa3fba50f79
Added dialog for editing kommentare. Open the dialog on double click on a
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
54
diff
changeset
|
51 form.loadRecord(record); |
54
3c7bfff8bd64
Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
52 }, |
3c7bfff8bd64
Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
53 updateKommentar: function(button) { |
3c7bfff8bd64
Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
54 //console.log('Click save'); |
3c7bfff8bd64
Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
55 //// We only have a reference to the button here but we really wnat to |
3c7bfff8bd64
Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
56 //// get the form and the window. So first get the window and form and |
3c7bfff8bd64
Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
57 //// the the record an values. |
3c7bfff8bd64
Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
58 //var win = button.up('window'); |
3c7bfff8bd64
Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
59 //var form = win.down('form'); |
3c7bfff8bd64
Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
60 //var record = form.getRecord(); |
3c7bfff8bd64
Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
61 //var values = form.getValues(); |
3c7bfff8bd64
Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
62 |
3c7bfff8bd64
Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
63 //record.set(values); |
3c7bfff8bd64
Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
64 //win.close(); |
3c7bfff8bd64
Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
65 //// synchronize the store after editing the record |
3c7bfff8bd64
Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
66 //// NOTE: The function 'getProbenStore' will be generated |
3c7bfff8bd64
Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
67 //// dynamically based on the Name of the configured Store!!! |
3c7bfff8bd64
Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
68 //this.getProbenStore().sync(); |
3c7bfff8bd64
Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
69 } |
3c7bfff8bd64
Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
70 }); |