# HG changeset patch # User Dustin Demuth # Date 1432900998 -7200 # Node ID 5ed0e6273888c8c86f3647cc78e88f8ded733c5d # Parent a0666d755405ff8c8ab2f2d5f51730d036bed3af Only enable delete button in grids when an entry was selected diff -r a0666d755405 -r 5ed0e6273888 app/view/grid/Messung.js --- 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 '
Lade...
'; } }]; + 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(); + } } }); diff -r a0666d755405 -r 5ed0e6273888 app/view/grid/Ort.js --- 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(); + } } }); diff -r a0666d755405 -r 5ed0e6273888 app/view/grid/PKommentar.js --- 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(); + } } + }); diff -r a0666d755405 -r 5ed0e6273888 app/view/grid/Probenzusatzwert.js --- 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(); + } } + }); diff -r a0666d755405 -r 5ed0e6273888 app/view/window/ProbeEdit.js --- 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) {