Skip to content

Commit

Permalink
Fix CoSettings picker configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
Ioannis committed Aug 23, 2024
1 parent 8527bc9 commit a13b802
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 31 deletions.
4 changes: 2 additions & 2 deletions app/config/schema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@
"required_fields_name": { "type": "string", "size": 160 },
"search_global_limit": { "type": "integer" },
"search_global_limited_models": { "type": "boolean" },
"person_picker_email_type": { "type": "integer" },
"person_picker_identifier_type": { "type": "integer" },
"person_picker_email_address_type_id": { "type": "integer" },
"person_picker_identifier_type_id": { "type": "integer" },
"person_picker_display_types": { "type": "boolean" }
},
"indexes": {
Expand Down
46 changes: 23 additions & 23 deletions app/src/Model/Table/CoSettingsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,25 +222,25 @@ public function addDefaults(int $coId): int {
// Default values for each setting

$defaultSettings = [
'co_id' => $coId,
'default_address_type_id' => null,
'default_email_address_type_id' => null,
'default_identifier_type_id' => null,
'default_name_type_id' => null,
'default_pronoun_type_id' => null,
'default_telephone_number_type_id' => null,
'default_url_type_id' => null,
'email_smtp_server_id' => null,
'email_delivery_address_type_id' => null,
'permitted_fields_name' => PermittedNameFieldsEnum::HGMFS,
'permitted_fields_telephone_number' => PermittedTelephoneNumberFieldsEnum::CANE,
'person_picker_email_type' => null,
'person_picker_identifier_type' => null,
'person_picker_display_types' => true,
'required_fields_address' => RequiredAddressFieldsEnum::Street,
'required_fields_name' => RequiredNameFieldsEnum::Given,
'search_global_limit' => DEF_GLOBAL_SEARCH_LIMIT,
'search_limited_models' => false
'co_id' => $coId,
'default_address_type_id' => null,
'default_email_address_type_id' => null,
'default_identifier_type_id' => null,
'default_name_type_id' => null,
'default_pronoun_type_id' => null,
'default_telephone_number_type_id' => null,
'default_url_type_id' => null,
'email_smtp_server_id' => null,
'email_delivery_address_type_id' => null,
'permitted_fields_name' => PermittedNameFieldsEnum::HGMFS,
'permitted_fields_telephone_number' => PermittedTelephoneNumberFieldsEnum::CANE,
'person_picker_email_address_type_id' => null,
'person_picker_identifier_type_id' => null,
'person_picker_display_types' => true,
'required_fields_address' => RequiredAddressFieldsEnum::Street,
'required_fields_name' => RequiredNameFieldsEnum::Given,
'search_global_limit' => DEF_GLOBAL_SEARCH_LIMIT,
'search_limited_models' => false
// XXX to add new settings, set a default here, then add a validation rule below
// also update data model documentation
// 'disable_expiration' => false,
Expand Down Expand Up @@ -416,15 +416,15 @@ public function validationDefault(Validator $validator): Validator {
]);
$validator->allowEmptyString('person_picker_display_types');

$validator->add('person_picker_email_type', [
$validator->add('person_picker_email_address_type_id', [
'content' => ['rule' => 'isInteger']
]);
$validator->allowEmptyString('person_picker_email_type');
$validator->allowEmptyString('person_picker_email_address_type_id');

$validator->add('person_picker_identifier_type', [
$validator->add('person_picker_identifier_type_id', [
'content' => ['rule' => 'isInteger']
]);
$validator->allowEmptyString('person_picker_identifier_type');
$validator->allowEmptyString('person_picker_identifier_type_id');

$validator->add('required_fields_address', [
'content' => ['rule' => ['inList', RequiredAddressFieldsEnum::getConstValues()]]
Expand Down
2 changes: 1 addition & 1 deletion app/src/Model/Table/GroupsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public function initialize(array $config): void {
// For the Groups Filtering block we want to
// pick/GET from the entire CO pool of people
'action' => 'GET',
// The co configuration will fall throught the default configuration
// The co configuration will fall through the default configuration
'for' => 'co'
]
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,16 +141,36 @@ export default {
}
return str
},
filterByEmailAddressType(items) {
if(this.app.cosettings[0].person_picker_email_address_type_id == null
|| this.app.cosettings[0].person_picker_email_address_type_id == '') {
return items
}

return items.filter((item) => {
return item.type_id == this.app.cosettings[0].person_picker_email_address_type_id;
})
},
filterByIdentifierType(items) {
if(this.app.cosettings[0].person_picker_identifier_type_id == ''
|| this.app.cosettings[0].person_picker_identifier_type_id == null) {
return items
}

return items.filter((item) => {
return item.type_id == this.app.cosettings[0].person_picker_identifier_type_id;
})
},
parseResponse(data) {
return data?.People?.map((item) => {
return {
"value": item.id,
"label": `${item?.primary_name?.given} ${item?.primary_name?.family} (ID: ${item?.id})`,
"email": item?.email_addresses,
"emailPretty": this.shortenString(this.constructEmailCsv(item?.email_addresses)),
"email": this.filterByEmailAddressType(item?.email_addresses),
"emailPretty": this.shortenString(this.constructEmailCsv(this.filterByEmailAddressType(item?.email_addresses))),
"emailLabel": this.txt['email'] + ": ",
"identifier": item?.identifiers,
"identifierPretty": this.shortenString(this.constructIdentifierCsv(item?.identifiers)),
"identifier": this.filterByIdentifierType(item?.identifiers),
"identifierPretty": this.shortenString(this.constructIdentifierCsv(this.filterByIdentifierType(item?.identifiers))),
"identifierLabel": this.txt['Identifiers'] + ": "
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default {
<span class="value">
<span v-html="highlightedquery(this.val, query)"></span>
</span>
<span class="type">
<span v-if="app.cosettings[0].person_picker_display_types" class="type">
{{ this.type }}
</span>
</div>
Expand Down

0 comments on commit a13b802

Please sign in to comment.