Add PhoneField content field with intl-tel-input integration#468
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
This pull request has merge conflicts. Please resolve those before requesting a review. |
|
@copilot resolve the merge conflicts in this pull request |
Co-authored-by: MikeAlhayek <24724371+MikeAlhayek@users.noreply.github.com>
Merge conflicts have been resolved in commit
|
Remove hardcoded CSS variable overrides for flag image paths that were breaking image resolution. The library's own CSS uses relative paths (../img/) which correctly resolve both from CDN and local static files. Add SRI integrity hashes (sha384) for both the CSS and JS CDN resources to ensure subresource integrity verification. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
@copilot i think the .webp file used for the flags needs to also be copied from the node_modules folder using the copy action in assets.json |
The { "copy": true, "inputs": ["node_modules/intl-tel-input/build/img/flags.webp"], "output": "wwwroot/vendors/intl-tel-input/img/flags.webp" },
{ "copy": true, "inputs": ["node_modules/intl-tel-input/build/img/flags@2x.webp"], "output": "wwwroot/vendors/intl-tel-input/img/flags@2x.webp" },
{ "copy": true, "inputs": ["node_modules/intl-tel-input/build/img/globe.webp"], "output": "wwwroot/vendors/intl-tel-input/img/globe.webp" },
{ "copy": true, "inputs": ["node_modules/intl-tel-input/build/img/globe@2x.webp"], "output": "wwwroot/vendors/intl-tel-input/img/globe@2x.webp" }The |
Gulp 5 defaults gulp.src() to encoding: 'utf8' which corrupts binary
files during copy operations. Add { encoding: false } to the copy
pipeline to preserve binary data integrity.
Also add .gitattributes rules to explicitly mark image and font files
as binary to prevent future text-mode corruption.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Replace the InternationalTelephone TextField editor with a dedicated PhoneField content field that stores the E.164 phone number, ISO country code, and national number separately. This ensures the correct country flag is always displayed when the field is loaded for editing, even for countries that share a calling code (e.g. US and CA both use +1). - Add PhoneField, PhoneFieldSettings, display driver, and settings driver - Add edit, display, and settings views with intl-tel-input integration - Migrate PhoneNumberInfoPart.Number from TextField to PhoneField - Update Omnichannel index provider, helper, import handler, and tests - Update documentation, changelog, and sidebar navigation Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Replace the plain DefaultCountryCode text input with a three-option InitialCountryMode setting (Globe, Current culture, Specific) that controls which country flag is pre-selected when the phone field is empty. Specific mode shows a dropdown of all supported countries populated from IPhoneNumberService.GetSupportedRegions(). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Schedule a background deferred task in UpdateFrom1Async that migrates existing PhoneNumber content items from the old TextField format (Number.Text) to the new PhoneField format (Number.PhoneNumber, Number.CountryCode, Number.NationalNumber). Assumes US region for existing records, validates via IPhoneNumberService, and skips invalid numbers. Processes in batches of 100 with a separate session per batch. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Rewrite MigratePhoneNumberDataAsync to: - First query IContentDefinitionManager for all content types that have PhoneNumberInfoPart attached instead of hardcoding a single type - Use a while loop with Skip/Take pagination (100 per batch) - Create a fresh session per batch to avoid holding all items in memory - Break when a batch returns no more records Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
PhoneNumber content items are embedded inside a BagPart named ContactMethods on parent content items that have OmnichannelContactPart. They are not separate YesSql documents, so the previous approach of querying ContentItemIndex for PhoneNumber type would find nothing. Now the migration: - Discovers content types with OmnichannelContactPart attached - Queries those parent documents via cursor-based pagination - Navigates into ContactMethods BagPart -> ContentItems array - Migrates each inner PhoneNumber item's Number field from TextField to PhoneField format Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
ContentTransferMigrations.UpdateFrom1Async() was failing with a SqliteException because it queries the Direction column that only exists in the v2 CreateAsync schema. Tenants at v1 never had this column added. The exception caused the DataMigrationManager to cancel the YesSql session, which prevented ALL other migration version updates in the same startup cycle from being committed -- including ContactMethodMigrations. This caused ContactMethodMigrations to re-run from version 1 on every app restart, and its schema changes (TextField to PhoneField) were never persisted. Fix: Add the Direction column and its index in UpdateFrom1Async before attempting to use it. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
OmnichannelContactsMigrations.UpdateFrom2Async was throwing an uncaught SqliteException (duplicate column name: TimeZoneId) because the DDL committed on a previous run but the version was never saved. This cancelled the YesSql session and prevented ContactMethodMigrations from persisting its version update. Also downgrade ContentTransferMigrations catch from LogError to LogWarning since the duplicate column scenario is expected. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Use a MutationObserver to detect new [data-phone-field] elements added to the DOM after page load (e.g. when adding a contact method via BagPart). The observer watches document.body for childList mutations and initializes intl-tel-input on any newly inserted phone fields. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Motivation
The Omnichannel Management module's
PhoneNumberInfoPart.Numberwas originally aTextField, which can only store a single string value. This made it impossible to correctly reload the country flag when editing a phone number, because countries like the US and Canada share the same calling code (+1). A dedicated field type is needed to persist the country code alongside the phone number.Approach
New
PhoneFieldcontent fieldAdds a custom
PhoneFieldin the newCrestApps.OrchardCore.ContentFieldsmodule that stores three properties:+14155552671)US,CA) for correct flag displayThe field includes a display driver with server-side validation via
IPhoneNumberService, a settings driver (withRequired,Hint,DefaultCountryCode), and edit/display/settings views.Shared intl-tel-input resources
The intl-tel-input library assets (JS, CSS, flag images) live in
CrestApps.OrchardCore.Resourceswith CDN + SRI hashes and local fallback copies.ContentFieldsdepends onResourcesfor reusability.Gulp 5 binary copy fix
Fixed
buildCopyPipelineingulpfile.jsto pass{ encoding: false }so Gulp 5 does not corrupt binary assets (.webpflag images) during copy.Omnichannel migration
PhoneNumberInfoPart.Numberchanged fromTextFieldtoPhoneFieldContactMethodMigrations.UpdateFrom1Asyncremoves the oldTextFieldand adds aPhoneFieldOmnichannelContactIndexProvider,OmnichannelHelper, import handler, tests) updated from.Number.Textto.Number.PhoneNumberValidation
-warnaserror)npm run rebuild) clean