Skip to content

Commit

Permalink
tweak(Sales) EvaluationDimension division field json expanded
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmhh committed Jan 12, 2024
1 parent d01e429 commit 68add67
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tine20/Sales/Controller/Division.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,4 +203,14 @@ protected function _handleEvent(Tinebase_Event_Abstract $_eventObject)
}
}
}

public static function evalDimModelConfigHook(array &$_fields, Tinebase_ModelConfiguration $mc): void
{
$expander = $mc->jsonExpander;

$expander[Tinebase_Record_Expander::EXPANDER_PROPERTIES][Tinebase_Model_EvaluationDimension::FLD_ITEMS]
[Tinebase_Record_Expander::EXPANDER_PROPERTIES]['divisions'] = [];

$mc->setJsonExpander($expander);
}
}
12 changes: 12 additions & 0 deletions tine20/Sales/Setup/Initialize.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,18 @@ public static function createTbSystemCFEvaluationDimension(): void
],
]
], true));

Tinebase_CustomField::getInstance()->addCustomField(new Tinebase_Model_CustomField_Config([
'name' => 'divisions',
'application_id' => $appId,
'model' => Tinebase_Model_EvaluationDimension::class,
'is_system' => true,
'definition' => [
Tinebase_Model_CustomField_Config::DEF_HOOK => [
[Sales_Controller_Division::class, 'evalDimModelConfigHook'],
],
],
], true));
}

protected function _initializeCostCenterCostBearer()
Expand Down
7 changes: 7 additions & 0 deletions tine20/Sales/Setup/Uninitialize.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ protected function _uninitializeCustomFields()
if (null !== $cfc) {
Tinebase_CustomField::getInstance()->deleteCustomField($cfc);
}

$cfc = Tinebase_CustomField::getInstance()->getCustomFieldByNameAndApplication(
Tinebase_Application::getInstance()->getApplicationByName(Tinebase_Config::APP_NAME)->getId(),
'divisions', Tinebase_Model_EvaluationDimension::class, true);
if (null !== $cfc) {
Tinebase_CustomField::getInstance()->deleteCustomField($cfc);
}
}

protected function _uninitializeCostCenterCostBearer()
Expand Down
1 change: 1 addition & 0 deletions tine20/Tinebase/Model/EvaluationDimension.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class Tinebase_Model_EvaluationDimension extends Tinebase_Record_NewAbstract
self::MODEL_NAME => self::MODEL_NAME_PART,
self::MODLOG_ACTIVE => true,
self::HAS_DELETED_TIME_UNIQUE => true,
self::HAS_SYSTEM_CUSTOM_FIELDS => true,
self::EXPOSE_JSON_API => true,
self::RECORD_NAME => 'Evaluation Dimension', // gettext('GENDER_Evaluation Dimension')
self::RECORDS_NAME => 'Evaluation Dimensions', // ngettext('Evaluation Dimension', 'Evaluation Dimensions', n)
Expand Down

0 comments on commit 68add67

Please sign in to comment.