0012022: omit personal containers via model configuration
authorCornelius Weiß <c.weiss@metaways.de>
Thu, 7 Jul 2016 08:15:46 +0000 (10:15 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Mon, 11 Jul 2016 10:33:00 +0000 (12:33 +0200)
https://forge.tine20.org/view.php?id=12022

Change-Id: I4a00ad0cdca77b37ef51dcab2f0e1577a89a3175
Reviewed-on: http://gerrit.tine20.com/customers/3313
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
Tested-by: Philipp Schüle <p.schuele@metaways.de>
tine20/Filemanager/js/NodeTreePanel.js
tine20/Tinebase/ModelConfiguration.php
tine20/Tinebase/js/widgets/container/ContainerSelect.js
tine20/Tinebase/js/widgets/container/TreePanel.js

index 4f16d82..e62a686 100644 (file)
@@ -221,15 +221,7 @@ Ext.extend(Tine.Filemanager.NodeTreePanel, Tine.widgets.container.TreePanel, {
         
         return this.filterPlugin;
     },
-    
-    /**
-     * returns the personal root path
-     * @returns {String}
-     */
-    getRootPath: function() {
-        return Tine.Tinebase.container.getMyFileNodePath();
-    },
-    
+
     /**
      * returns params for async request
      * 
index 5eb5fa6..98a6983 100644 (file)
@@ -80,7 +80,14 @@ class Tinebase_ModelConfiguration {
      * @var boolean
      */
     protected $_containerUsesFilter = TRUE;
-    
+
+    /**
+     * set this to false, if personal containers should be ommited
+     *
+     * @var boolean
+     */
+    protected $_hasPersonalContainer = TRUE;
+
     /**
      * The property of the title, if any
      *
@@ -594,7 +601,8 @@ class Tinebase_ModelConfiguration {
         'defaultFilter', 'requiredRight', 'singularContainerMode', 'fields', 'defaultData', 'titleProperty',
         'useGroups', 'fieldGroupFeDefaults', 'fieldGroupRights', 'multipleEdit', 'multipleEditRequiredRight',
         'recordName', 'recordsName', 'appName', 'modelName', 'createModule', 'virtualFields', 'group', 'isDependent',
-        'hasCustomFields', 'modlogActive', 'hasAttachments', 'idProperty', 'splitButton', 'attributeConfig'
+        'hasCustomFields', 'modlogActive', 'hasAttachments', 'idProperty', 'splitButton', 'attributeConfig',
+        'hasPersonalContainer'
     );
 
     /**
index aba7de4..1e7fd41 100644 (file)
@@ -326,6 +326,7 @@ Tine.widgets.container.selectionComboBox = Ext.extend(Ext.form.ComboBox, {
     onChoseOther: function() {
         this.collapse();
         this.dlg = new Tine.widgets.container.selectionDialog({
+            recordClass: this.recordClass,
             allowNodeSelect: this.allowNodeSelect,
             containerName: this.containerName,
             containersName: this.containersName,
@@ -443,6 +444,10 @@ Tine.widgets.container.selectionDialog = Ext.extend(Ext.Component, {
      */
     allowNodeSelect: false,
     /**
+     * @cfg {Tine.data.Record} recordClass
+     */
+    recordClass: false,
+    /**
      * @cfg {string} containerName
      * name of container (singular)
      */
@@ -506,6 +511,7 @@ Tine.widgets.container.selectionDialog = Ext.extend(Ext.Component, {
         }
 
         this.tree = new Tine.widgets.container.TreePanel({
+            recordClass: this.recordClass,
             allowMultiSelection: false,
             containerName: this.TriggerField.containerName,
             containersName: this.TriggerField.containersName,
index a6b46e6..0b4b5a3 100644 (file)
@@ -102,17 +102,24 @@ Ext.extend(Tine.widgets.container.TreePanel, Ext.tree.TreePanel, {
      */
     useContainerColor: false,
     /**
-     * @cfg {Boolean} useContainerColor
+     * @cfg {Boolean} useProperties
      * use container properties
      */
     useProperties: true,
-    
+
+    /**
+     * @property {Object}
+     * modelConfiguration of recordClass (if available)
+     */
+    modelConfiguration: null,
+
     useArrows: true,
     border: false,
     autoScroll: true,
     enableDrop: true,
     ddGroup: 'containerDDGroup',
-    
+    hasPersonalContainer: true,
+
     /**
      * @fixme not needed => all events hand their events over!!!
      * 
@@ -135,6 +142,14 @@ Ext.extend(Tine.widgets.container.TreePanel, Ext.tree.TreePanel, {
         if (this.allowMultiSelection) {
             this.selModel = new Ext.tree.MultiSelectionModel({});
         }
+
+        if (this.recordClass) {
+            this.modelConfiguration = this.recordClass.getModelConfiguration();
+        }
+
+        if (this.modelConfiguration) {
+            this.hasPersonalContainer = this.modelConfiguration.hasPersonalContainer !== false;
+        }
         
         var containerName = this.recordClass ? this.recordClass.getContainerName() : 'container';
         var containersName = this.recordClass ? this.recordClass.getContainersName() : 'containers';
@@ -147,23 +162,30 @@ Ext.extend(Tine.widgets.container.TreePanel, Ext.tree.TreePanel, {
             getParams: this.onBeforeLoad.createDelegate(this),
             inspectCreateNode: this.onBeforeCreateNode.createDelegate(this)
         });
-        
+
+        var extraItems = this.getExtraItems();
         this.root = {
             path: '/',
             cls: 'tinebase-tree-hide-collapsetool',
             expanded: true,
             children: [{
-                path: this.getRootPath(),
-                id: 'personal'
+                path: Tine.Tinebase.container.getMyNodePath(),
+                id: 'personal',
+                hidden: !this.hasPersonalContainer
             }, {
                 path: '/shared',
                 id: 'shared'
             }, {
                 path: '/personal',
-                id: 'otherUsers'
-            }].concat(this.getExtraItems())
+                id: 'otherUsers',
+                hidden: !this.hasPersonalContainer
+            }].concat(extraItems)
         };
-        
+
+        if (!this.hasPersonalContainer && ! extraItems.length) {
+            this.rootVisible = false;
+        }
+
         // init drop zone
         this.dropConfig = {
             ddGroup: this.ddGroup || 'TreeDD',
@@ -199,16 +221,7 @@ Ext.extend(Tine.widgets.container.TreePanel, Ext.tree.TreePanel, {
         Tine.widgets.container.TreePanel.superclass.initComponent.call(this);
         return;
     },
-    
-    /**
-     * delivers the personal root node path
-     * 
-     * @returns personal root node path
-     */
-    getRootPath: function() {
-        return Tine.Tinebase.container.getMyNodePath();
-    },
-    
+
     /**
      * template fn for subclasses to set default path
      *