annotate app/controller/Kommentare.js @ 70:1a943947a7d2

Added new listeners for events comming from the Probenforms.
author Torsten Irländer <torsten.irlaender@intevation.de>
date Wed, 05 Jun 2013 15:43:42 +0200
parents 20a4f9aaecde
children 84f32c62670f
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 },
60
5db7ab34af6d Implemented Adding und Editing Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 59
diff changeset
22 'kommentarelist toolbar button[action=add]': {
5db7ab34af6d Implemented Adding und Editing Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 59
diff changeset
23 click: this.addKommentar
5db7ab34af6d Implemented Adding und Editing Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 59
diff changeset
24 },
59
9e23eca8dfc7 Added function to delete kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 55
diff changeset
25 'kommentarelist toolbar button[action=delete]': {
9e23eca8dfc7 Added function to delete kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 55
diff changeset
26 click: this.deleteKommentar
60
5db7ab34af6d Implemented Adding und Editing Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 59
diff changeset
27 },
5db7ab34af6d Implemented Adding und Editing Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 59
diff changeset
28 'kommentaredit button[action=save]': {
5db7ab34af6d Implemented Adding und Editing Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 59
diff changeset
29 click: this.saveKommentar
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
30 }
54
3c7bfff8bd64 Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
31 });
3c7bfff8bd64 Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
32 },
60
5db7ab34af6d Implemented Adding und Editing Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 59
diff changeset
33 addKommentar: function(button) {
5db7ab34af6d Implemented Adding und Editing Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 59
diff changeset
34 console.log('Adding new Kommentar');
5db7ab34af6d Implemented Adding und Editing Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 59
diff changeset
35 var view = Ext.widget('kommentaredit');
5db7ab34af6d Implemented Adding und Editing Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 59
diff changeset
36 var form = view.down('form');
5db7ab34af6d Implemented Adding und Editing Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 59
diff changeset
37 // Create a new Kommentar
5db7ab34af6d Implemented Adding und Editing Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 59
diff changeset
38 var record = Ext.create('Lada.model.Kommentar');
5db7ab34af6d Implemented Adding und Editing Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 59
diff changeset
39 form.loadRecord(record);
5db7ab34af6d Implemented Adding und Editing Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 59
diff changeset
40 },
59
9e23eca8dfc7 Added function to delete kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 55
diff changeset
41 deleteKommentar: function(button) {
9e23eca8dfc7 Added function to delete kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 55
diff changeset
42 // Get selected item in grid
9e23eca8dfc7 Added function to delete kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 55
diff changeset
43 var grid = button.up('grid');
9e23eca8dfc7 Added function to delete kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 55
diff changeset
44 var selection = grid.getView().getSelectionModel().getSelection()[0];
9e23eca8dfc7 Added function to delete kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 55
diff changeset
45 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
46 if(btn === 'yes'){
9e23eca8dfc7 Added function to delete kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 55
diff changeset
47 var store = grid.getStore();
9e23eca8dfc7 Added function to delete kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 55
diff changeset
48 store.remove(selection);
9e23eca8dfc7 Added function to delete kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 55
diff changeset
49 store.sync();
9e23eca8dfc7 Added function to delete kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 55
diff changeset
50 console.log('Deleting Kommentar');
9e23eca8dfc7 Added function to delete kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 55
diff changeset
51 } else {
9e23eca8dfc7 Added function to delete kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 55
diff changeset
52 console.log('Cancel Deleting Kommentar');
9e23eca8dfc7 Added function to delete kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 55
diff changeset
53 }
9e23eca8dfc7 Added function to delete kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 55
diff changeset
54 });
9e23eca8dfc7 Added function to delete kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 55
diff changeset
55 },
54
3c7bfff8bd64 Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
56 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
57 // 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
58 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
59 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
60 form.loadRecord(record);
54
3c7bfff8bd64 Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
61 },
60
5db7ab34af6d Implemented Adding und Editing Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 59
diff changeset
62 saveKommentar: function(button) {
5db7ab34af6d Implemented Adding und Editing Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 59
diff changeset
63 var win = button.up('window');
5db7ab34af6d Implemented Adding und Editing Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 59
diff changeset
64 var form = win.down('form');
5db7ab34af6d Implemented Adding und Editing Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 59
diff changeset
65 var record = form.getRecord();
5db7ab34af6d Implemented Adding und Editing Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 59
diff changeset
66 var values = form.getValues();
5db7ab34af6d Implemented Adding und Editing Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 59
diff changeset
67 var store = this.getKommentareStore();
5db7ab34af6d Implemented Adding und Editing Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 59
diff changeset
68 record.set(values);
5db7ab34af6d Implemented Adding und Editing Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 59
diff changeset
69 store.add(record);
5db7ab34af6d Implemented Adding und Editing Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 59
diff changeset
70 store.sync();
5db7ab34af6d Implemented Adding und Editing Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 59
diff changeset
71 console.log('Saving Kommentar');
5db7ab34af6d Implemented Adding und Editing Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 59
diff changeset
72 win.close();
54
3c7bfff8bd64 Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
73 }
3c7bfff8bd64 Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
74 });

http://lada.wald.intevation.org