0013280: can't set attendee status for non organisers via editDialog
authorCornelius Weiß <c.weiss@metaways.de>
Thu, 29 Jun 2017 13:29:11 +0000 (15:29 +0200)
committersstamer <s.stamer@metaways.de>
Tue, 4 Jul 2017 10:04:22 +0000 (12:04 +0200)
Change-Id: Ie2eb525fb91e023c9a97f3b99068c911b5ff019f
Reviewed-on: http://gerrit.tine20.com/customers/4981
Reviewed-by: sstamer <s.stamer@metaways.de>
Tested-by: sstamer <s.stamer@metaways.de>
20 files changed:
tine20/Calendar/js/AttendeeGridPanel.js
tine20/Calendar/js/EventEditDialog.js
tine20/Calendar/js/EventFinderOptionsDialog.js
tine20/Calendar/js/MainScreenCenterPanel.js
tine20/Calendar/js/Model.js
tine20/Filemanager/js/DownloadLinkGridPanel.js
tine20/Filemanager/js/GrantsPanel.js
tine20/Filemanager/js/NodeEditDialog.js
tine20/Filemanager/js/NodeTreePanel.js
tine20/Filemanager/js/NotificationPanel.js
tine20/MailFiler/js/NodeTreePanel.js
tine20/Tinebase/js/data/Record.js
tine20/Tinebase/js/widgets/ActionUpdater.js
tine20/Tinebase/js/widgets/ActivitiesGridPanel.js
tine20/Tinebase/js/widgets/dialog/AttachmentsGridPanel.js
tine20/Tinebase/js/widgets/dialog/EditDialog.js
tine20/Tinebase/js/widgets/grid/FileUploadGrid.js
tine20/Tinebase/js/widgets/grid/GridPanel.js
tine20/Tinebase/js/widgets/grid/LinkGridPanel.js
tine20/Tinebase/js/widgets/relation/GenericPickerGridPanel.js

index 27119d1..da13fae 100644 (file)
@@ -570,10 +570,7 @@ Tine.Calendar.AttendeeGridPanel = Ext.extend(Ext.grid.EditorGridPanel, {
                     Tine.widgets.exportAction.SCOPE_SINGLE
                 );
 
-                var actionUpdater = new Tine.widgets.ActionUpdater({
-                    containerProperty: Tine.Calendar.Model.Resource.getMeta('containerProperty'),
-                    evalGrants: true
-                });
+                var actionUpdater = new Tine.widgets.ActionUpdater();
                 actionUpdater.addAction(exportAction);
                 actionUpdater.updateActions([resource]);
 
index 8f0833e..5d27297 100644 (file)
@@ -33,6 +33,7 @@ Tine.Calendar.EventEditDialog = Ext.extend(Tine.widgets.dialog.EditDialog, {
     recordProxy: Tine.Calendar.backend,
     showContainerSelector: false,
     displayNotes: true,
+    requiredSaveGrant: 'readGrant',
 
     mode: 'local',
 
@@ -547,16 +548,7 @@ Tine.Calendar.EventEditDialog = Ext.extend(Tine.widgets.dialog.EditDialog, {
         this.attendeeGridPanel.onRecordLoad(this.record);
         this.rrulePanel.onRecordLoad(this.record);
         this.alarmPanel.onRecordLoad(this.record);
-        
-        // apply grants
-        if (! this.record.get('editGrant')) {
-            this.getForm().items.each(function(f){
-                if(f.isFormField && f.requiredGrant !== undefined){
-                    f.setDisabled(! this.record.get(f.requiredGrant));
-                }
-            }, this);
-        }
-        
+
         this.perspectiveCombo.loadPerspective();
         // disable container selection combo if user has no right to edit
         this.containerSelect.setDisabled.defer(20, this.containerSelect, [(! this.record.get('editGrant'))]);
index 2a0e96d..20dbd8f 100644 (file)
@@ -103,10 +103,7 @@ Tine.Calendar.EventFinderOptionsDialog = Ext.extend(Ext.Panel, {
             iconCls: 'action_cancel'
         });
 
-        this.actionUpdater = new Tine.widgets.ActionUpdater({
-            containerProperty: this.recordClass ? this.recordClass.getMeta('containerProperty') : null,
-            evalGrants: this.evalGrants
-        });
+        this.actionUpdater = new Tine.widgets.ActionUpdater();
 
         this.actionUpdater.addActions([
             this.action_saveAndClose,
index cb226bf..c03373f 100644 (file)
@@ -360,9 +360,7 @@ Tine.Calendar.MainScreenCenterPanel = Ext.extend(Ext.Panel, {
         ];
         
         this.actionUpdater = new  Tine.widgets.ActionUpdater({
-            actions: this.recordActions,
-            grantsProperty: false,
-            containerProperty: false
+            actions: this.recordActions
         });
     },
 
index ddb8df6..66a078f 100644 (file)
@@ -71,6 +71,7 @@ Tine.Calendar.Model.Event = Tine.Tinebase.data.Record.create(Tine.Tinebase.Model
     recordName: 'Event',
     recordsName: 'Events',
     containerProperty: 'container_id',
+    grantsPath: 'data',
     // ngettext('Calendar', 'Calendars', n); gettext('Calendars');
     containerName: 'Calendar',
     containersName: 'Calendars',
index 6209a8e..3e9def6 100644 (file)
@@ -40,6 +40,10 @@ Tine.Filemanager.DownloadLinkGridPanel = Ext.extend(Ext.grid.EditorGridPanel, {
      * @private
      */
     initComponent: function() {
+        var _ = window.lodash,
+            record = this.editDialog.record,
+            hasRequiredGrant = _.get(record, record.constructor.getMeta('grantsPath') + '.' + this.requiredGrant);
+
         this.recordProxy = Tine.Filemanager.downloadLinkRecordBackend;
         this.recordClass = Tine.Filemanager.Model.DownloadLink;
         
@@ -61,7 +65,7 @@ Tine.Filemanager.DownloadLinkGridPanel = Ext.extend(Ext.grid.EditorGridPanel, {
         
         this.actionCreate = new Ext.Action({
             text: this.app.i18n._('Create Public Link'),
-            disabled: false,
+            disabled: !hasRequiredGrant,
             scope: this,
             handler: this.onCreate,
             iconCls: 'action_add'
@@ -69,7 +73,7 @@ Tine.Filemanager.DownloadLinkGridPanel = Ext.extend(Ext.grid.EditorGridPanel, {
         
         this.actionRemove = new Ext.Action({
             text: i18n._('Remove record'),
-            disabled: true,
+            disabled: !hasRequiredGrant,
             scope: this,
             handler: this.onRemove,
             iconCls: 'action_delete'
index db383c5..f819032 100644 (file)
@@ -24,6 +24,7 @@ Tine.Filemanager.GrantsPanel = Ext.extend(Ext.Panel, {
      */
     recordClass: Tine.Filemanager.Model.Node,
 
+    requiredGrant: 'editGrant',
     layout: 'fit',
     border: false,
 
@@ -83,6 +84,9 @@ Tine.Filemanager.GrantsPanel = Ext.extend(Ext.Panel, {
     },
 
     onRecordLoad: function(editDialog, record, ticketFn) {
+        var _ = window.lodash,
+            hasRequiredGrant = _.get(record, record.constructor.getMeta('grantsPath') + '.' + this.requiredGrant);
+
         this.hasOwnGrantsCheckbox.setDisabled(! lodash.get(record, 'data.account_grants.adminGrant', false)
             || record.get('type') != 'folder');
         this.hasOwnGrantsCheckbox.setValue(record.get('acl_node') == record.id);
@@ -90,7 +94,13 @@ Tine.Filemanager.GrantsPanel = Ext.extend(Ext.Panel, {
         this.grantsGrid.useGrant('admin', !!String(record.get('path')).match(/^\/shared/));
         this.grantsGrid.getStore().loadData(record.data);
 
-        // this.ownerCt[(record.get('type') == 'folder' ? 'un' : '') + 'hideTabStripItem'](this);
+        this.setReadOnly(! hasRequiredGrant);
+    },
+
+    setReadOnly: function(readOnly) {
+        this.readOnly = readOnly;
+        this.grantsGrid.setReadOnly(readOnly);
+        this.hasOwnGrantsCheckbox.setDisabled(readOnly);
     },
 
     onRecordUpdate: function(editDialog, record) {
index d4c3620..f8799e7 100644 (file)
@@ -35,6 +35,7 @@ Tine.Filemanager.NodeEditDialog = Ext.extend(Tine.widgets.dialog.EditDialog, {
     evalGrants: true,
     showContainerSelector: false,
     displayNotes: true,
+    requiredSaveGrant: 'readGrant',
     
     /**
      * @type Tine.Filemanager.DownloadLinkGridPanel
@@ -58,6 +59,7 @@ Tine.Filemanager.NodeEditDialog = Ext.extend(Tine.widgets.dialog.EditDialog, {
         
         Tine.Filemanager.NodeEditDialog.superclass.initComponent.call(this);
     },
+
     /**
      * folder or file?
      */
@@ -160,6 +162,7 @@ Tine.Filemanager.NodeEditDialog = Ext.extend(Tine.widgets.dialog.EditDialog, {
                             formDefaults: formFieldDefaults,
                             items: [[{
                                     fieldLabel: this.app.i18n._('Name'),
+                                    requiredGrant: 'editGrant',
                                     name: 'name',
                                     allowBlank: false,
                                     readOnly: false,
index fbc21f6..8ca7ebc 100644 (file)
@@ -305,8 +305,6 @@ Tine.Filemanager.NodeTreePanel = Ext.extend(Tine.widgets.container.TreePanel, {
         });
 
         this.actionUpdater = new Tine.widgets.ActionUpdater({
-            containerProperty: this.recordClass.getMeta('containerProperty'),
-            evalGrants: true,
             actions: this.ctxMenu.items
         });
     },
index ef706b4..3d65122 100644 (file)
@@ -14,6 +14,8 @@ Tine.Filemanager.NotificationPanel = Ext.extend(Ext.Panel, {
     layout: 'fit',
     border: false,
 
+    requiredGrant: 'readGrant',
+
     notificationGrid: null,
 
     initComponent: function () {
@@ -30,29 +32,16 @@ Tine.Filemanager.NotificationPanel = Ext.extend(Ext.Panel, {
             idProperty: 'accountId'
         });
 
-        var notificationProps = window.lodash.get(this.editDialog.record, 'data.notificationProps', []);
-        var disable = notificationProps === null || notificationProps.length === 0;
-
         this.notificationGrid = new Tine.Filemanager.NotificationGridPanel({
             store: store,
-            readOnly: disable,
+            readOnly: true,
             flex: 1,
             editDialog: this.editDialog
         });
 
-        var featureEnabled = _.get(Tine.Tinebase.configManager.get('filesystem'), 'enableNotifications', false);
-
-        var disabled = false;
-
-        if (!featureEnabled) {
-            disabled = true;
-        } else if (!_.get(this.editDialog, 'record.data.account_grants.adminGrant', false)) {
-            disabled = true;
-        }
-
         this.hasOwnNotificationSettings = new Ext.form.Checkbox({
-            checked: !disable,
-            disabled: disabled,
+            checked: false,
+            disabled: true,
             boxLabel: this.app.i18n._('This folder has own notification settings'),
             listeners: {scope: this, check: this.onOwnNotificationCheck}
         });
@@ -87,7 +76,22 @@ Tine.Filemanager.NotificationPanel = Ext.extend(Ext.Panel, {
     },
 
     onRecordLoad: function (editDialog, record, ticketFn) {
-        this.notificationGrid.getStore().loadData(window.lodash.get(record, 'data.notificationProps', []), false);
+        var _ = window.lodash,
+            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),
+            hasAdminGrant = _.get(this.editDialog, 'record.data.account_grants.adminGrant', false);
+
+        this.notificationGrid.getStore().loadData(_.get(record, 'data.notificationProps', []), false);
+        this.hasOwnNotificationSettings.setValue(hasOwnNotificationSettings);
+
+        // @TODO: enable box for non admins if not hasOwnNotificationSettings
+        //        atm. the server can't cope with it -> see #490, #484
+        // this.hasOwnNotificationSettings.setDisabled(!featureEnabled || !hasRequiredGrant || (hasOwnNotificationSettings && !hasAdminGrant))
+        this.hasOwnNotificationSettings.setDisabled(!hasAdminGrant);
+
+        this.notificationGrid.setReadOnly(!featureEnabled || !hasRequiredGrant);
     },
 
     onSave: function (editDialog, record, ticketFn) {
index 02c31d7..b0e809a 100644 (file)
@@ -31,8 +31,6 @@ Tine.MailFiler.NodeTreePanel = Ext.extend(Tine.Filemanager.NodeTreePanel, {
         });
 
         this.actionUpdater = new Tine.widgets.ActionUpdater({
-            containerProperty: this.recordClass.getMeta('containerProperty'),
-            evalGrants: true,
             actions: this.ctxMenu.items
         });
     }
index ed5a950..00decb1 100644 (file)
@@ -61,6 +61,11 @@ Ext.extend(Tine.Tinebase.data.Record, Ext.data.Record, {
      */
     recordsName: 'records',
     /**
+     * @cfg {String} grantsPath
+     * path (see _.get() to find grants
+     */
+    grantsPath: null,
+    /**
      * @cfg {String} containerProperty
      * name of the container property
      */
@@ -321,6 +326,9 @@ Tine.Tinebase.data.Record.create = function(o, meta) {
             field.label = p.containerName;
         }
     }
+    if (!p.grantsPath) {
+        p.grantsPath = 'data' + (containerProperty ? ('.' + containerProperty) : '') + '.account_grants';
+    }
     Tine.Tinebase.data.RecordMgr.add(f);
     return f;
 };
index 9ff6e5b..e6da761 100644 (file)
     config.actions = [];
     
     Ext.apply(this, config);
+
+    if (this.recordClass) {
+        this.grantsPath = this.recordClass.getMeta('grantsPath');
+    }
     this.addActions(actions);
  };
 
      * should grants of a grant-aware records be evaluated (defaults to true)
      */
     evalGrants: true,
-    
-    /**
-     * @cfg {String} grantsProperty
-     * property in the record to find the grants in
-     */
-    grantsProperty: 'account_grants',
-    
-    /**
-     * @cfg {String} containerProperty
-     * container property of records (if set, grants are expected to be  a property of the container)
-     */
-    containerProperty: 'container_id',
+
+    recordClass: null,
+
+    grantsPath: null,
     
     /**
      * add actions to update
      */
     getGrantsSum: function(records) {
 
-        var defaultGrant = records.length == 0 ? false : true;
-        var grants = {
-            addGrant:       defaultGrant,
-            adminGrant:     defaultGrant,
-            deleteGrant:    defaultGrant,
-            editGrant:      defaultGrant,
-            readGrant:      defaultGrant,
-            exportGrant:    defaultGrant,
-            syncGrant:      defaultGrant
-        };
+        var _ = window.lodash,
+            defaultGrant = records.length == 0 ? false : true,
+            grants = {
+                addGrant:       defaultGrant,
+                adminGrant:     defaultGrant,
+                deleteGrant:    defaultGrant,
+                editGrant:      defaultGrant,
+                readGrant:      defaultGrant,
+                exportGrant:    defaultGrant,
+                syncGrant:      defaultGrant
+            };
         
         if (! this.evalGrants) {
             return grants;
         
         var recordGrants;
         for (var i=0; i<records.length; i++) {
-            recordGrants = this.containerProperty ? 
-                records[i].get(this.containerProperty)[this.grantsProperty] : this.grantsProperty ? 
-                records[i].get(this.grantsProperty) : records[i].data;
+            recordGrants = _.get(records[i], this.grantsPath);
             
             for (var grant in grants) {
                 if (grants.hasOwnProperty(grant) && recordGrants && recordGrants.hasOwnProperty(grant)) {
index 00b79b7..19f925a 100644 (file)
@@ -65,7 +65,6 @@ Tine.widgets.activities.ActivitiesGridPanel = Ext.extend(Ext.grid.GridPanel, {
 
         // init actions
         this.actionUpdater = new Tine.widgets.ActionUpdater({
-            containerProperty: 'container_id',
             evalGrants: false
         });
 
@@ -189,9 +188,13 @@ Tine.widgets.activities.ActivitiesGridPanel = Ext.extend(Ext.grid.GridPanel, {
      * @param {Function} ticketFn
      */
     onLoadRecord: function (activities, record, ticketFn) {
+        var _ = window.lodash,
+            interceptor = ticketFn(),
+            notes = record.get('notes'),
+            hasRequiredGrant = _.get(record, record.constructor.getMeta('grantsPath') + '.' + this.requiredGrant);
+
         this.store.removeAll();
-        var interceptor = ticketFn();
-        var notes = record.get('notes');
+
         if (notes && notes.length > 0) {
             this.updateTitle(notes.length);
             var notesRecords = [];
@@ -212,9 +215,7 @@ Tine.widgets.activities.ActivitiesGridPanel = Ext.extend(Ext.grid.GridPanel, {
         }
         interceptor();
 
-        if (record.constructor.hasField(this.requiredGrant) && ! record.get(this.requiredGrant)) {
-            this.setReadOnly(true);
-        }
+        this.setReadOnly(! hasRequiredGrant);
     },
 
     setReadOnly: function(readOnly) {
index ee9565d..721fbe0 100644 (file)
@@ -202,9 +202,13 @@ Tine.widgets.dialog.AttachmentsGridPanel = Ext.extend(Tine.widgets.grid.FileUplo
      * @param {Function} ticketFn
      */
     onLoadRecord: function(dialog, record, ticketFn) {
+        var _ = window.lodash,
+            interceptor = ticketFn(),
+            attachments = record.get('attachments'),
+            hasRequiredGrant = _.get(record, record.constructor.getMeta('grantsPath') + '.' + this.requiredGrant);
+
         this.store.removeAll();
-        var interceptor = ticketFn();
-        var attachments = record.get('attachments');
+
         if (attachments && attachments.length > 0) {
             this.updateTitle(attachments.length);
             var attachmentRecords = [];
@@ -225,9 +229,7 @@ Tine.widgets.dialog.AttachmentsGridPanel = Ext.extend(Tine.widgets.grid.FileUplo
         }
         interceptor();
 
-        if (record.constructor.hasField(this.requiredGrant) && ! record.get(this.requiredGrant)) {
-            this.setReadOnly(true);
-        }
+        this.setReadOnly(! hasRequiredGrant);
     },
 
     /**
index 9d066db..8735556 100644 (file)
@@ -69,6 +69,12 @@ Tine.widgets.dialog.EditDialog = Ext.extend(Ext.FormPanel, {
      */
     evalGrants: true,
     /**
+     * @cfg {String} requiredSaveGrant
+     * required grant for apply/save
+     */
+    requiredSaveGrant: 'editGrant',
+
+    /**
      * @cfg {Ext.data.Record} record
      * record in edit process.
      */
@@ -104,12 +110,6 @@ Tine.widgets.dialog.EditDialog = Ext.extend(Ext.FormPanel, {
      * do duplicate check when saving record (mode remote only)
      */
     doDuplicateCheck: true,
-    
-    /**
-     * required grant for apply/save
-     * @type String
-     */
-    editGrant: 'editGrant',
 
     /**
      * when a record has the relations-property the relations-panel can be disabled here
@@ -307,7 +307,7 @@ Tine.widgets.dialog.EditDialog = Ext.extend(Ext.FormPanel, {
             this.appName    = this.appName    ? this.appName    : this.recordClass.getMeta('appName');
             this.modelName  = this.modelName  ? this.modelName  : this.recordClass.getMeta('modelName');
         }
-        
+
         if (! this.app) {
             this.app = Tine.Tinebase.appMgr.get(this.appName);
         }
@@ -578,7 +578,7 @@ Tine.widgets.dialog.EditDialog = Ext.extend(Ext.FormPanel, {
      */
     initActions: function() {
         this.action_saveAndClose = new Ext.Action({
-            requiredGrant: this.editGrant,
+            requiredGrant: this.requiredSaveGrant,
             text: (this.saveAndCloseButtonText != '') ? this.app.i18n._(this.saveAndCloseButtonText) : i18n._('Ok'),
             minWidth: 70,
             ref: '../btnSaveAndClose',
@@ -589,7 +589,7 @@ Tine.widgets.dialog.EditDialog = Ext.extend(Ext.FormPanel, {
         });
     
         this.action_applyChanges = new Ext.Action({
-            requiredGrant: this.editGrant,
+            requiredGrant: this.requiredSaveGrant,
             text: i18n._('Apply'),
             minWidth: 70,
             ref: '../btnApplyChanges',
@@ -622,7 +622,7 @@ Tine.widgets.dialog.EditDialog = Ext.extend(Ext.FormPanel, {
 
         // init actions
         this.actionUpdater = new Tine.widgets.ActionUpdater({
-            containerProperty: this.recordClass ? this.recordClass.getMeta('containerProperty') : null,
+            recordClass: this.recordClass,
             evalGrants: this.evalGrants
         });
 
@@ -862,7 +862,8 @@ Tine.widgets.dialog.EditDialog = Ext.extend(Ext.FormPanel, {
     
     // finally load the record into the form
     onAfterRecordLoad: function() {
-        var form = this.getForm();
+        var _ = window.lodash,
+            form = this.getForm();
         
         if (form) {
             form.loadRecord(this.record);
@@ -878,6 +879,16 @@ Tine.widgets.dialog.EditDialog = Ext.extend(Ext.FormPanel, {
             this.record.set('id', (new Date()).getTime());
         }
 
+        // apply grants to fields with requiredGrant prop
+        if (this.evalGrants) {
+            this.getForm().items.each(function (f) {
+                if (f.isFormField && f.requiredGrant !== undefined) {
+                    var hasRequiredGrant = _.get(this.record, this.recordClass.getMeta('grantsPath') + '.' + f.requiredGrant);
+                    f.setDisabled(!hasRequiredGrant);
+                }
+            }, this);
+        }
+
         this.checkStates.defer(100, this);
 
         if (this.loadMask) {
@@ -933,8 +944,8 @@ Tine.widgets.dialog.EditDialog = Ext.extend(Ext.FormPanel, {
         var form = this.getForm().items.each(function(item) {
             this.relayEvents(item, ['change', 'select']);
         }, this);
-        this.on('change', this.checkStates, this);
-        this.on('select', this.checkStates, this);
+        this.on('change', this.checkStates, this, {buffer: 100});
+        this.on('select', this.checkStates, this, {buffer: 100});
     },
     
     /**
index cb5212f..3656fbc 100644 (file)
@@ -71,7 +71,6 @@ Tine.widgets.grid.FileUploadGrid = Ext.extend(Ext.grid.EditorGridPanel, {
 
         // init actions
         this.actionUpdater = new Tine.widgets.ActionUpdater({
-            containerProperty: 'container_id', 
             evalGrants: false
         });
         
index 7f93f17..ac49d59 100644 (file)
@@ -394,7 +394,6 @@ Ext.extend(Tine.widgets.grid.GridPanel, Ext.Panel, {
 
         // init actions
         this.actionUpdater = new Tine.widgets.ActionUpdater({
-            containerProperty: this.recordClass.getMeta('containerProperty'), 
             evalGrants: this.evalGrants
         });
 
index 2584cd0..888baaa 100644 (file)
@@ -202,10 +202,14 @@ Tine.widgets.grid.LinkGridPanel = Ext.extend(Tine.widgets.grid.PickerGridPanel,
      * @param {Record} record
      */
     onRecordLoad: function(record) {
+        var _ = window.lodash,
+            hasRequiredGrant = _.get(record, record.constructor.getMeta('grantsPath') + '.' + this.requiredGrant);
+
+
         if (this.record) {
             return;
         }
-        
+
         this.record = record;
 
         Tine.log.debug('Loading relations into store...');
@@ -229,9 +233,7 @@ Tine.widgets.grid.LinkGridPanel = Ext.extend(Tine.widgets.grid.PickerGridPanel,
 
         // TODO perhaps we should filter all that do not match the model
 
-        if (record.constructor.hasField(this.requiredGrant) && ! record.get(this.requiredGrant)) {
-            this.setReadOnly(true);
-        }
+        this.setReadOnly(hasRequiredGrant);
 
     },
     
index e806de0..6721dce 100644 (file)
@@ -1150,9 +1150,11 @@ Tine.widgets.relation.GenericPickerGridPanel = Ext.extend(Tine.widgets.grid.Pick
      * @param {Record} record
      */
     loadRecord: function(dialog, record, ticketFn) {
-        this.store.removeAll();
-        var interceptor = ticketFn();
+        var _ = window.lodash,
+            interceptor = ticketFn(),
+            hasRequiredGrant = _.get(record, record.constructor.getMeta('grantsPath') + '.' + this.requiredGrant);
 
+        this.store.removeAll();
 
         if (dialog.mode == 'local') {
             // if dialog is local, relations must be fetched async
@@ -1166,10 +1168,7 @@ Tine.widgets.relation.GenericPickerGridPanel = Ext.extend(Tine.widgets.grid.Pick
             this.loadRelations(relations, interceptor);
         }
 
-        if (record.constructor.hasField(this.requiredGrant) && ! record.get(this.requiredGrant)) {
-            this.setReadOnly(true);
-        }
-
+        this.setReadOnly(! hasRequiredGrant);
     },
 
     loadRelations: function(relations, interceptor) {