Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed #15344 - make select2 for countries freeform-ish #15367

Merged
merged 3 commits into from
Aug 22, 2024

Conversation

snipe
Copy link
Owner

@snipe snipe commented Aug 22, 2024

This is a sort of compromise for #15344, which correctly asserts that we do not validate country value on the API or importer. We cannot do that since the data sources on the admin's side may not comply with ISO 3166-1 alpha-2 codes or UK's extended codes, and would lead to model-level validation when those codes don't match when being entered/updated via API, CSV import, or SCIM (since the source data in the LDAP directory, SCIM directory, etc might not be compliant.)

The challenge is that if that info from the directory didn't match the ISO two letter codes, the field value for country would be accepted, but it would not be selected (since that arbitrary value doesn't exist in our countries array so it would never find a match to mark as the selected option) and thus that country value would be dropped on saving if the user didn't notice nothing was selected.

Screen.Recording.2024-08-22.at.11.03.07.AM.mov

Signed-off-by: snipe <snipe@snipe.net>
@snipe snipe marked this pull request as draft August 22, 2024 09:50
Copy link

what-the-diff bot commented Aug 22, 2024

PR Summary

  • Localization Updates
    The pull request makes changes to our localizations. Previously, the United Kingdom was only labeled as 'UK'. Now the application will differentiate between England ('GB-ENG'), Northern Ireland ('GB-NIR'), Scotland ('GB-SCT') and Wales ('GB-WLS').

  • Improved macBegDropDown() Function
    The macBegDropDown() function in resources/macros/macros.php has been optimized to better handle the selection of country values. If the country value already exists in the array it is selected, otherwise it gets added as a new option.

  • HTML select Element Enhancement
    The select element attribute data-tags value has been changed to "true", which means tags can be used. Furthermore, if a selected country value is not available in our options, it creates a new option with the selected country value and labels it as 'New'.

  • Code Cleanup
    Unnecessary comments and redundant variable declarations in resources/macros/macros.php have been removed for better code readability and performance.

snipe added 2 commits August 22, 2024 11:01
Signed-off-by: snipe <snipe@snipe.net>
Signed-off-by: snipe <snipe@snipe.net>
@snipe snipe marked this pull request as ready for review August 22, 2024 10:04
@snipe snipe merged commit 9608414 into develop Aug 22, 2024
8 of 9 checks passed
@snipe snipe deleted the fixes/15344_added_freeform_to_country_select2 branch August 22, 2024 10:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant