Mercurial > lada > lada-client
comparison app/controller/Kommentare.js @ 285:6c030e5739a7
Added Docstrings
author | Torsten Irländer <torsten.irlaender@intevation.de> |
---|---|
date | Fri, 09 Aug 2013 12:56:32 +0200 |
parents | 4a79323336c6 |
children | c509e9f6d4db |
comparison
equal
deleted
inserted
replaced
284:c32be5f97b5d | 285:6c030e5739a7 |
---|---|
1 /** | |
2 * Controller for Kommentare | |
3 * | |
4 * The controller defines the main logic of the application. It provides | |
5 * various methods which are bound to listeners and called when the defined | |
6 * events in the various UI elements occour (e.g User clicks on a button) | |
7 */ | |
1 Ext.define('Lada.controller.Kommentare', { | 8 Ext.define('Lada.controller.Kommentare', { |
2 extend: 'Ext.app.Controller', | 9 extend: 'Ext.app.Controller', |
3 views: [ | 10 views: [ |
4 'kommentare.Create' | 11 'kommentare.Create' |
5 ], | 12 ], |
30 savesuccess: this.createSuccess, | 37 savesuccess: this.createSuccess, |
31 savefailure: this.createFailure | 38 savefailure: this.createFailure |
32 } | 39 } |
33 }); | 40 }); |
34 }, | 41 }, |
42 /** | |
43 * Method to save the kommentar in the database. The method is called when | |
44 * the user clicks on the "Save" button | |
45 */ | |
35 saveKommentar: function(button) { | 46 saveKommentar: function(button) { |
36 console.log('Saving Kommentar'); | 47 console.log('Saving Kommentar'); |
37 var form = button.up('window').down('form'); | 48 var form = button.up('window').down('form'); |
38 form.commit(); | 49 form.commit(); |
39 }, | 50 }, |
51 /** | |
52 * Method to open a window to enter the values for a new kommentar. | |
53 * The method is called when the user clicks on the "Add" button in the | |
54 * grid toolbar. | |
55 */ | |
40 addKommentar: function(button) { | 56 addKommentar: function(button) { |
41 console.log('Adding new Kommentar for Probe ' + button.probeId); | 57 console.log('Adding new Kommentar for Probe ' + button.probeId); |
42 var kommentar = Ext.create('Lada.model.Kommentar'); | 58 var kommentar = Ext.create('Lada.model.Kommentar'); |
43 kommentar.set('probeId', button.probeId); | 59 kommentar.set('probeId', button.probeId); |
44 var view = Ext.widget('kommentarecreate', {model: kommentar}); | 60 var view = Ext.widget('kommentarecreate', {model: kommentar}); |
45 }, | 61 }, |
62 /** | |
63 * Method to open a window to edit the values for an existing kommentar. | |
64 * The method is called when the user doubleclicks on the item in the | |
65 * grid. | |
66 */ | |
46 editKommentar: function(grid, record) { | 67 editKommentar: function(grid, record) { |
47 console.log('Editing Kommentar'); | 68 console.log('Editing Kommentar'); |
48 var view = Ext.widget('kommentarecreate', {model: record}); | 69 var view = Ext.widget('kommentarecreate', {model: record}); |
49 console.log("Loaded Kommentar with ID " + record.getId()); //outputs ID | 70 console.log("Loaded Kommentar with ID " + record.getId()); //outputs ID |
50 }, | 71 }, |
72 /** | |
73 * Method to delete a kommentar. This will trigger the display of a | |
74 * Confirmation dialog. After the deletion the related store will be | |
75 * refreshed. | |
76 * The method is called when the user selects the item in the grid and | |
77 * selects the delete button in the grid toolbar. | |
78 */ | |
51 deleteKommentar: function(button) { | 79 deleteKommentar: function(button) { |
52 // Get selected item in grid | 80 // Get selected item in grid |
53 var grid = button.up('grid'); | 81 var grid = button.up('grid'); |
54 var selection = grid.getView().getSelectionModel().getSelection()[0]; | 82 var selection = grid.getView().getSelectionModel().getSelection()[0]; |
55 Ext.MessageBox.confirm('Löschen', 'Sind Sie sicher?', function(btn){ | 83 Ext.MessageBox.confirm('Löschen', 'Sind Sie sicher?', function(btn){ |
67 } else { | 95 } else { |
68 console.log('Cancel Deleting Kommentar'); | 96 console.log('Cancel Deleting Kommentar'); |
69 } | 97 } |
70 }); | 98 }); |
71 }, | 99 }, |
100 /** | |
101 * Method to trigger the action after successfull save (create or edit). | |
102 * In this case the related store is refreshed and the window is closed. | |
103 */ | |
72 createSuccess: function(form, record, operation) { | 104 createSuccess: function(form, record, operation) { |
73 // Reload store | 105 // Reload store |
74 var store = this.getKommentareStore(); | 106 var store = this.getKommentareStore(); |
75 store.reload(); | 107 store.reload(); |
76 var win = form.up('window'); | 108 var win = form.up('window'); |
77 win.close(); | 109 win.close(); |
78 }, | 110 }, |
111 /** | |
112 * Method to trigger the action after save (create or edit) fails. | |
113 * In this case a Message Boss with a general error is shown. | |
114 */ | |
79 createFailure: function(form, record, operation) { | 115 createFailure: function(form, record, operation) { |
80 Ext.MessageBox.show({ | 116 Ext.MessageBox.show({ |
81 title: 'Fehler beim Speichern', | 117 title: 'Fehler beim Speichern', |
82 msg: form.message, | 118 msg: form.message, |
83 icon: Ext.MessageBox.ERROR, | 119 icon: Ext.MessageBox.ERROR, |