fix grant evaluation in editDialogs
authorCornelius Weiß <c.weiss@metaways.de>
Fri, 14 Jul 2017 15:54:37 +0000 (17:54 +0200)
committerCornelius Weiss <c.weiss@metaways.de>
Fri, 14 Jul 2017 15:57:05 +0000 (17:57 +0200)
- evalt grants for cfs
- don't eval grants for non grant aware apps

Change-Id: I49c3eb9b8b73afb93f070df90cfaef7b69cf057e
Reviewed-on: http://gerrit.tine20.com/customers/5183
Reviewed-by: Cornelius Weiss <c.weiss@metaways.de>
Tested-by: Cornelius Weiss <c.weiss@metaways.de>
tine20/Filemanager/js/DownloadLinkGridPanel.js
tine20/Filemanager/js/GrantsPanel.js
tine20/Filemanager/js/NotificationPanel.js
tine20/Projects/js/ProjectEditDialog.js
tine20/Tinebase/js/widgets/ActivitiesGridPanel.js
tine20/Tinebase/js/widgets/customfields/Field.js
tine20/Tinebase/js/widgets/dialog/AttachmentsGridPanel.js
tine20/Tinebase/js/widgets/dialog/EditDialog.js
tine20/Tinebase/js/widgets/grid/LinkGridPanel.js
tine20/Tinebase/js/widgets/relation/GenericPickerGridPanel.js

index 3e9def6..e10208c 100644 (file)
@@ -42,7 +42,8 @@ Tine.Filemanager.DownloadLinkGridPanel = Ext.extend(Ext.grid.EditorGridPanel, {
     initComponent: function() {
         var _ = window.lodash,
             record = this.editDialog.record,
-            hasRequiredGrant = _.get(record, record.constructor.getMeta('grantsPath') + '.' + this.requiredGrant);
+            evalGrants = this.editDialog.evalGrants,
+            hasRequiredGrant = !evalGrants || _.get(record, record.constructor.getMeta('grantsPath') + '.' + this.requiredGrant);
 
         this.recordProxy = Tine.Filemanager.downloadLinkRecordBackend;
         this.recordClass = Tine.Filemanager.Model.DownloadLink;
index f819032..7798e9f 100644 (file)
@@ -85,7 +85,8 @@ Tine.Filemanager.GrantsPanel = Ext.extend(Ext.Panel, {
 
     onRecordLoad: function(editDialog, record, ticketFn) {
         var _ = window.lodash,
-            hasRequiredGrant = _.get(record, record.constructor.getMeta('grantsPath') + '.' + this.requiredGrant);
+            evalGrants = editDialog.evalGrants,
+            hasRequiredGrant = !evalGrants || _.get(record, record.constructor.getMeta('grantsPath') + '.' + this.requiredGrant);
 
         this.hasOwnGrantsCheckbox.setDisabled(! lodash.get(record, 'data.account_grants.adminGrant', false)
             || record.get('type') != 'folder');
index 3d65122..094aa94 100644 (file)
@@ -80,7 +80,8 @@ Tine.Filemanager.NotificationPanel = Ext.extend(Ext.Panel, {
             featureEnabled = _.get(Tine.Tinebase.configManager.get('filesystem'), 'enableNotifications', false),
             notificationProps = window.lodash.get(record, 'data.notificationProps', []),
             hasOwnNotificationSettings = !!notificationProps.length,
-            hasRequiredGrant = _.get(record, record.constructor.getMeta('grantsPath') + '.' + this.requiredGrant),
+            evalGrants = editDialog.evalGrants,
+            hasRequiredGrant = !evalGrants || _.get(record, record.constructor.getMeta('grantsPath') + '.' + this.requiredGrant),
             hasAdminGrant = _.get(this.editDialog, 'record.data.account_grants.adminGrant', false);
 
         this.notificationGrid.getStore().loadData(_.get(record, 'data.notificationProps', []), false);
index 4272803..df75032 100644 (file)
@@ -74,6 +74,7 @@ Tine.Projects.ProjectEditDialog = Ext.extend(Tine.widgets.dialog.EditDialog, {
     getFormItems: function() {
         this.contactLinkPanel = new Tine.widgets.grid.LinkGridPanel({
             app: this.app,
+            editDialog: this,
             searchRecordClass: Tine.Addressbook.Model.Contact,
             newRecordClass: Tine.Addressbook.Model.Contact,
             title: this.app.i18n._('Attendee'),
index 19f925a..2ab2305 100644 (file)
@@ -183,15 +183,16 @@ Tine.widgets.activities.ActivitiesGridPanel = Ext.extend(Ext.grid.GridPanel, {
     /**
      * populate store
      *
-     * @param {EditDialog} activities
+     * @param {EditDialog} editDialog
      * @param {Record} record
      * @param {Function} ticketFn
      */
-    onLoadRecord: function (activities, record, ticketFn) {
+    onLoadRecord: function (editDialog, record, ticketFn) {
         var _ = window.lodash,
             interceptor = ticketFn(),
             notes = record.get('notes'),
-            hasRequiredGrant = _.get(record, record.constructor.getMeta('grantsPath') + '.' + this.requiredGrant);
+            evalGrants = editDialog.evalGrants,
+            hasRequiredGrant = !evalGrants || _.get(record, record.constructor.getMeta('grantsPath') + '.' + this.requiredGrant);
 
         this.store.removeAll();
 
index 5254ad7..ff89a08 100644 (file)
@@ -62,7 +62,8 @@ Tine.widgets.customfields.Field = Ext.extend(Ext.Panel, {
                 name: 'customfield_' + cfConfig.get('name'),
                 xtype: (def.value_search == 1) ? 'customfieldsearchcombo' : uiConfig.xtype,
                 customfieldId: cfConfig.id,
-                readOnly: cfConfig.get('account_grants').indexOf('writeGrant') < 0
+                readOnly: cfConfig.get('account_grants').indexOf('writeGrant') < 0,
+                requiredGrant: 'editGrant'
             };
             
             // auto xtype per data type
index 721fbe0..46c77e0 100644 (file)
@@ -197,15 +197,16 @@ Tine.widgets.dialog.AttachmentsGridPanel = Ext.extend(Tine.widgets.grid.FileUplo
     /**
      * populate store
      * 
-     * @param {EditDialog} dialog
+     * @param {EditDialog} editDialog
      * @param {Record} record
      * @param {Function} ticketFn
      */
-    onLoadRecord: function(dialog, record, ticketFn) {
+    onLoadRecord: function(editDialog, record, ticketFn) {
         var _ = window.lodash,
             interceptor = ticketFn(),
             attachments = record.get('attachments'),
-            hasRequiredGrant = _.get(record, record.constructor.getMeta('grantsPath') + '.' + this.requiredGrant);
+            evalGrants = editDialog.evalGrants,
+            hasRequiredGrant = !evalGrants || _.get(record, record.constructor.getMeta('grantsPath') + '.' + this.requiredGrant);
 
         this.store.removeAll();
 
index 4391e7a..bda7b86 100644 (file)
@@ -332,6 +332,13 @@ Tine.widgets.dialog.EditDialog = Ext.extend(Ext.FormPanel, {
                 recordClass: this.recordClass
             });
         }
+
+        var grantsField = this.recordClass.getMeta('grantsPath')
+            .replace(/^data\./, '')
+            .replace(/\.+/g, '');
+
+        this.evalGrants = this.evalGrants && (grantsField == 'data' || this.recordClass.hasField(grantsField));
+
         // init plugins
         this.plugins = Ext.isString(this.plugins) ? Ext.decode(this.plugins) : Ext.isArray(this.plugins) ? this.plugins.concat(Ext.decode(this.initialConfig.plugins)) : [];
         
index 888baaa..4679540 100644 (file)
@@ -36,6 +36,8 @@ Tine.widgets.grid.LinkGridPanel = Ext.extend(Tine.widgets.grid.PickerGridPanel,
     clicksToEdit: 1,
     selectRowAfterAdd: false,
 
+    editDialog: null,
+
     /**
      * the record
      * @type Record 
@@ -203,7 +205,8 @@ Tine.widgets.grid.LinkGridPanel = Ext.extend(Tine.widgets.grid.PickerGridPanel,
      */
     onRecordLoad: function(record) {
         var _ = window.lodash,
-            hasRequiredGrant = _.get(record, record.constructor.getMeta('grantsPath') + '.' + this.requiredGrant);
+            evalGrants = this.editDialog.evalGrants,
+            hasRequiredGrant = !evalGrants || _.get(record, record.constructor.getMeta('grantsPath') + '.' + this.requiredGrant);
 
 
         if (this.record) {
index fe9d5bd..912a872 100644 (file)
@@ -1154,7 +1154,8 @@ Tine.widgets.relation.GenericPickerGridPanel = Ext.extend(Tine.widgets.grid.Pick
     loadRecord: function(dialog, record, ticketFn) {
         var _ = window.lodash,
             interceptor = ticketFn(),
-            hasRequiredGrant = _.get(record, record.constructor.getMeta('grantsPath') + '.' + this.requiredGrant);
+            evalGrants = dialog.evalGrants,
+            hasRequiredGrant = !evalGrants || _.get(record, record.constructor.getMeta('grantsPath') + '.' + this.requiredGrant);
 
         this.store.removeAll();