Skip to content

Commit

Permalink
Merge branch 'pu/cw/modelGrantNames' into '2024.11'
Browse files Browse the repository at this point in the history
tweak(Tinebase): allow generic model dependend grant names

See merge request tine20/tine20!4874
  • Loading branch information
corneliusweiss committed Feb 1, 2024
2 parents a47aea6 + 3059eae commit e974738
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions tine20/Tinebase/js/widgets/ActionUpdater.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@
getGrantsSum: function(records) {

var _ = window.lodash,
modelNamePrefix = this.recordClass?.getMeta('modelName') + '_',
defaultGrant = records.length == 0 ? false : true,
grants = {
addGrant: defaultGrant,
Expand All @@ -244,6 +245,7 @@
if (! this.evalGrants) {
return grants;
}


var recordGrants;
for (var i=0; i<records.length; i++) {
Expand All @@ -254,7 +256,8 @@
}

for (var grant in grants) {
grants[grant] = _.get(grants, grant, false) && _.get(recordGrants, grant, false);
// e.g. readGrant || Document_Invoice_readGrant
grants[grant] = _.get(grants, grant, false) && (_.get(recordGrants, grant, false) || _.get(recordGrants, modelNamePrefix+grant, false));
}

// custom grants model
Expand All @@ -264,7 +267,7 @@
}
}
// if calculated admin right is true, overwrite all grants with true
if(grants.adminGrant) {
if(grants.adminGrant || grants[modelNamePrefix + 'adminGrant']) {
for (var grant in grants) {
grants[grant] = true;
}
Expand Down

0 comments on commit e974738

Please sign in to comment.