comparison app/controller/Base.js @ 287:12e7f0ef90b6

Move more methods into the BaseController.
author Torsten Irländer <torsten.irlaender@intevation.de>
date Fri, 09 Aug 2013 14:58:13 +0200
parents c509e9f6d4db
children 302db31ac50a
comparison
equal deleted inserted replaced
286:c509e9f6d4db 287:12e7f0ef90b6
35 }, 35 },
36 /** 36 /**
37 * Method to save the kommentar in the database. The method is called when 37 * Method to save the kommentar in the database. The method is called when
38 * the user clicks on the "Save" button 38 * the user clicks on the "Save" button
39 */ 39 */
40 saveItem: function(button) {}, 40 saveItem: function(button) {
41 console.log('Saving ...');
42 var form = button.up('window').down('form');
43 form.commit();
44 },
41 /** 45 /**
42 * Method to open a window to enter the values for a new kommentar. 46 * Method to open a window to enter the values for a new kommentar.
43 * The method is called when the user clicks on the "Add" button in the 47 * The method is called when the user clicks on the "Add" button in the
44 * grid toolbar. 48 * grid toolbar.
45 */ 49 */
55 * Confirmation dialog. After the deletion the related store will be 59 * Confirmation dialog. After the deletion the related store will be
56 * refreshed. 60 * refreshed.
57 * The method is called when the user selects the item in the grid and 61 * The method is called when the user selects the item in the grid and
58 * selects the delete button in the grid toolbar. 62 * selects the delete button in the grid toolbar.
59 */ 63 */
60 deleteItem: function(button) {}, 64 deleteItem: function(button) {
65 var grid = button.up('grid');
66 var selection = grid.getView().getSelectionModel().getSelection()[0];
67 Ext.MessageBox.confirm('Löschen', 'Sind Sie sicher?', function(btn){
68 if(btn === 'yes'){
69 var store = grid.getStore();
70 var deleteUrl = selection.getProxy().url + selection.getEidi();
71 Ext.Ajax.request({
72 url: deleteUrl,
73 method: 'DELETE',
74 success: function(response, opts) {
75 store.reload();
76 }
77 });
78 console.log('Deleting ' + selection);
79 } else {
80 console.log('Cancel Deleting ' + selection);
81 }
82 });
83 },
61 /** 84 /**
62 * Method to trigger the action after successfull save (create or edit). 85 * Method to trigger the action after successfull save (create).
63 * In this case the related store is refreshed and the window is closed. 86 * In this case the related store is refreshed and the window is closed.
64 */ 87 */
65 createSuccess: function(form, record, operation) {}, 88 createSuccess: function(form, record, operation) {},
66 /** 89 /**
67 * Method to trigger the action after save (create or edit) fails. 90 * Method to trigger the action after save (create) fails.
68 * In this case a Message Boss with a general error is shown. 91 * In this case a Message Boss with a general error is shown.
69 */ 92 */
70 createFailure: function(form, record, operation) {} 93 createFailure: function(form, record, operation) {
94 Ext.MessageBox.show({
95 title: 'Fehler beim Speichern',
96 msg: form.message,
97 icon: Ext.MessageBox.ERROR,
98 buttons: Ext.Msg.OK
99 });
100 },
101 /**
102 * Method to trigger the action after successfull save (edit).
103 * In this case the related store is refreshed and the window is closed.
104 */
105 editSuccess: function(form, record, operation) {},
106 /**
107 * Method to trigger the action after save ( edit) fails.
108 * In this case a Message Boss with a general error is shown.
109 */
110 editFailure: function(form, record, operation) {
111 Ext.MessageBox.show({
112 title: 'Fehler beim Speichern',
113 msg: form.message,
114 icon: Ext.MessageBox.ERROR,
115 buttons: Ext.Msg.OK
116 });
117 },
71 }); 118 });

http://lada.wald.intevation.org