Skip to content

Commit

Permalink
Fix EnrollmentAttributes fiels
Browse files Browse the repository at this point in the history
  • Loading branch information
Ioannis authored and arlen committed Sep 24, 2024
1 parent c8fc075 commit 42ee120
Showing 1 changed file with 136 additions and 147 deletions.
283 changes: 136 additions & 147 deletions app/plugins/CoreEnroller/templates/EnrollmentAttributes/fields.inc
Original file line number Diff line number Diff line change
Expand Up @@ -461,172 +461,161 @@
<?php
// This view does currently not support read-only
if($vv_action == 'add' || $vv_action == 'edit') {
print $this->Field->control('label');

print $this->Field->control('description');
foreach ( ['label',
'description',
] as $field) {
print $this->element('form/listItem', [
'arguments' => [
'fieldName' => $field
]]);
}

print $this->Field->control(
fieldName: 'attribute',
options: [
'onChange' => 'updateGadgets()'
print $this->element('form/listItem', [
'arguments' => [
'fieldName' => 'attribute',
'fieldOptions' => [
'onChange' => 'updateGadgets()'
]
]
);
]);

print $this->Field->control(
fieldName: 'attribute_mvea_parent',
controlType: 'select',
/* options: [
// We default to an empty list then dynamically populate it
'options' => ['Person', 'PersonRole']
]*/
);
print $this->element('form/listItem', [
'arguments' => [
'fieldName' => 'attribute_mvea_parent',
]
]);

// This field is called attribute_type and not attribute_type_id because we want this
// to behave as a hidden value populated by the appropriate select, and we don't want
// Cake to implement foreign key automagic.
print $this->Field->control(
fieldName: 'attribute_type',
controlType: 'text'
);
print $this->element('form/listItem', [
'arguments' => [
'fieldName' => 'attribute_type'
]]);

// These are the actual selects that will render for the appropriate Attribute
print $this->Field->control(
fieldName: 'address_type_id',
// Because these fields don't exist in the database, we need to explicitly set the controlType
controlType: 'select',
options: [
'onChange' => "document.getElementById('attribute-type').value = document.getElementById('address-type-id').value"
]
);

print $this->Field->control(
fieldName: 'email_address_type_id',
controlType: 'select',
options: [
'onChange' => "document.getElementById('attribute-type').value = document.getElementById('email-address-type-id').value"
]
);

print $this->Field->control(
fieldName: 'identifier_type_id',
controlType: 'select',
options: [
'onChange' => "document.getElementById('attribute-type').value = document.getElementById('identifier-type-id').value"
]
);

print $this->Field->control(
fieldName: 'name_type_id',
controlType: 'select',
options: [
'onChange' => "document.getElementById('attribute-type').value = document.getElementById('name-type-id').value"
]
);

print $this->Field->control(
fieldName: 'pronoun_type_id',
controlType: 'select',
options: [
'onChange' => "document.getElementById('attribute-type').value = document.getElementById('pronoun-type-id').value"
]
);

print $this->Field->control(
fieldName: 'telephone_number_type_id',
controlType: 'select',
options: [
'onChange' => "document.getElementById('attribute-type').value = document.getElementById('telephone-number-type-id').value"
]
);

print $this->Field->control(
fieldName: 'url_type_id',
controlType: 'select',
options: [
'onChange' => "document.getElementById('attribute-type').value = document.getElementById('url-type-id').value"
]
);

print $this->Field->control('attribute_language');

print $this->Field->control('attribute_tag');

print $this->Field->control('status');
foreach (['address_type_id',
'email_address_type_id',
'identifier_type_id',
'name_type_id',
'pronoun_type_id',
'telephone_number_type_id',
'url_type_id',
] as $field) {
print $this->element('form/listItem', [
'arguments' => [
'fieldName' => $field,
'fieldOptions' => [
'onChange' => "document.getElementById('attribute-type').value = document.getElementById('" . $field . "').value"
]
]
]);
}

print $this->Field->control('ordr');
foreach ( ['attribute_language',
'attribute_tag',
'status',
'ordr',
] as $field) {
print $this->element('form/listItem', [
'arguments' => [
'fieldName' => $field
]]);
}

print $this->Field->control(
fieldName: 'default_value_validity_type',
controlType: 'select',
options: [
'options' => [
print $this->element('form/listItem', [
'arguments' => [
'fieldName' => 'default_value_validity_type',
'fieldOptions' => [
'on' => __d('core_enroller', 'enumeration.DefaultValueValidityType.on'),
'after' => __d('core_enroller', 'enumeration.DefaultValueValidityType.after')
],
// 'empty' => false,
'onChange' => 'updateValidityGadgets()'
]
);
'after' => __d('core_enroller', 'enumeration.DefaultValueValidityType.after'),
'onChange' => 'updateValidityGadgets()'
]
]]);

// print $this->Field->control(
// fieldName: 'default_value_validity_type',
// controlType: 'select',
// options: [
// 'options' => [
// 'on' => __d('core_enroller', 'enumeration.DefaultValueValidityType.on'),
// 'after' => __d('core_enroller', 'enumeration.DefaultValueValidityType.after')
// ],
//// 'empty' => false,
// 'onChange' => 'updateValidityGadgets()'
// ]
// );

// The default value is always stored in default_value, however for select based fields
// (such as cou_id or affiliation) the value is copied into default_value and the
// field specific attribute is used for display purposes only
print $this->Field->control('default_value');

print $this->Field->control(
fieldName: 'default_value_affiliation_type_id',
controlType: 'select',
options: [
'onChange' => "document.getElementById('default-value').value = document.getElementById('default-value-affiliation-type-id').value"
]
);

print $this->Field->control(
fieldName: 'default_value_cou_id',
controlType: 'select',
options: [
'onChange' => "document.getElementById('default-value').value = document.getElementById('default-value-cou-id').value"
]
);

print $this->Field->dateControl(
fieldName: 'default_value_datetime',
options: [
]
);

print $this->Field->control('default_value_env_name');
print $this->element('form/listItem', [
'arguments' => [
'fieldName' => 'default_value'
]]);

foreach (['default_value_affiliation_type_id',
'default_value_cou_id',
'default_value_group_id'
] as $field) {
print $this->element('form/listItem', [
'arguments' => [
'fieldName' => $field,
'fieldOptions' => [
'onChange' => "document.getElementById('default-value').value = document.getElementById('" . $field . "').value"
]
]
]);
}

print $this->Field->control(
fieldName: 'default_value_group_id',
controlType: 'select',
options: [
'onChange' => "document.getElementById('default-value').value = document.getElementById('default-value-group-id').value"
]
);
foreach ( ['default_value_datetime',
'default_value_env_name',
] as $field) {
print $this->element('form/listItem', [
'arguments' => [
'fieldName' => $field
]]);
}

print $this->Field->control('required', ['default' => true]);
print $this->element('form/listItem', [
'arguments' => [
'fieldName' => 'required',
'fieldOptions' => [
'default' => true
]
]]);

// Like attribute_type, this is a "behind the scenes" field that is not directly edited
print $this->Field->control('attribute_required_fields');

print $this->Field->control(
fieldName: 'address_required_fields',
controlType: 'select',
options: [
'onChange' => "document.getElementById('attribute-required-fields').value = document.getElementById('address-required-fields').value"
]
);

print $this->Field->control(
fieldName: 'name_required_fields',
controlType: 'select',
options: [
'onChange' => "document.getElementById('attribute-required-fields').value = document.getElementById('name-required-fields').value"
]
);

print $this->Field->control('modifiable', ['default' => true]);
print $this->element('form/listItem', [
'arguments' => [
'fieldName' => 'attribute_required_fields'
]]);

foreach ([
'address_required_fields',
'name_required_fields',

] as $field) {
print $this->element('form/listItem', [
'arguments' => [
'fieldName' => $field,
'fieldOptions' => [
'onChange' => "document.getElementById('attribute-required-fields').value = document.getElementById('" . $field . "').value"
]
]
]);
}

print $this->Field->control('hidden');
print $this->element('form/listItem', [
'arguments' => [
'fieldName' => 'modifiable',
'fieldOptions' => [
'default' => true
]
]]);

print $this->element('form/listItem', [
'arguments' => [
'fieldName' => 'hidden'
]]);
}

0 comments on commit 42ee120

Please sign in to comment.