#8212: can't sort by tags
authorAlexander Stintzing <a.stintzing@metaways.de>
Tue, 23 Apr 2013 13:26:35 +0000 (15:26 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Thu, 25 Apr 2013 20:06:15 +0000 (22:06 +0200)
- should not be sortable by tags
  -> make tags not sortable in modelConfiguration

https://forge.tine20.org/mantisbt/view.php?id=8212

Change-Id: I1695edf5335c7954ee8c18739e65a92dcfdd889d
Reviewed-on: https://gerrit.tine20.org/tine20/1933
Tested-by: jenkins user
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
Tested-by: Philipp Schüle <p.schuele@metaways.de>
tests/tine20/Tinebase/ModelConfigurationTest.php
tine20/Tinebase/ModelConfiguration.php
tine20/Tinebase/js/widgets/grid/GridPanel.js

index f2d931a..c642893 100644 (file)
@@ -109,7 +109,11 @@ class Tinebase_ModelConfigurationTest extends PHPUnit_Framework_TestCase
         $fields = $employeeCObj->getFields();
         $this->assertArrayHasKey('deleted_time', $fields);
         $this->assertArrayHasKey('supervisor_id', $fields);
-
+        
+        // test if sortable is set to false on tags-field
+        $this->assertArrayHasKey('sortable', $fields['tags']);
+        $this->assertFalse($fields['tags']['sortable']);
+        
         $this->assertEquals($account->accountLastName, $employee->n_family);
         $this->assertEquals($account->accountFirstName, $employee->n_given);
     }
index 369f930..c77ab37 100644 (file)
@@ -230,6 +230,8 @@ class Tinebase_ModelConfiguration {
      *
      * - shy: If this is set to true, the row for this field won't be shown in the grid, but can be activated
      * 
+     * - sortable: If this is set to false, no sort by this field is possible in the gridpanel, defaults to true
+     * 
      *   // TODO: generalize, currently only in ContractGridPanel, take it from there:
      * - showInDetailsPanel: auto show in details panel if any is defined in the js gridpanel class
      * 
@@ -628,7 +630,13 @@ class Tinebase_ModelConfiguration {
         }
 
         if ($this->_hasTags) {
-            $this->_fields['tags'] = array('label' => 'Tags', 'type' => 'tag', 'validators' => array(Zend_Filter_Input::ALLOW_EMPTY => true, Zend_Filter_Input::DEFAULT_VALUE => NULL), 'useGlobalTranslation' => TRUE);
+            $this->_fields['tags'] = array(
+                'label' => 'Tags',
+                'sortable' => false,
+                'type' => 'tag', 
+                'validators' => array(Zend_Filter_Input::ALLOW_EMPTY => true, Zend_Filter_Input::DEFAULT_VALUE => NULL), 
+                'useGlobalTranslation' => TRUE
+            );
         }
 
         if ($this->_modlogActive) {
index 5c4ac7f..5225cfe 100644 (file)
@@ -417,7 +417,8 @@ Ext.extend(Tine.widgets.grid.GridPanel, Ext.Panel, {
                         id: key,
                         dataIndex: key,
                         header: this.app.i18n._(fieldConfig.label),
-                        hidden: fieldConfig.hasOwnProperty('shy') ? fieldConfig.shy : false
+                        hidden: fieldConfig.hasOwnProperty('shy') ? fieldConfig.shy : false,    // defaults to false
+                        sortable: (fieldConfig.hasOwnProperty('sortable') && fieldConfig.sortable == false) ? false : true // defaults to true
                     }
                     var renderer = Tine.widgets.grid.RendererManager.get(this.app.name, this.recordClass.getMeta('modelName'), key);
                     if (renderer) {
@@ -429,7 +430,6 @@ Ext.extend(Tine.widgets.grid.GridPanel, Ext.Panel, {
             
             this.gridConfig.cm = new Ext.grid.ColumnModel({
                 defaults: {
-                    sortable: true,
                     resizable: true
                 },
                 columns: columns