Mercurial > lada > lada-client
diff app/controller/grid/Status.js @ 742:6e28ebbe1a73
added documentation for Form and Grid controllers
author | Dustin Demuth <dustin@intevation.de> |
---|---|
date | Thu, 23 Apr 2015 16:28:04 +0200 |
parents | f0bc5387abcc |
children | 2362f8ab1e9f |
line wrap: on
line diff
--- a/app/controller/grid/Status.js Mon Apr 20 16:07:40 2015 +0200 +++ b/app/controller/grid/Status.js Thu Apr 23 16:28:04 2015 +0200 @@ -6,10 +6,17 @@ * the documentation coming with IMIS-Labordaten-Application for details. */ +/** + * This is a controller for a grid of Status + */ Ext.define('Lada.controller.grid.Status', { extend: 'Ext.app.Controller', - init: function() { + /** + * Initialize the Controller with + * 3 Listeners + */ + init: function() { this.control({ 'statusgrid': { edit: this.gridSave, @@ -24,7 +31,13 @@ }); }, - gridSave: function(editor, context) { + /** + * This function is called when the grids roweditor saves + * the record. + * On success it refreshes the windows which contains the grid + * On failure it displays a message + */ + gridSave: function(editor, context) { context.record.save({ success: function() { context.grid.initData(); @@ -49,14 +62,21 @@ }); }, - cancelEdit: function(editor, context) { + /** + * When the edit was canceled, + * the empty row might have been created by the roweditor is removed + */ + cancelEdit: function(editor, context) { if (!context.record.get('id') || context.record.get('id') === '') { editor.getCmp().store.remove(context.record); } }, - add: function(button) { + /** + * This function adds a new row to add a Status + */ + add: function(button) { var record = Ext.create('Lada.model.Status', { messungsId: button.up('statusgrid').recordId }); @@ -64,7 +84,13 @@ button.up('statusgrid').rowEditing.startEdit(0, 1); }, - remove: function(button) { + /** + * A row can be removed from the grid with the remove + * function. It asks the user for confirmation + * If the removal was confirmed, it reloads the parent window on success, + * on failure, an error message is shown. + */ + remove: function(button) { var grid = button.up('grid'); var selection = grid.getView().getSelectionModel().getSelection()[0]; Ext.MessageBox.confirm('Messwert löschen', 'Sind Sie sicher?', function(btn) {