0012188: add copyOmitFields to modelconfig
authorPaul Mehrer <p.mehrer@metaways.de>
Fri, 9 Sep 2016 08:26:13 +0000 (10:26 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Mon, 12 Sep 2016 06:31:23 +0000 (08:31 +0200)
* configured Timetracker models

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

Change-Id: Ic0501af5c6473134c53f386a8602f0ccc0367e9b
Reviewed-on: http://gerrit.tine20.com/customers/3551
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tests/tine20/Tinebase/Frontend/JsonTest.php
tine20/Timetracker/Model/Timeaccount.php
tine20/Timetracker/Model/Timesheet.php
tine20/Tinebase/ModelConfiguration.php
tine20/Tinebase/js/ApplicationStarter.js

index f5ac9b2..16dc404 100644 (file)
@@ -486,6 +486,7 @@ class Tinebase_Frontend_JsonTest extends TestCase
      * @see 0007934: change pw button active even if it is not allowed
      * @see 0008310: apps should be sorted the other way round in menu
      * @see 0009130: Can't open login page on Ubuntu "due to a temporary overloading"
+     * @see 0012188: add copyOmitFields to modelconfig
      */
     public function testGetAllRegistryData()
     {
@@ -517,6 +518,14 @@ class Tinebase_Frontend_JsonTest extends TestCase
             $this->assertTrue(in_array('Invoice', $configuredSalesModels), 'Invoices is missing from configured models: '
                 . print_r($configuredSalesModels, true));
         }
+
+        $this->assertTrue(isset($registryData['Timetracker']['models']['Timeaccount']['copyOmitFields']), 'Timeaccount copyOmitFields empty/missing');
+        $this->assertEquals(array(
+            'billed_in',
+            'invoice_id',
+            'status',
+            'cleared_at',
+        ), $registryData['Timetracker']['models']['Timeaccount']['copyOmitFields']);
     }
 
     /**
index 650872c..1336ee8 100644 (file)
@@ -159,6 +159,7 @@ class Timetracker_Model_Timeaccount extends Sales_Model_Accountable_Abstract
             'billed_in'         => array(
                 'label'                 => "Cleared in", // _("Cleared in"),
                 'validators'            => array(Zend_Filter_Input::ALLOW_EMPTY => true),
+                'copyOmit'              => true,
             ),
             'invoice_id'        => array(
                 'label'                 => 'Invoice', // _('Invoice')
@@ -170,6 +171,7 @@ class Timetracker_Model_Timeaccount extends Sales_Model_Accountable_Abstract
                     'idProperty'            => 'id'
                 ),
                 'validators'            => array(Zend_Filter_Input::ALLOW_EMPTY => true),
+                'copyOmit'              => true,
             ),
             'status'            => array(
                 // is_open = Status, status = Billed
@@ -180,11 +182,13 @@ class Timetracker_Model_Timeaccount extends Sales_Model_Accountable_Abstract
                     'jsConfig'              => array('filtertype' => 'timetracker.timeaccountbilled')
                 ),
                 'validators'            => array(Zend_Filter_Input::ALLOW_EMPTY => true, Zend_Filter_Input::DEFAULT_VALUE => 'not yet billed'),
+                'copyOmit'              => true,
             ),
             'cleared_at'        => array(
                 'label'                 => "Cleared at", // _("Cleared at")
                 'type'                  => 'datetime',
                 'validators'            => array(Zend_Filter_Input::ALLOW_EMPTY => true),
+                'copyOmit'              => true,
             ),
             'deadline'          => array(
                 'label'                 => 'Booking deadline', // _('Booking deadline')
index 7805ce9..f8cb38b 100644 (file)
@@ -104,7 +104,8 @@ class Timetracker_Model_Timesheet extends Tinebase_Record_Abstract implements Sa
                 'label'                 => 'Cleared in', // _('Cleared in')
                 'validators'            => array(Zend_Filter_Input::ALLOW_EMPTY => true),
                 'copyOmit'              => TRUE,
-                'shy'                   => TRUE
+                'shy'                   => TRUE,
+                'copyOmit'              => true,
             ),
             'invoice_id'            => array(
                 'validators'            => array(Zend_Filter_Input::ALLOW_EMPTY => true),
@@ -116,6 +117,7 @@ class Timetracker_Model_Timesheet extends Tinebase_Record_Abstract implements Sa
                     'modelName'             => 'Invoice',
                     'idProperty'            => 'id'
                 ),
+                'copyOmit'              => true,
             ),
             'is_cleared'            => array(
                 'label'                 => NULL,
@@ -123,7 +125,8 @@ class Timetracker_Model_Timesheet extends Tinebase_Record_Abstract implements Sa
                 'type'                  => 'boolean',
                 'default'               => 0,
                 'copyOmit'              => TRUE,
-                'shy'                   => TRUE
+                'shy'                   => TRUE,
+                'copyOmit'              => true,
             ),
             'is_cleared_combined'   => array(
                 'label'                 => 'Cleared', // _('Cleared')
index 6697465..c3e5d4d 100644 (file)
@@ -602,7 +602,7 @@ class Tinebase_ModelConfiguration {
         'useGroups', 'fieldGroupFeDefaults', 'fieldGroupRights', 'multipleEdit', 'multipleEditRequiredRight',
         'recordName', 'recordsName', 'appName', 'modelName', 'createModule', 'virtualFields', 'group', 'isDependent',
         'hasCustomFields', 'modlogActive', 'hasAttachments', 'idProperty', 'splitButton', 'attributeConfig',
-        'hasPersonalContainer'
+        'hasPersonalContainer', 'copyOmitFields'
     );
 
     /**
@@ -697,6 +697,13 @@ class Tinebase_ModelConfiguration {
     );
 
     /**
+     * Collection of copy omit properties for frontend
+     *
+     * @var array
+     */
+    protected $_copyOmitFields = NULL;
+
+    /**
      * the constructor (must be called by the singleton pattern)
      *
      * @var array $modelClassConfiguration
@@ -832,6 +839,13 @@ class Tinebase_ModelConfiguration {
                 $fieldDef['length'] = 40;
             }
 
+            if (isset($fieldDef['copyOmit']) && $fieldDef['copyOmit']) {
+                if (!is_array($this->_copyOmitFields)) {
+                    $this->_copyOmitFields = array();
+                }
+                $this->_copyOmitFields[] = $fieldKey;
+            }
+
             if ($fieldDef['type'] == 'virtual') {
                 $fieldDef = isset($fieldDef['config']) ? $fieldDef['config'] : array();
                 $fieldDef['key'] = $fieldKey;
index 7b11407..b8fe659 100644 (file)
@@ -434,7 +434,7 @@ Tine.Tinebase.ApplicationStarter = {
                     if (! Tine[appName].Model.hasOwnProperty(modelName)) {
                         Tine[appName].Model[modelName] = Tine.Tinebase.data.Record.create(Tine[appName].Model[modelArrayName], 
                             Ext.copyTo({modelConfiguration: modelConfig}, modelConfig,
-                               'idProperty,defaultFilter,appName,modelName,recordName,recordsName,titleProperty,containerProperty,containerName,containersName,group')
+                               'idProperty,defaultFilter,appName,modelName,recordName,recordsName,titleProperty,containerProperty,containerName,containersName,group,copyOmitFields')
                         );
                         Tine[appName].Model[modelName].getFilterModel = function() {
                             return filterModel;