From 3d39ace7fabab6dacabfe1d52b812330b8548fbe Mon Sep 17 00:00:00 2001 From: Brian Bolt Date: Tue, 21 Apr 2020 09:32:56 -0700 Subject: [PATCH] fixes #680 add disableEditMyParents option --- .../CmpdReg/src/client/custom/configuration.json | 1 + modules/CmpdReg/src/client/src/MetaLot.js | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/modules/CmpdReg/src/client/custom/configuration.json b/modules/CmpdReg/src/client/custom/configuration.json index d653af3bf..012bfeb9d 100755 --- a/modules/CmpdReg/src/client/custom/configuration.json +++ b/modules/CmpdReg/src/client/custom/configuration.json @@ -40,6 +40,7 @@ "disableAliasEdit": false, "showLotInventory": false, "disableEditMyLots": false, + "disableEditMyParents": true, "requireLotNumber": false, "allowManualLotNumber": false, "autoPopulateNextLotNumber": false diff --git a/modules/CmpdReg/src/client/src/MetaLot.js b/modules/CmpdReg/src/client/src/MetaLot.js index 2ae999091..006cdd6c6 100755 --- a/modules/CmpdReg/src/client/src/MetaLot.js +++ b/modules/CmpdReg/src/client/src/MetaLot.js @@ -440,13 +440,22 @@ $(function() { }, parentAllowedToUpdate: function () { - if (!this.allowedToUpdate()) return false; + // Check if disableEditMyParents is defined and true. If its true and the user is not an admin, then we disable the allowed to update feature + if(typeof(window.configuration.metaLot.disableEditMyParents) != "undefined" && window.configuration.metaLot.disableEditMyParents != null && window.configuration.metaLot.disableEditMyParents) { + if (!this.user.get('isAdmin')) return false; + } + // Further check to see if the parent is editable by checking the metalot allowedToUpdate function + if (!this.allowedToUpdate()) return false; - if (this.model.get('lot').isNew() ) { + // If we get here, then just check if the lot is new or not + if (this.model.get('lot').isNew()) { return false; } else { return true; - } + } + + // We shouldn't get here but lets disable edit parent by default to be safe + return false } }); });