[Lada-commits] [PATCH 1 of 2] added documentation for Form and Grid controllers
Wald Commits
scm-commit at wald.intevation.org
Thu Apr 23 16:29:47 CEST 2015
# HG changeset patch
# User Dustin Demuth <dustin at intevation.de>
# Date 1429799284 -7200
# Node ID 6e28ebbe1a73b20b2a32660d6b189bb100ffb772
# Parent 2e8da590ea0c092f1ae888c8594ce22783389ec2
added documentation for Form and Grid controllers
diff -r 2e8da590ea0c -r 6e28ebbe1a73 app/controller/Filter.js
--- a/app/controller/Filter.js Mon Apr 20 16:07:40 2015 +0200
+++ b/app/controller/Filter.js Thu Apr 23 16:28:04 2015 +0200
@@ -24,6 +24,10 @@
displayFields: null,
+ /**
+ * Initialize this Controller
+ * It has 4 Listeners
+ */
init: function() {
this.control({
// CSS like selector to select element in the viewport. See
@@ -72,25 +76,26 @@
// Setup Columns of the probenlist
this.displayFields.reverse();
- // Setup Filters of the probenlist
- //
- // Allowed types are
- // * text
- // * number
- // * datetime
- // * bool
- // * listmst
- // * listumw
- // * listver
- // * listdbasis
- // * listnetz
- //
- // Iterate over all configured filters and add filters dynamically
- //
- // 1. Empty filters
+ /* Setup Filters of the probenlist
+ *
+ * Allowed types are
+ * * text
+ * * number
+ * * datetime
+ * * bool
+ * * listmst
+ * * listumw
+ * * listver
+ * * listdbasis
+ * * listnetz
+ *
+ * Iterate over all configured filters and add filters dynamically
+ *
+ * 1. Empty filters
+ */
filters.removeAll();
var hide = true;
- // 2. Iterate over all configured filters
+ /* 2. Iterate over all configured filters */
var j;
for (j = 0; j < filterFields.length; j++) {
var type = filterFields[j].type;
@@ -202,7 +207,9 @@
resultGrid.getStore().load();
resultGrid.show();
},
-
+ /**
+ * This function resets the filters
+ */
reset: function(element) {
var filters = element.up('panel[name=main]').down('fieldset[name=filtervariables]');
for (var i = filters.items.length - 1; i >= 0; i--) {
@@ -210,7 +217,10 @@
filter.clearValue();
}
},
-
+ /**
+ * This Function is supposed to handle the About action
+ * It has no function yet.
+ */
about: function() {
var info = this.getInfoStore();
Ext.widget('about', {
diff -r 2e8da590ea0c -r 6e28ebbe1a73 app/controller/FilterResult.js
--- a/app/controller/FilterResult.js Mon Apr 20 16:07:40 2015 +0200
+++ b/app/controller/FilterResult.js Thu Apr 23 16:28:04 2015 +0200
@@ -15,6 +15,9 @@
'Lada.view.window.ProbeEdit'
],
+ /**
+ * Initialize the Controller with 4 listeners
+ */
init: function() {
this.control({
'filterresultgrid': {
@@ -33,6 +36,12 @@
this.callParent(arguments);
},
+ /**
+ * This function is called after a Row in the
+ * {@link Lada.view.grid.FilterResult}
+ * was double-clicked.
+ * The function opens a {@link Lada.view.window.ProbeEdit}
+ */
editItem: function(grid, record) {
var win = Ext.create('Lada.view.window.ProbeEdit', {
record: record
@@ -41,12 +50,20 @@
win.initData();
},
+ /**
+ * This function opens a new window to create a Probe
+ * {@link Lada.view.window.ProbeEdit}
+ */
addItem: function() {
var win = Ext.create('Lada.view.window.ProbeCreate');
win.show();
win.initData();
},
+ /**
+ * This function opens a {@link Lada.view.window.FileUpload}
+ * window to upload a LAF-File
+ */
uploadFile: function() {
var win = Ext.create('Lada.view.window.FileUpload', {
title: 'Datenimport',
@@ -56,6 +73,11 @@
win.show();
},
+ /**
+ * This function can be used to Download the items which
+ * were selected in the {@link Lada.view.grid.FilterResult}
+ * The Download does not work with Internet Explorers older than v.10
+ */
downloadFile: function(button) {
var grid = button.up('grid');
var selection = grid.getView().getSelectionModel().getSelection();
diff -r 2e8da590ea0c -r 6e28ebbe1a73 app/controller/Map.js
--- a/app/controller/Map.js Mon Apr 20 16:07:40 2015 +0200
+++ b/app/controller/Map.js Thu Apr 23 16:28:04 2015 +0200
@@ -7,6 +7,8 @@
*/
/**
+ * This is a controller for a Map.
+ * Maps are used in the Ortsangaben of a Probe.
*/
Ext.define('Lada.controller.Map', {
extend: 'Ext.app.Controller',
@@ -14,6 +16,10 @@
requires: [
],
+ /**
+ * Initialize the Controller
+ * It has only one listener.
+ */
init: function() {
this.control({
'maptoolbar button[action=add]': {
@@ -23,6 +29,12 @@
this.callParent(arguments);
},
+ /**
+ * addLocation is a function which can be
+ * used to add an location to create a new Location
+ * with the help of the map.
+ * The function uses {@link Lada.view.panel.Map#activateDraw}
+ */
addLocation: function(button) {
var mapPanel = button.up('map');
var details = button.up('window').down('locationform');
diff -r 2e8da590ea0c -r 6e28ebbe1a73 app/controller/form/Location.js
--- a/app/controller/form/Location.js Mon Apr 20 16:07:40 2015 +0200
+++ b/app/controller/form/Location.js Thu Apr 23 16:28:04 2015 +0200
@@ -6,9 +6,15 @@
* the documentation coming with IMIS-Labordaten-Application for details.
*/
+/**
+ * This is a Controller for a Location Form
+ */
Ext.define('Lada.controller.form.Location', {
extend: 'Ext.app.Controller',
-
+ /**
+ * Initialize the Controller with
+ * 5 listeners
+ */
init: function() {
this.control({
'locationform button[action=save]': {
@@ -29,6 +35,11 @@
});
},
+ /**
+ * The save function saves the content of the Location form.
+ * On success it will reload the Store,
+ * on failure, it will display an Errormessage
+ */
save: function(button) {
var formPanel = button.up('form');
var data = formPanel.getForm().getFieldValues(true);
@@ -81,12 +92,22 @@
});
},
+ /**
+ * The discard function resets the Location form
+ * to its original state.
+ */
discard: function(button) {
var formPanel = button.up('form');
formPanel.getForm().loadRecord(formPanel.getForm().getRecord());
button.up('window').down('map').locationRecord = null;
},
+ /**
+ * The dirtyForm function enables or disables the save and discard
+ * button which are present in the toolbar of the form.
+ * The Buttons are only active if the content of the form was altered
+ * (the form is dirty).
+ */
dirtyForm: function(form, dirty) {
if (dirty) {
form.owner.down('button[action=save]').setDisabled(false);
@@ -98,6 +119,12 @@
}
},
+ /**
+ * This function updates the Latitude (heigth-value / y-value) of a feature
+ * (geospatial object). The feature can be a marker in the map
+ * @param {Ext.form.field.Field} field the Ext.field which was altered
+ * @param {} nValue the new Latitude as WGS84 in decimaldegrees
+ */
updateFeatureLatitude: function(field, nValue) {
var layer = field.up('window').down('map').selectControl.layer;
var newLocation = field.up('window').down('map').locationRecord;
@@ -108,6 +135,12 @@
}
},
+ /**
+ * This function updates the Longitude (right-value / x-value) of a feature
+ * (geospatial object). The feature can be a marker in the map
+ * @param {Ext.form.field.Field} field the Ext.field which was altered
+ * @param {} nValue the new Longitude as WGS84 in decimaldegrees
+ */
updateFeatureLongitude: function(field, nValue) {
var layer = field.up('window').down('map').selectControl.layer;
var newLocation = field.up('window').down('map').locationRecord;
diff -r 2e8da590ea0c -r 6e28ebbe1a73 app/controller/form/Messung.js
--- a/app/controller/form/Messung.js Mon Apr 20 16:07:40 2015 +0200
+++ b/app/controller/form/Messung.js Thu Apr 23 16:28:04 2015 +0200
@@ -6,9 +6,16 @@
* the documentation coming with IMIS-Labordaten-Application for details.
*/
+/**
+ * This is a controller for a Messung form
+ */
Ext.define('Lada.controller.form.Messung', {
extend: 'Ext.app.Controller',
+ /**
+ * Initialize the Controller
+ * It has 3 listeners
+ */
init: function() {
this.control({
'messungform button[action=save]': {
@@ -23,6 +30,11 @@
});
},
+ /**
+ * The save function saves the content of the Location form.
+ * On success it will reload the Store,
+ * on failure, it will display an Errormessage
+ */
save: function(button) {
var formPanel = button.up('form');
formPanel.setLoading(true);
@@ -95,12 +107,25 @@
});
},
- discard: function(button) {
+ /**
+ * The discard function resets the Location form
+ * to its original state.
+ */
+ discard: function(button) {
var formPanel = button.up('form');
formPanel.getForm().loadRecord(formPanel.getForm().getRecord());
},
- dirtyForm: function(form, dirty) {
+ /**
+ * The dirtyForm function enables or disables the save and discard
+ * button which are present in the toolbar of the form.
+ * The Buttons are only active if the content of the form was altered
+ * (the form is dirty).
+ * In Additon it calls the disableChildren() function of the window
+ * embedding the form. Only when the record does not carry the readonly
+ * flag, the function calls the embedding windows enableChilren() function
+ */
+ dirtyForm: function(form, dirty) {
if (dirty) {
form.owner.down('button[action=save]').setDisabled(false);
form.owner.down('button[action=discard]').setDisabled(false);
diff -r 2e8da590ea0c -r 6e28ebbe1a73 app/controller/form/Ort.js
--- a/app/controller/form/Ort.js Mon Apr 20 16:07:40 2015 +0200
+++ b/app/controller/form/Ort.js Thu Apr 23 16:28:04 2015 +0200
@@ -6,9 +6,15 @@
* the documentation coming with IMIS-Labordaten-Application for details.
*/
+/*
+ * This is a controller for an Ort Form
+ */
Ext.define('Lada.controller.form.Ort', {
extend: 'Ext.app.Controller',
+ /**
+ * Initialize the Controller with 4 listeners
+ */
init: function() {
this.control({
'ortform button[action=save]': {
@@ -26,7 +32,12 @@
});
},
- save: function(button) {
+ /**
+ * The save function saves the content of the Location form.
+ * On success it will reload the Store,
+ * on failure, it will display an Errormessage
+ */
+ save: function(button) {
var formPanel = button.up('ortform');
var data = formPanel.getForm().getFieldValues(true);
for (var key in data) {
@@ -72,7 +83,11 @@
});
},
- discard: function(button) {
+ /**
+ * The discard function resets the Location form
+ * to its original state.
+ */
+ discard: function(button) {
var formPanel = button.up('form');
formPanel.getForm().loadRecord(formPanel.getForm().getRecord());
var win = button.up('window');
@@ -82,6 +97,12 @@
win.down('map').selectFeature(id);
},
+ /**
+ * The dirtyForm function enables or disables the save and discard
+ * button which are present in the toolbar of the form.
+ * The Buttons are only active if the content of the form was altered
+ * (the form is dirty).
+ */
dirtyForm: function(form, dirty) {
if (dirty) {
form.owner.down('button[action=save]').setDisabled(false);
@@ -93,6 +114,11 @@
}
},
+ /**
+ * updateDetails is used when a value is selected within the ort combobox
+ * When this function is called, the map element within the window
+ * which is embedding this form is updated.
+ */
updateDetails: function(combobox, record) {
var win = combobox.up('window');
var details = win.down('locationform');
diff -r 2e8da590ea0c -r 6e28ebbe1a73 app/controller/form/Probe.js
--- a/app/controller/form/Probe.js Mon Apr 20 16:07:40 2015 +0200
+++ b/app/controller/form/Probe.js Thu Apr 23 16:28:04 2015 +0200
@@ -6,9 +6,16 @@
* the documentation coming with IMIS-Labordaten-Application for details.
*/
+/**
+ * A Controller for a Probe form
+ */
Ext.define('Lada.controller.form.Probe', {
extend: 'Ext.app.Controller',
+ /**
+ * Initialize the Controller
+ * It has 4 listeners
+ */
init: function() {
this.control({
'probeform button[action=save]': {
@@ -26,6 +33,11 @@
});
},
+ /**
+ * The save function saves the content of the Location form.
+ * On success it will reload the Store,
+ * on failure, it will display an Errormessage
+ */
save: function(button) {
var formPanel = button.up('form');
var data = formPanel.getForm().getFieldValues(true);
@@ -85,11 +97,24 @@
});
},
+ /**
+ * The discard function resets the Location form
+ * to its original state.
+ */
discard: function(button) {
var formPanel = button.up('form');
formPanel.getForm().loadRecord(formPanel.getForm().getRecord());
},
+ /**
+ * The dirtyForm function enables or disables the save and discard
+ * button which are present in the toolbar of the form.
+ * The Buttons are only active if the content of the form was altered
+ * (the form is dirty).
+ * In Additon it calls the disableChildren() function of the window
+ * embedding the form. Likewise it calls the embedding windows
+ * enableChilren() function
+ */
dirtyForm: function(form, dirty) {
if (dirty) {
form.owner.down('button[action=save]').setDisabled(false);
@@ -103,6 +128,13 @@
}
},
+ /**
+ * checkDate() is called when a xtype=datetime field was modified
+ * It checks for two things:
+ * - Is the date in the future
+ * - Does the date belong to a time period and the end is before start
+ * In both cases it adds a warning to the field which was checked.
+ */
checkDate: function(field) {
var now = Date.now();
var w = 0 //amount of warnings
diff -r 2e8da590ea0c -r 6e28ebbe1a73 app/controller/grid/MKommentar.js
--- a/app/controller/grid/MKommentar.js Mon Apr 20 16:07:40 2015 +0200
+++ b/app/controller/grid/MKommentar.js Thu Apr 23 16:28:04 2015 +0200
@@ -6,9 +6,18 @@
* the documentation coming with IMIS-Labordaten-Application for details.
*/
+/**
+ * This is a controller for a grid of MKommentar
+ * MKommentar are comments which are associated to a
+ * Measurement
+ */
Ext.define('Lada.controller.grid.MKommentar', {
extend: 'Ext.app.Controller',
+ /**
+ * Inhitialize the controller
+ * It has 3 listeners
+ */
init: function() {
this.control({
'mkommentargrid': {
@@ -24,6 +33,12 @@
});
},
+ /**
+ * 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(record, response) {
@@ -46,6 +61,10 @@
});
},
+ /**
+ * 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') === '') {
@@ -53,6 +72,9 @@
}
},
+ /**
+ * This function adds a new row to add a MKommentar
+ */
add: function(button) {
var record = Ext.create('Lada.model.MKommentar');
record.set('messungsId', button.up('mkommentargrid').recordId);
@@ -60,6 +82,12 @@
button.up('mkommentargrid').rowEditing.startEdit(0, 1);
},
+ /**
+ * A Mkommentar-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];
diff -r 2e8da590ea0c -r 6e28ebbe1a73 app/controller/grid/Messung.js
--- a/app/controller/grid/Messung.js Mon Apr 20 16:07:40 2015 +0200
+++ b/app/controller/grid/Messung.js Thu Apr 23 16:28:04 2015 +0200
@@ -16,6 +16,10 @@
'Lada.view.window.MessungEdit'
],
+ /**
+ * Inhitialize the controller
+ * It has 3 listeners
+ */
init: function() {
this.control({
'messunggrid': {
@@ -30,6 +34,10 @@
});
},
+ /**
+ * This function opens a new {@link Lada.view.window.MessungEdit}
+ * Window.
+ */
editItem: function(grid, record) {
var probe = grid.up('window').record;
var win = Ext.create('Lada.view.window.MessungEdit', {
@@ -42,6 +50,9 @@
win.initData();
},
+ /**
+ * This function opens a window add a Messung
+ */
add: function(button) {
var probe = button.up('window').record;
var win = Ext.create('Lada.view.window.MessungCreate', {
@@ -52,6 +63,13 @@
win.initData();
},
+ /**
+ * This function removes a Messung
+ * It displays a Confirmation-Popup.
+ * When the Removal was confirmed and the operation was successful,
+ * the Messung-row is removed from the grid.
+ * On failure an Errormessage is shown
+ */
remove: function(button) {
var grid = button.up('grid');
var selection = grid.getView().getSelectionModel().getSelection()[0];
diff -r 2e8da590ea0c -r 6e28ebbe1a73 app/controller/grid/Messwert.js
--- a/app/controller/grid/Messwert.js Mon Apr 20 16:07:40 2015 +0200
+++ b/app/controller/grid/Messwert.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 Messwert Grid
+ */
Ext.define('Lada.controller.grid.Messwert', {
extend: 'Ext.app.Controller',
- init: function() {
+ /**
+ * Inhitialize the controller
+ * It has 3 listeners
+ */
+ init: function() {
this.control({
'messwertgrid': {
edit: this.gridSave,
@@ -24,6 +31,12 @@
});
},
+ /**
+ * 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(request, response) {
@@ -59,6 +72,10 @@
});
},
+ /**
+ * 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') === '') {
@@ -66,6 +83,9 @@
}
},
+ /**
+ * This function adds a new row to add a Messwert
+ */
add: function(button) {
var record = Ext.create('Lada.model.Messwert', {
messungsId: button.up('messwertgrid').recordId
@@ -74,7 +94,13 @@
button.up('messwertgrid').rowEditing.startEdit(0, 1);
},
- remove: function(button) {
+ /**
+ * A Messwert-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) {
diff -r 2e8da590ea0c -r 6e28ebbe1a73 app/controller/grid/Ort.js
--- a/app/controller/grid/Ort.js Mon Apr 20 16:07:40 2015 +0200
+++ b/app/controller/grid/Ort.js Thu Apr 23 16:28:04 2015 +0200
@@ -6,6 +6,9 @@
* the documentation coming with IMIS-Labordaten-Application for details.
*/
+/**
+ * This is a controller for a grid of Orte
+ */
Ext.define('Lada.controller.grid.Ort', {
extend: 'Ext.app.Controller',
@@ -14,6 +17,10 @@
'Lada.view.window.OrtCreate'
],
+ /**
+ * Inhitialize the controller
+ * It has 3 listeners
+ */
init: function() {
this.control({
'ortgrid': {
@@ -28,6 +35,10 @@
});
},
+ /**
+ * When open is called, a {@link Lada.view.window.OrtEdit}
+ * is created which allows to edit the Orte
+ */
open: function(grid, record) {
var probe = grid.up('window').record;
var win = Ext.create('Lada.view.window.OrtEdit', {
@@ -40,6 +51,9 @@
win.initData();
},
+ /**
+ * This function adds a new row to add an Ort
+ */
add: function(button) {
var probe = button.up('window').record;
var win = Ext.create('Lada.view.window.OrtCreate', {
@@ -50,6 +64,12 @@
win.initData();
},
+ /**
+ * A Ort-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];
diff -r 2e8da590ea0c -r 6e28ebbe1a73 app/controller/grid/PKommentar.js
--- a/app/controller/grid/PKommentar.js Mon Apr 20 16:07:40 2015 +0200
+++ b/app/controller/grid/PKommentar.js Thu Apr 23 16:28:04 2015 +0200
@@ -6,9 +6,16 @@
* the documentation coming with IMIS-Labordaten-Application for details.
*/
-Ext.define('Lada.controller.grid.PKommentar', {
+/**
+ * This is a controller for a grid of Orte
+ */
+EExt.define('Lada.controller.grid.PKommentar', {
extend: 'Ext.app.Controller',
+ /**
+ * Initialize the Controller with
+ * 3 Listeners
+ */
init: function() {
this.control({
'pkommentargrid': {
@@ -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.store.reload();
@@ -49,21 +62,34 @@
});
},
- 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 PKommentar
+ */
+ add: function(button) {
var record = Ext.create('Lada.model.PKommentar');
record.set('probeId', button.up('pkommentargrid').recordId);
button.up('pkommentargrid').store.insert(0, record);
button.up('pkommentargrid').rowEditing.startEdit(0, 1);
},
- remove: function(button) {
+ /**
+ * A PKommentar-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('Löschen', 'Sind Sie sicher?', function(btn) {
diff -r 2e8da590ea0c -r 6e28ebbe1a73 app/controller/grid/Probenzusatzwert.js
--- a/app/controller/grid/Probenzusatzwert.js Mon Apr 20 16:07:40 2015 +0200
+++ b/app/controller/grid/Probenzusatzwert.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 Probenzusatzwert
+ */
Ext.define('Lada.controller.grid.Probenzusatzwert', {
extend: 'Ext.app.Controller',
- init: function() {
+ /**
+ * Initialize the Controller with
+ * 3 Listeners
+ */
+ init: function() {
this.control({
'probenzusatzwertgrid': {
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.store.reload();
@@ -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 Probenzusatzwert
+ */
+ add: function(button) {
var record = Ext.create('Lada.model.Zusatzwert', {
probeId: button.up('probenzusatzwertgrid').recordId
});
@@ -64,7 +84,13 @@
button.up('probenzusatzwertgrid').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('Zusatzwert löschen', 'Sind Sie sicher?', function(btn) {
diff -r 2e8da590ea0c -r 6e28ebbe1a73 app/controller/grid/Status.js
--- 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) {
More information about the Lada-commits
mailing list