improves container selector grants check
authorPhilipp Schüle <p.schuele@metaways.de>
Mon, 29 Feb 2016 14:40:25 +0000 (15:40 +0100)
committerPhilipp Schüle <p.schuele@metaways.de>
Mon, 29 Feb 2016 14:52:44 +0000 (15:52 +0100)
... admin grants includes others

Change-Id: Iac9b8e4889365444cd2535b08f8d9fb607f09d49
Reviewed-on: http://gerrit.tine20.com/customers/2825
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
Tested-by: Philipp Schüle <p.schuele@metaways.de>
tine20/Tinebase/js/widgets/dialog/EditDialog.js

index 3f80127..f9e794e 100644 (file)
@@ -518,14 +518,14 @@ Tine.widgets.dialog.EditDialog = Ext.extend(Ext.FormPanel, {
                     scope: this,
                     select: function() {    
                         // enable or disable save button dependent to containers account grants
-                        var grants = this.containerSelectCombo.selectedContainer ? this.containerSelectCombo.selectedContainer.account_grants : {};
-                        // on edit check editGrant, on add check addGrant
-                        if (this.record.data.id) {  // edit if record has already an id
-                            var disable = grants.hasOwnProperty('editGrant') ? ! grants.editGrant : false;
-                        } else {
-                            var disable = grants.hasOwnProperty('addGrant') ? ! grants.addGrant : false;
-                        }
-                        this.action_saveAndClose.setDisabled(disable);
+                        // on edit: check editGrant, on add: check addGrant
+                        var grants = this.containerSelectCombo.selectedContainer
+                            ? this.containerSelectCombo.selectedContainer.account_grants : {},
+                            grantToCheck = (this.record.data.id) ? 'editGrant' : 'addGrant',
+                            enabled =  grants.hasOwnProperty(grantToCheck) && grants[grantToCheck]
+                                    || grants.hasOwnProperty('adminGrant') && grants.adminGrant ? true : false;
+
+                        this.action_saveAndClose.setDisabled(! enabled);
                     }
                 }
             });