Mercurial > lada > lada-client
changeset 823:5ed0e6273888
Only enable delete button in grids when an entry was selected
author | Dustin Demuth <dustin@intevation.de> |
---|---|
date | Fri, 29 May 2015 14:03:18 +0200 |
parents | a0666d755405 |
children | fab0b7be5aca |
files | app/view/grid/Messung.js app/view/grid/Ort.js app/view/grid/PKommentar.js app/view/grid/Probenzusatzwert.js app/view/window/ProbeEdit.js |
diffstat | 5 files changed, 144 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/app/view/grid/Messung.js Fri May 29 14:02:21 2015 +0200 +++ b/app/view/grid/Messung.js Fri May 29 14:03:18 2015 +0200 @@ -25,6 +25,8 @@ warnings: null, errors: null, + readOnly: true, + allowDeselect: true, initComponent: function() { this.dockedItems = [{ @@ -121,8 +123,19 @@ return '<div id="' + id + '">Lade...</div>'; } }]; + this.listeners = { + select: { + fn: this.activateRemoveButton, + scope: this + }, + deselect: { + fn: this.deactivateRemoveButton, + scope: this + } + }; this.initData(); this.callParent(arguments); + this.setReadOnly(true); //Grid is always initialised as RO }, initData: function() { @@ -212,8 +225,29 @@ if (this.getPlugin('rowedit')){ this.getPlugin('rowedit').enable(); } - this.down('button[action=delete]').enable(); + //this.down('button[action=delete]').enable(); + //always disabled, unless a row was selected this.down('button[action=add]').enable(); } + }, + /** + * Activate the Remove Button + */ + activateRemoveButton: function(selection, record) { + var grid = this; + //only enable the remove buttone, when the grid is editable. + if (! grid.readOnly) { + grid.down('button[action=delete]').enable(); + } + }, + /** + * Activate the Remove Button + */ + deactivateRemoveButton: function(selection, record) { + var grid = this; + //only enable the remove buttone, when the grid is editable. + if (! grid.readOnly) { + grid.down('button[action=delete]').disable(); + } } });
--- a/app/view/grid/Ort.js Fri May 29 14:02:21 2015 +0200 +++ b/app/view/grid/Ort.js Fri May 29 14:03:18 2015 +0200 @@ -27,6 +27,8 @@ warnings: null, errors: null, + readOnly: true, + allowDeselect: true, initComponent: function() { this.dockedItems = [{ @@ -92,8 +94,19 @@ return record.get('bezeichnung'); } }]; + this.listeners = { + select: { + fn: this.activateRemoveButton, + scope: this + }, + deselect: { + fn: this.deactivateRemoveButton, + scope: this + } + }; this.initData(); this.callParent(arguments); + this.setReadOnly(true); //Grid is always initialised as RO }, initData: function() { @@ -134,5 +147,25 @@ this.down('button[action=delete]').enable(); this.down('button[action=add]').enable(); } + }, + /** + * Activate the Remove Button + */ + activateRemoveButton: function(selection, record) { + var grid = this; + //only enable the remove buttone, when the grid is editable. + if (! grid.readOnly) { + grid.down('button[action=delete]').enable(); + } + }, + /** + * Activate the Remove Button + */ + deactivateRemoveButton: function(selection, record) { + var grid = this; + //only enable the remove buttone, when the grid is editable. + if (! grid.readOnly) { + grid.down('button[action=delete]').disable(); + } } });
--- a/app/view/grid/PKommentar.js Fri May 29 14:02:21 2015 +0200 +++ b/app/view/grid/PKommentar.js Fri May 29 14:03:18 2015 +0200 @@ -26,6 +26,8 @@ }, recordId: null, + readOnly: true, + allowDeselect: true, initComponent: function() { this.rowEditing = Ext.create('Ext.grid.plugin.RowEditing', { @@ -103,8 +105,19 @@ allowBlank: false } }]; + this.listeners = { + select: { + fn: this.activateRemoveButton, + scope: this + }, + deselect: { + fn: this.deactivateRemoveButton, + scope: this + } + }; this.initData(); this.callParent(arguments); + this.setReadOnly(true); //Grid is always initialised as RO }, initData: function() { @@ -132,5 +145,26 @@ this.down('button[action=delete]').enable(); this.down('button[action=add]').enable(); } + }, + /** + * Activate the Remove Button + */ + activateRemoveButton: function(selection, record) { + var grid = this; + //only enable the remove buttone, when the grid is editable. + if (! grid.readOnly) { + grid.down('button[action=delete]').enable(); + } + }, + /** + * Activate the Remove Button + */ + deactivateRemoveButton: function(selection, record) { + var grid = this; + //only enable the remove buttone, when the grid is editable. + if (! grid.readOnly) { + grid.down('button[action=delete]').disable(); + } } + });
--- a/app/view/grid/Probenzusatzwert.js Fri May 29 14:02:21 2015 +0200 +++ b/app/view/grid/Probenzusatzwert.js Fri May 29 14:03:18 2015 +0200 @@ -25,6 +25,8 @@ margin: '0, 5, 5, 5', recordId: null, + readOnly: true, + allowDeselect: true, initComponent: function() { this.rowEditing = Ext.create('Ext.grid.plugin.RowEditing', { @@ -150,8 +152,19 @@ allowDecimal: false } }]; + this.listeners = { + select: { + fn: this.activateRemoveButton, + scope: this + }, + deselect: { + fn: this.deactivateRemoveButton, + scope: this + } + }; this.initData(); this.callParent(arguments); + this.setReadOnly(true); //Grid is always initialised as RO }, initData: function() { @@ -179,5 +192,26 @@ this.down('button[action=delete]').enable(); this.down('button[action=add]').enable(); } + }, + /** + * Activate the Remove Button + */ + activateRemoveButton: function(selection, record) { + var grid = this; + //only enable the remove buttone, when the grid is editable. + if (! grid.readOnly) { + grid.down('button[action=delete]').enable(); + } + }, + /** + * Activate the Remove Button + */ + deactivateRemoveButton: function(selection, record) { + var grid = this; + //only enable the remove buttone, when the grid is editable. + if (! grid.readOnly) { + grid.down('button[action=delete]').disable(); + } } + });
--- a/app/view/window/ProbeEdit.js Fri May 29 14:02:21 2015 +0200 +++ b/app/view/window/ProbeEdit.js Fri May 29 14:03:18 2015 +0200 @@ -169,17 +169,25 @@ // Disable only when the User is not the owner of the Probe // Works in symbiosis with success callback some lines above. this.down('fset[name=messungen]').down('messunggrid').setReadOnly(true); + this.down('fset[name=messungen]').down('messunggrid').readOnly = true; } this.down('fset[name=orte]').down('ortgrid').setReadOnly(true); + this.down('fset[name=orte]').down('ortgrid').readOnly = true; this.down('fset[name=probenzusatzwerte]').down('probenzusatzwertgrid').setReadOnly(true); + this.down('fset[name=probenzusatzwerte]').down('probenzusatzwertgrid').readOnly = true; this.down('fset[name=pkommentare]').down('pkommentargrid').setReadOnly(true); + this.down('fset[name=pkommentare]').down('pkommentargrid').readOnly = true; }, enableChildren: function() { this.down('fset[name=messungen]').down('messunggrid').setReadOnly(false); + this.down('fset[name=messungen]').down('messunggrid').readOnly = false; this.down('fset[name=orte]').down('ortgrid').setReadOnly(false); + this.down('fset[name=orte]').down('ortgrid').readOnly = false; this.down('fset[name=probenzusatzwerte]').down('probenzusatzwertgrid').setReadOnly(false); + this.down('fset[name=probenzusatzwerte]').down('probenzusatzwertgrid').readOnly = false; this.down('fset[name=pkommentare]').down('pkommentargrid').setReadOnly(false); + this.down('fset[name=pkommentare]').down('pkommentargrid').readOnly = false; }, setMessages: function(errors, warnings) {