diff --git a/app/config/schema/schema.json b/app/config/schema/schema.json index 190826b33..da2844120 100644 --- a/app/config/schema/schema.json +++ b/app/config/schema/schema.json @@ -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": { diff --git a/app/src/Model/Table/CoSettingsTable.php b/app/src/Model/Table/CoSettingsTable.php index 40d93824a..33884a2f5 100644 --- a/app/src/Model/Table/CoSettingsTable.php +++ b/app/src/Model/Table/CoSettingsTable.php @@ -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, @@ -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()]] diff --git a/app/src/Model/Table/GroupsTable.php b/app/src/Model/Table/GroupsTable.php index 3350ab7a1..f42470ee1 100644 --- a/app/src/Model/Table/GroupsTable.php +++ b/app/src/Model/Table/GroupsTable.php @@ -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' ] ] diff --git a/app/webroot/js/comanage/components/autocomplete/cm-autocomplete-people.js b/app/webroot/js/comanage/components/autocomplete/cm-autocomplete-people.js index 32f416a5b..aa0cad4a3 100644 --- a/app/webroot/js/comanage/components/autocomplete/cm-autocomplete-people.js +++ b/app/webroot/js/comanage/components/autocomplete/cm-autocomplete-people.js @@ -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'] + ": " } }) diff --git a/app/webroot/js/comanage/components/autocomplete/item-with-type.js b/app/webroot/js/comanage/components/autocomplete/item-with-type.js index 03e734beb..9766b99c3 100644 --- a/app/webroot/js/comanage/components/autocomplete/item-with-type.js +++ b/app/webroot/js/comanage/components/autocomplete/item-with-type.js @@ -54,7 +54,7 @@ export default { - + {{ this.type }}