0013014: Allow to manage resources in addressbook module
authorMichael Spahn <m.spahn@metaways.de>
Wed, 3 May 2017 13:04:23 +0000 (15:04 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Tue, 23 May 2017 14:03:09 +0000 (16:03 +0200)
https://forge.tine20.org/view.php?id=13014

Change-Id: I2fa3cb7162dc327d5644a432da51b7e7b2813fae
Reviewed-on: http://gerrit.tine20.com/customers/4609
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tests/tine20/Addressbook/ControllerTest.php
tine20/Addressbook/Addressbook.jsb2
tine20/Addressbook/Config.php
tine20/Addressbook/js/Addressbook.js
tine20/Addressbook/js/Model.js
tine20/Addressbook/js/ResourceGridPanel.js [new file with mode: 0644]
tine20/Calendar/js/Model.js
tine20/Calendar/js/ResourcesGridPanel.js
tine20/Tinebase/js/widgets/MainScreen.js

index 8fecd79..0227e8d 100644 (file)
@@ -488,4 +488,17 @@ class Addressbook_ControllerTest extends TestCase
         $count = $this->_instance->searchCount($filter);
         $this->assertEquals(1, $count);
     }
+
+    /**
+     * 0013014: Allow to manage resources in addressbook module
+     */
+    public function testEnableResourcesFeature()
+    {
+        $enabledFeatures = Addressbook_Config::getInstance()->get(Addressbook_Config::ENABLED_FEATURES);
+        $enabledFeatures[Addressbook_Config::FEATURE_LIST_VIEW] = true;
+
+        Addressbook_Config::getInstance()->set(Addressbook_Config::ENABLED_FEATURES, $enabledFeatures);
+
+        $this->assertTrue(Addressbook_Config::getInstance()->featureEnabled(Addressbook_Config::FEATURE_LIST_VIEW));
+    }
 }
index 917accc..651dde6 100644 (file)
           "path": "js/"
         },
         {
+          "text": "ResourceGridPanel.js",
+          "path": "js/"
+        },
+        {
           "text": "ContactFilterModel.js",
           "path": "js/"
         },
index 94ee82a..3e5af2a 100644 (file)
@@ -73,6 +73,13 @@ class Addressbook_Config extends Tinebase_Config_Abstract
     const FEATURE_INDUSTRY = 'featureIndustry';
 
     /**
+     * FEATURE_RESOURCES
+     *
+     * @var string
+     */
+    const FEATURE_RESOURCES = 'featureResources';
+
+    /**
      * config for the syncBackends
      *
      * @var string
@@ -85,27 +92,34 @@ class Addressbook_Config extends Tinebase_Config_Abstract
      */
     protected static $_properties = array(
         self::ENABLED_FEATURES => array(
-           //_('Enabled Features')
-           'label'                 => 'Enabled Features',
-           //_('Enabled Features in Calendar Application.')
-           'description'           => 'Enabled Features in Addressbook Application.',
-           'type'                  => 'object',
-           'class'                 => 'Tinebase_Config_Struct',
-           'clientRegistryInclude' => TRUE,
-           'content'               => array(
-               self::FEATURE_LIST_VIEW => array(
-                   'label'         => 'Addressbook List View', //_('Addressbook List View')
-                   'description'   => 'Shows an additional view for lists inside the addressbook', //_('Shows an additional view for lists inside the addressbook')
-               ),
-               self::FEATURE_INDUSTRY => array(
-                       'label'         => 'Addressbook Industries', //_('Addressbook Industries')
-                       'description'   => 'Add Industry field to Adressbook', //_('Add Industry field to Adressbook')
-               ),
-           ),
-           'default'               => array(
-               self::FEATURE_LIST_VIEW   => false,
-               self::FEATURE_INDUSTRY    => true,
-           ),
+            //_('Enabled Features')
+            'label' => 'Enabled Features',
+            //_('Enabled Features in Calendar Application.')
+            'description' => 'Enabled Features in Addressbook Application.',
+            'type' => 'object',
+            'class' => 'Tinebase_Config_Struct',
+            'clientRegistryInclude' => true,
+            'content' => array(
+                self::FEATURE_LIST_VIEW => array(
+                    'label' => 'Addressbook List View',
+                    //_('Addressbook List View')
+                    'description' => 'Shows an additional view for lists inside the addressbook',
+                    //_('Shows an additional view for lists inside the addressbook')
+                ),
+                self::FEATURE_INDUSTRY => array(
+                    'label' => 'Addressbook Industries', //_('Addressbook Industries')
+                    'description' => 'Add Industry field to Adressbook', //_('Add Industry field to Adressbook')
+                ),
+                self::FEATURE_RESOURCES => array(
+                    'label' => 'Manage resources in Addressbook', // _('Manage resources in Addressbook')
+                    'description' => 'Show the resources grid also inside the Addressbook' // _('Show the resources grid also inside the Addressbook')
+                )
+            ),
+            'default' => array(
+                self::FEATURE_LIST_VIEW => false,
+                self::FEATURE_INDUSTRY => true,
+                self::FEATURE_RESOURCES => false
+            ),
         ),
         self::CONTACT_DUP_FIELDS => array(
                                    //_('Contact duplicate check fields')
index 4579369..2e3ce74 100755 (executable)
@@ -3,7 +3,7 @@
  * 
  * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
  * @author      Cornelius Weiss <c.weiss@metaways.de>
- * @copyright   Copyright (c) 2007-2008 Metaways Infosystems GmbH (http://www.metaways.de)
+ * @copyright   Copyright (c) 2007-2017 Metaways Infosystems GmbH (http://www.metaways.de)
  */
 
 Ext.ns('Tine.Addressbook');
@@ -39,9 +39,10 @@ Tine.Addressbook.Application = Ext.extend(Tine.Tinebase.Application, {
     getMainScreen: function() {
         var mainscreen = Tine.Addressbook.Application.superclass.getMainScreen.call(this);
 
-        if (!Tine.Tinebase.appMgr.get('Addressbook').featureEnabled('featureListView')) {
+        if (!Tine.Tinebase.appMgr.get('Addressbook').featureEnabled('featureListView')
+            && !Tine.Tinebase.appMgr.get('Addressbook').featureEnabled('featureResources')) {
             mainscreen.useModuleTreePanel = false;
-        };
+        }
 
         return mainscreen;
     },
@@ -135,9 +136,20 @@ Tine.Addressbook.Application = Ext.extend(Tine.Tinebase.Application, {
 Tine.Addressbook.MainScreen = Ext.extend(Tine.widgets.MainScreen, {
     activeContentType: 'Contact',
     contentTypes: [
-        {model: 'Contact',  requiredRight: null, singularContainerMode: false},
-        {model: 'List',  requiredRight: null, singularContainerMode: false}
-    ]
+        {model: 'Contact', requiredRight: null, singularContainerMode: false}
+    ],
+
+    initComponent: function() {
+        if(Tine.Tinebase.appMgr.get('Addressbook').featureEnabled('featureResources')) {
+           this.contentTypes.push({model: 'Resource', requiredRight: null, singularContainerMode: true});
+        }
+
+        if(Tine.Tinebase.appMgr.get('Addressbook').featureEnabled('featureListView')) {
+            this.contentTypes.push({model: 'List', requiredRight: null, singularContainerMode: false});
+        }
+        
+        Tine.Addressbook.MainScreen.superclass.initComponent.call(this);
+    }
 });
 
 Tine.Addressbook.ContactTreePanel = function(config) {
index 981c866..5fdc70d 100644 (file)
@@ -143,6 +143,36 @@ Tine.Addressbook.Model.Contact = Tine.Tinebase.data.Record.create(Tine.Addressbo
 });
 
 /**
+ * Make resource model available in adb
+ */
+Tine.Addressbook.Model.Resource = Tine.Tinebase.data.Record.create(Tine.Tinebase.Model.genericFields.concat([
+    {name: 'id'},
+    {name: 'name'},
+    {name: 'description'},
+    {name: 'email'},
+    {name: 'max_number_of_people', type: 'int'},
+    {name: 'type', type: 'keyField', keyFieldConfigName: 'resourceTypes'},
+    {name: 'status', type: 'keyField', keyFieldConfigName: 'attendeeStatus'},
+    {name: 'busy_type', type: 'keyField', keyFieldConfigName: 'freebusyTypes'},
+    {name: 'suppress_notification', type: 'bool'},
+    {name: 'tags'},
+    {name: 'notes'},
+    {name: 'grants'},
+    { name: 'attachments'},
+    { name: 'relations',   omitDuplicateResolving: true},
+    { name: 'customfields', omitDuplicateResolving: true}
+]), {
+    appName: 'Calendar',
+    modelName: 'Resource',
+    idProperty: 'id',
+    titleProperty: 'name',
+    containerProperty: 'container_id',
+    // ngettext('Resource', 'Resources', n); gettext('Resources');
+    recordName: 'Resource',
+    recordsName: 'Resources'
+});
+
+/**
  * get filtermodel of contact model
  * 
  * @namespace Tine.Addressbook.Model
diff --git a/tine20/Addressbook/js/ResourceGridPanel.js b/tine20/Addressbook/js/ResourceGridPanel.js
new file mode 100644 (file)
index 0000000..777f26e
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Tine 2.0
+ *
+ * @package     Addressbook
+ * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
+ * @author      Michael Spahn <m.spahn@metaways.de>
+ * @copyright   Copyright (c) 2017 Metaways Infosystems GmbH (http://www.metaways.de)
+ *
+ */
+Ext.ns('Tine.Addressbook');
+
+Ext.onReady(function() {
+    Tine.Addressbook.ResourceGridPanel = Ext.extend(Tine.Calendar.ResourcesGridPanel, {
+        initLayout: function () {
+            return Tine.Calendar.ResourcesGridPanel.superclass.initLayout.apply(this, arguments)
+        }
+    });
+
+    Tine.Addressbook.ResourceTreePanel = Ext.extend(Ext.Panel, {
+        getFilterPlugin: function () {
+            return {
+                init: Ext.emptyFn
+            };
+        }
+    });
+});
\ No newline at end of file
index e2510c6..e655dc9 100644 (file)
@@ -753,7 +753,7 @@ Tine.Calendar.Model.Attender.getAttendeeStore.getData = function(attendeeStore,
     }
 
     return attendeeData;
-}
+};
 
 /**
  * @namespace Tine.Calendar.Model
index 9cec9b0..4a7df54 100644 (file)
@@ -84,8 +84,8 @@ Tine.Calendar.ResourcesGridPanel = Ext.extend(Tine.widgets.grid.GridPanel, {
             renderer: Tine.Calendar.ResourcesGridPanel.locationRenderer,
             sortable: false
         }];
-        
-        this.supr().initComponent.call(this);
+
+        Tine.Calendar.ResourcesGridPanel.superclass.initComponent.call(this);
     },
     
     initLayout: function() {
index b75ae80..ebe3927 100644 (file)
@@ -221,7 +221,7 @@ Tine.widgets.MainScreen = Ext.extend(Ext.Panel, {
                     if(node != this.lastClickedNode) {
                         this.lastClickedNode = node;
                         this.fireEvent('selectionchange');
-                    } else {
+                    } else if (me.getWestPanel().getFavoritesPanel()) {
                         // select default favorite
                         // NOTE: a lot of models don't have a default favorite defined...
                         me.getWestPanel().getFavoritesPanel().selectDefault();
@@ -272,8 +272,11 @@ Tine.widgets.MainScreen = Ext.extend(Ext.Panel, {
                     }
                 };
             try {
-                if(Tine[this.app.name].hasOwnProperty(wpName)) this[wpName] = new Tine[this.app.appName][wpName](wpconfig);
-                else this[wpName] = new Tine.widgets.mainscreen.WestPanel(wpconfig);
+                if (Tine[this.app.name].hasOwnProperty(wpName)) {
+                    this[wpName] = new Tine[this.app.appName][wpName](wpconfig);
+                } else {
+                    this[wpName] = new Tine.widgets.mainscreen.WestPanel(wpconfig);
+                }
             } catch (e) {
                 Tine.log.error('Could not create westPanel');
                 Tine.log.error(e.stack ? e.stack : e);