Skip to content
This repository has been archived by the owner on Dec 27, 2023. It is now read-only.

Commit

Permalink
feature(HumanResources): have default ts title from attendanceRecorde…
Browse files Browse the repository at this point in the history
…r in config
  • Loading branch information
corneliusweiss committed Apr 27, 2023
1 parent 834783b commit 2fe8e10
Show file tree
Hide file tree
Showing 9 changed files with 92 additions and 9 deletions.
7 changes: 4 additions & 3 deletions tests/e2etests/src/testScreenshots/Admin/admin.test.js
Expand Up @@ -123,9 +123,10 @@ describe('application', () => {
});
test('hr settings', async () => {
await expect(page).toClick('.x-grid3-cell-inner.x-grid3-col-name', {text: 'Human Resources', clickCount: 2});
let dialog = await page.$('.x-window.x-resizable-pinned');
await dialog.screenshot({path: 'screenshots/Administration/17_admin_hr_einstellungen.png'});
await page.keyboard.press('Escape');
newPage = await lib.getNewWindow();
await newPage.waitForTimeout(2000);
await newPage.screenshot({path: 'screenshots/Administration/17_admin_hr_einstellungen.png'});
await newPage.close();
});
test('sales settings', async () => {
await expect(page).toClick('.x-grid3-cell-inner.x-grid3-col-name', {text: 'Sales', clickCount: 2});
Expand Down
1 change: 1 addition & 0 deletions tine20/Admin/Controller/Config.php
Expand Up @@ -129,6 +129,7 @@ public function search(Tinebase_Model_Filter_FilterGroup $_filter = NULL, Tineba
}

$configRecord->value = json_encode(Tinebase_Config::uncertainJsonDecode($configRecord->value));
$configRecord->options = $appConfigObject->getOptions($name, $definition);

$configRecords->addRecord($configRecord);
}
Expand Down
22 changes: 22 additions & 0 deletions tine20/Admin/js/config/FieldManager.js
Expand Up @@ -34,6 +34,9 @@ Tine.Admin.config.FieldManager = function() {
constr = items[type]
} else {
switch (type) {
case 'int':
constr = Ext.form.NumberField;
break;
case 'string':
constr = Ext.form.TextField;
break;
Expand Down Expand Up @@ -89,6 +92,25 @@ Tine.Admin.config.FieldManager = function() {
}
}

if (['string', 'int'].indexOf(type) >= 0 && _.isArray(configRecord.get('options'))) {
var store = new Ext.data.JsonStore({
fields: ['id', 'title'],
data : configRecord.get('options')
});

options = {
mode: 'local',
forceSelection: true,
allowBlank: false,
triggerAction: 'all',
editable: false,
valueField: 'id',
displayField: 'title',
store: store
};

constr = Ext.form.ComboBox;
}
return Ext.isFunction(constr) ? new constr(options) : null;

},
Expand Down
5 changes: 5 additions & 0 deletions tine20/Admin/js/config/GridPanel.js
Expand Up @@ -264,6 +264,11 @@ Tine.Admin.config.GridPanel = Ext.extend(Tine.widgets.grid.GridPanel, {
break;
}

const option = _.find(record.get('options'), {id: value})
if (option?.title) {
value = option.title;
}

if (record.get('source') == 'DEFAULT') {
return String.format(this.app.i18n._('Default ({0})'), value);
}
Expand Down
4 changes: 3 additions & 1 deletion tine20/HumanResources/BL/AttendanceRecorder/TimeSheet.php
Expand Up @@ -611,7 +611,9 @@ public static function getTSDescription(HumanResources_Model_AttendanceRecord $r
{
return isset($record->xprops()[HumanResources_Model_AttendanceRecord::META_DATA][HumanResources_Config_AttendanceRecorder::METADATA_TS_DESCRIPTION]) ?
$record->xprops()[HumanResources_Model_AttendanceRecord::META_DATA][HumanResources_Config_AttendanceRecorder::METADATA_TS_DESCRIPTION] :
Tinebase_Translation::getTranslation(HumanResources_Config::APP_NAME)->_('attendance recorder generated');
Tinebase_Translation::getTranslation(HumanResources_Config::APP_NAME)->translate(
HumanResources_Config::getInstance()->{HumanResources_Config::ATTENDANCE_RECORDER_DEFAULT_TS_DESCRIPTION}
);
}

public function undo(Tinebase_Record_RecordSet $data): void
Expand Down
34 changes: 33 additions & 1 deletion tine20/HumanResources/Config.php
Expand Up @@ -64,6 +64,13 @@ class HumanResources_Config extends Tinebase_Config_Abstract
*/
const FEATURE_WORKING_TIME_ACCOUNTING = 'workingTimeAccounting';

/**
* attendance recorder default description
*
* @stering
*/
const ATTENDANCE_RECORDER_DEFAULT_TS_DESCRIPTION = 'attendanceRecorderDefaultDescription';

/**
* id of (filsystem) container for vacation templates
*
Expand Down Expand Up @@ -151,6 +158,16 @@ class HumanResources_Config extends Tinebase_Config_Abstract
'clientRegistryInclude' => TRUE,
'setByAdminModule' => TRUE,
),
self::ATTENDANCE_RECORDER_DEFAULT_TS_DESCRIPTION => [
// _('AR TS Description')
self::LABEL => 'AR TS Description',
// _('Default description for attendance recorder created timesheets.')
self::DESCRIPTION => 'Default description for attendance recorder created timesheets.',
self::TYPE => Tinebase_Config_Abstract::TYPE_STRING,
self::CLIENTREGISTRYINCLUDE => false,
self::SETBYADMINMODULE => true,
self::DEFAULT_STR => 'attendance recorder generated', // _('attendance recorder generated')
],
self::ENABLED_FEATURES => [
//_('Enabled Features')
self::LABEL => 'Enabled Features',
Expand Down Expand Up @@ -210,7 +227,11 @@ class HumanResources_Config extends Tinebase_Config_Abstract
//_('Timetracker Timeaccount for Workingtime Tracking')
'label' => 'Timetracker Timeaccount for Workingtime Tracking',
'description' => 'Timetracker Timeaccount for Workingtime Tracking',
'type' => Tinebase_Config_Abstract::TYPE_STRING,
self::TYPE => self::TYPE_RECORD,
self::OPTIONS => [
self::APPLICATION_NAME => Timetracker_Config::APP_NAME,
self::MODEL_NAME => Timetracker_Model_Timeaccount::MODEL_NAME_PART,
],
'clientRegistryInclude' => true,
'setByAdminModule' => true,
'setBySetupModule' => false,
Expand Down Expand Up @@ -314,4 +335,15 @@ public function getVacationExpirationDate($accountYear=null)
[$month, $day] = preg_split('/-/', $this->{self::VACATION_EXPIRES});
return new Tinebase_DateTime("{$year}-{$month}-{$day} 00:00:00");
}

public function getOptions($name, $definition) {
switch ($name) {
case self::DEFAULT_FEAST_CALENDAR:
return self::recordsToOption(Tinebase_Container::getInstance()->getSharedContainer(Tinebase_Core::getUser(), Calendar_Model_Event::class, [
Tinebase_Model_Grants::GRANT_READ
]));
default:
return parent::getOptions($name, $definition);
}
}
}
4 changes: 0 additions & 4 deletions tine20/HumanResources/HumanResources.jsb2
Expand Up @@ -71,10 +71,6 @@
"text": "AccountEditDialog.js",
"path": "js/"
},
{
"text": "AdminPanel.js",
"path": "js/"
},
{
"text": "WorkingTimeSchemeEditDialog.js",
"path": "js/"
Expand Down
6 changes: 6 additions & 0 deletions tine20/HumanResources/translations/de.po
Expand Up @@ -128,6 +128,12 @@ msgstr "Allen Arbeitszeiten unabhängig der Abteilungsrechte managen."
msgid "Clock in: %1$s"
msgstr "Einstemplen: %1$s"

msgid "AR TS Description"
msgstr "SU SZ Beschreibung"

msgid "Default description for attendance recorder created timesheets."
msgstr "Standard Beschreibung für durch die Stempeluhr erzeugte Stundenzettel."

msgid "attendance recorder generated"
msgstr "Angelegt durch die Stempeluhr"

Expand Down
18 changes: 18 additions & 0 deletions tine20/Tinebase/Config/Abstract.php
Expand Up @@ -967,6 +967,24 @@ public function getDefinition($_name)
return (isset($properties[$_name]) || array_key_exists($_name, $properties)) ? $properties[$_name] : NULL;
}

/**
* get options (for combo ui)
* @param $name
* @param $definition
* @return array [value => label] or null
*/
public function getOptions($name, $definition) {
return $definition['options'] ?? null;
}

public static function recordsToOption(Tinebase_Record_RecordSet $records) : array {
$options = [];
foreach($records as $record) {
$options[] = ['id' => $record->getId(), 'title' => $record->getTitle()];
}
return $options;
}

/**
* @param $target
* @param $key
Expand Down

0 comments on commit 2fe8e10

Please sign in to comment.