Skip to content

Commit

Permalink
Refactor Enrollment Attributes Add/Edit view (#224)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ioannis authored Sep 30, 2024
1 parent 6ab65c2 commit b9f19e9
Show file tree
Hide file tree
Showing 10 changed files with 296 additions and 547 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ msgstr "{0,plural,=1{Enrollment Attribute} other{Enrollment Attributes}}"
msgid "enumeration.DefaultValueValidityType.after"
msgstr "Days After Finalization"

msgid "enumeration.DefaultValueValidityType.on"
msgstr "On This Date"

msgid "field.EnrollmentAttributes.address_required_fields"
msgstr "Required Address Fields"

Expand All @@ -57,19 +54,22 @@ msgid "field.EnrollmentAttributes.default_value"
msgstr "Default Value"

msgid "field.EnrollmentAttributes.default_value_affiliation_type_id"
msgstr "Default Value"
msgstr "Default Affiliation Type"

msgid "field.EnrollmentAttributes.default_value_cou_id"
msgstr "Default Value"
msgstr "Default Cou"

msgid "field.EnrollmentAttributes.default_value_datetime"
msgstr "Default Value"
msgstr "Default Datetime"

msgid "field.EnrollmentAttributes.default_value_datetime.desc"
msgstr "On This Date"

msgid "field.EnrollmentAttributes.default_value_env_name"
msgstr "Environmental Variable for Default Value"

msgid "field.EnrollmentAttributes.default_value_group_id"
msgstr "Default Value"
msgstr "Default Group"

msgid "field.EnrollmentAttributes.default_value_validity_type"
msgstr "Default Validity Date Type"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ public function supportedAttributes(string $format='full'): array {

$attrs['name'] = [
'label' => __d('controller', 'Names', [1]),
'mveaModel' => 'Namen',
'mveaModel' => 'Names',
'mveaParents' => ['Person']
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*/

declare(strict_types = 1);

use \Cake\Utility\Inflector;

$indexColumns = [
'label' => [
'type' => 'link',
Expand All @@ -46,4 +50,69 @@ $indexColumns = [
'type' => 'boolean',
'class' => 'YesBooleanEnum'
]
];
];


if(empty($attributes)) {
return;
}

// Map attributes to icons
$attributeToIcons =
[
'adHocAttribute' => 'grass',
'address' => 'home',
'affiliation_type_id' => 'person_search',
'cou_id' => 'supervised_user_circle',
'date_of_birth' => 'event',
'department' => 'domain',
'emailAddress' => 'email',
'group_id' => 'groups',
'identifier' => 'badge',
'manager_person_id' => 'supervisor_account',
'name' => 'face',
'organization' => 'corporate_fare',
'pronoun' => 'transgender',
'sponsor_person_id' => 'person',
'telephoneNumber' => 'call',
'petition_textarea' => 'text_fields',
'petition_text' => 'text_fields',
'title' => 'title',
'url' => 'link',
'valid_from' => 'calendar_month',
'valid_through' => 'calendar_month'
];

// Build the Add menu
$action_args = array();
// This is an add action as a result we do not have an obect id
// and we will use the username instead.
$action_args['vv_attr_id'] = $vv_user['username'];
$action_args['vv_actions_type'] = 'mvea-add-menu';
$action_args['vv_actions_title'] = __d('operation', 'add');
$action_args['vv_actions_icon'] = 'add_circle';
$action_args['vv_actions_class'] = 'mvea-add-menu';
$actionOrderDefault = $this->Menu->getMenuOrder('Default');
foreach ($attributes as $attr => $hr_name) {
$actionLabel = $hr_name;
$actionClass = 'cm-modal-link nospin';
$actionOrder = $actionOrderDefault++;
$actionIcon = $attributeToIcons[$attr] ?? $this->Menu->getMenuIcon('Default');
$dataAttrs = ['data-cm-modal-title', __d('file-connector', 'EnrollmentAttributes', 1)];
$actionUrl = [
'pluing' => $this->getPlugin(),
'controller' => $vv_controller,
'action' => 'add',
'?' => array_merge($linkFilter, ['attribute_type' => $attr])
];

$action_args['vv_actions'][] = [
'order' => $actionOrder,
'icon' => $actionIcon,
'iconClass' => '',
'url' => $actionUrl,
'class' => $actionClass,
'label' => $actionLabel,
'dataAttrs' => []
];
}
Loading

0 comments on commit b9f19e9

Please sign in to comment.