annotate app/controller/Kommentare.js @ 107:84f32c62670f

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

http://lada.wald.intevation.org