From eb5ec338dbfeca5fea0551412d51c0d4717da618 Mon Sep 17 00:00:00 2001 From: Josh Worden Date: Tue, 15 Feb 2022 15:25:58 -0600 Subject: [PATCH 01/18] Add city, street, extra fields, hidden support --- .../api/fragments/active-user.js | 3 + .../browser/form/fields/address-extra.vue | 64 +++++++++++++++++++ .../browser/form/fields/city.vue | 64 +++++++++++++++++++ .../browser/form/fields/street.vue | 64 +++++++++++++++++++ .../marko-web-identity-x/browser/profile.vue | 47 +++++++++++++- .../components/form-profile.marko | 1 + packages/marko-web-identity-x/config.js | 7 ++ .../marko-web-identity-x/routes/profile.js | 6 ++ 8 files changed, 253 insertions(+), 3 deletions(-) create mode 100644 packages/marko-web-identity-x/browser/form/fields/address-extra.vue create mode 100644 packages/marko-web-identity-x/browser/form/fields/city.vue create mode 100644 packages/marko-web-identity-x/browser/form/fields/street.vue diff --git a/packages/marko-web-identity-x/api/fragments/active-user.js b/packages/marko-web-identity-x/api/fragments/active-user.js index 2b2c4b991..a30225ed9 100644 --- a/packages/marko-web-identity-x/api/fragments/active-user.js +++ b/packages/marko-web-identity-x/api/fragments/active-user.js @@ -14,6 +14,9 @@ fragment ActiveUserFragment on AppUser { countryCode regionCode postalCode + city + street + addressExtra receiveEmail mustReVerifyProfile externalIds { diff --git a/packages/marko-web-identity-x/browser/form/fields/address-extra.vue b/packages/marko-web-identity-x/browser/form/fields/address-extra.vue new file mode 100644 index 000000000..d1970e3e4 --- /dev/null +++ b/packages/marko-web-identity-x/browser/form/fields/address-extra.vue @@ -0,0 +1,64 @@ + + + diff --git a/packages/marko-web-identity-x/browser/form/fields/city.vue b/packages/marko-web-identity-x/browser/form/fields/city.vue new file mode 100644 index 000000000..c24770d66 --- /dev/null +++ b/packages/marko-web-identity-x/browser/form/fields/city.vue @@ -0,0 +1,64 @@ + + + diff --git a/packages/marko-web-identity-x/browser/form/fields/street.vue b/packages/marko-web-identity-x/browser/form/fields/street.vue new file mode 100644 index 000000000..3fa8acb13 --- /dev/null +++ b/packages/marko-web-identity-x/browser/form/fields/street.vue @@ -0,0 +1,64 @@ + + + diff --git a/packages/marko-web-identity-x/browser/profile.vue b/packages/marko-web-identity-x/browser/profile.vue index 43238498a..8efbfc6b0 100644 --- a/packages/marko-web-identity-x/browser/profile.vue +++ b/packages/marko-web-identity-x/browser/profile.vue @@ -40,9 +40,6 @@ :required="isFieldRequired('countryCode')" /> - - -
+
+ +
+
+ +
+
+
+ +
+
+ +
+
+
[], }, + hiddenFields: { + type: Array, + default: () => [], + }, reloadPageOnSubmit: { type: Boolean, default: false, @@ -351,6 +382,16 @@ export default { isFieldRequired(name) { return this.requiredFields.includes(name); }, + /** + * + */ + isFieldHidden(name) { + return this.hiddenFields.includes(name); + }, + + isFieldVisible(name) { + return !this.isFieldHidden(name); + }, getRegionalPolicyAnswer(policyId) { return this.user.regionalConsentAnswers.find(a => a.id === policyId); diff --git a/packages/marko-web-identity-x/components/form-profile.marko b/packages/marko-web-identity-x/components/form-profile.marko index adfe4d371..1f303443b 100644 --- a/packages/marko-web-identity-x/components/form-profile.marko +++ b/packages/marko-web-identity-x/components/form-profile.marko @@ -9,6 +9,7 @@ $ const { identityX } = req; activeUser: user, requiredServerFields: identityX.config.getRequiredServerFields(), requiredClientFields: identityX.config.getRequiredClientFields(), + hiddenFields: identityX.config.getHiddenFields(), callToAction: input.callToAction, reloadPageOnSubmit: input.reloadPageOnSubmit, endpoints: identityX.config.getEndpoints(), diff --git a/packages/marko-web-identity-x/config.js b/packages/marko-web-identity-x/config.js index 3ba7343b9..9e7727508 100644 --- a/packages/marko-web-identity-x/config.js +++ b/packages/marko-web-identity-x/config.js @@ -12,6 +12,7 @@ class IdentityXConfiguration { * @param {string} [options.apiToken] An API token to use. Only required when doing write ops. * @param {string[]} [options.requiredServerFields] Required fields, server enforced. * @param {string[]} [options.requiredClientFields] Required fields, client-side only. + * @param {string[]} [options.hiddenFields] The fields to include in the profile. * @param {function} [options.onHookError] * @param {...object} options.rest */ @@ -20,6 +21,7 @@ class IdentityXConfiguration { apiToken, requiredServerFields = [], requiredClientFields = [], + hiddenFields = ['city', 'street', 'addressExtra'], onHookError, ...rest } = {}) { @@ -29,6 +31,7 @@ class IdentityXConfiguration { this.options = { requiredServerFields, requiredClientFields, + hiddenFields, onHookError: (e) => { if (process.env.NODE_ENV === 'development') { log('ERROR IN IDENTITY-X HOOK', e); @@ -89,6 +92,10 @@ class IdentityXConfiguration { return this.getAsArray('requiredClientFields'); } + getHiddenFields() { + return this.getAsArray('requiredClientFields'); + } + get(path, def) { return get(this.options, path, def); } diff --git a/packages/marko-web-identity-x/routes/profile.js b/packages/marko-web-identity-x/routes/profile.js index caa9267ba..e0b5281fe 100644 --- a/packages/marko-web-identity-x/routes/profile.js +++ b/packages/marko-web-identity-x/routes/profile.js @@ -47,6 +47,9 @@ module.exports = asyncRoute(async (req, res) => { countryCode, regionCode, postalCode, + city, + street, + addressExtra, receiveEmail, regionalConsentAnswers, customBooleanFieldAnswers, @@ -60,6 +63,9 @@ module.exports = asyncRoute(async (req, res) => { countryCode, regionCode, postalCode, + city, + street, + addressExtra, receiveEmail, }; From 205d44d4aa12aba6d0e31fd18704c66c20769852 Mon Sep 17 00:00:00 2001 From: Josh Worden Date: Wed, 16 Feb 2022 10:51:15 -0600 Subject: [PATCH 02/18] Fix field name --- packages/marko-web-identity-x/config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/marko-web-identity-x/config.js b/packages/marko-web-identity-x/config.js index 9e7727508..363fb8d69 100644 --- a/packages/marko-web-identity-x/config.js +++ b/packages/marko-web-identity-x/config.js @@ -93,7 +93,7 @@ class IdentityXConfiguration { } getHiddenFields() { - return this.getAsArray('requiredClientFields'); + return this.getAsArray('hiddenFields'); } get(path, def) { From f452ad759558f3fd5d2d5694ba2c8d3ec014c020 Mon Sep 17 00:00:00 2001 From: Josh Worden Date: Wed, 16 Feb 2022 11:11:14 -0600 Subject: [PATCH 03/18] Move address fields into a component --- .../browser/form/address-block.vue | 112 ++++++++++++++++++ .../marko-web-identity-x/browser/profile.vue | 76 +----------- 2 files changed, 117 insertions(+), 71 deletions(-) create mode 100644 packages/marko-web-identity-x/browser/form/address-block.vue diff --git a/packages/marko-web-identity-x/browser/form/address-block.vue b/packages/marko-web-identity-x/browser/form/address-block.vue new file mode 100644 index 000000000..4dba43059 --- /dev/null +++ b/packages/marko-web-identity-x/browser/form/address-block.vue @@ -0,0 +1,112 @@ + + + diff --git a/packages/marko-web-identity-x/browser/profile.vue b/packages/marko-web-identity-x/browser/profile.vue index 8efbfc6b0..bef637277 100644 --- a/packages/marko-web-identity-x/browser/profile.vue +++ b/packages/marko-web-identity-x/browser/profile.vue @@ -40,44 +40,13 @@ :required="isFieldRequired('countryCode')" />
-
- -
-
- -
-
- -
-
- -
-
-
- -
-
- -
-
+
import post from './utils/post'; import cookiesEnabled from './utils/cookies-enabled'; -import regionCountryCodes from './utils/region-country-codes'; -import City from './form/fields/city.vue'; import CustomBoolean from './form/fields/custom-boolean.vue'; import CustomSelect from './form/fields/custom-select.vue'; import GivenName from './form/fields/given-name.vue'; @@ -178,12 +145,8 @@ import FamilyName from './form/fields/family-name.vue'; import Organization from './form/fields/organization.vue'; import OrganizationTitle from './form/fields/organization-title.vue'; import Country from './form/fields/country.vue'; -import Region from './form/fields/region.vue'; -import PostalCode from './form/fields/postal-code.vue'; import ReceiveEmail from './form/fields/receive-email.vue'; import RegionalPolicy from './form/fields/regional-policy.vue'; -import Street from './form/fields/street.vue'; -import AddressExtra from './form/fields/address-extra.vue'; import Login from './login.vue'; import FeatureError from './errors/feature'; @@ -193,7 +156,6 @@ const { isArray } = Array; export default { components: { - City, CustomBoolean, CustomSelect, GivenName, @@ -201,12 +163,8 @@ export default { Organization, OrganizationTitle, Country, - Region, - PostalCode, ReceiveEmail, RegionalPolicy, - Street, - AddressExtra, Login, }, @@ -304,20 +262,6 @@ export default { return user.countryCode; }, - /** - * - */ - displayRegionField() { - return regionCountryCodes.includes(this.countryCode); - }, - - /** - * - */ - displayPostalCodeField() { - return this.displayRegionField; - }, - submitMessage() { const message = 'Profile updated.'; if (this.isReloadingPage) return `${message} Reloading page...`; @@ -382,16 +326,6 @@ export default { isFieldRequired(name) { return this.requiredFields.includes(name); }, - /** - * - */ - isFieldHidden(name) { - return this.hiddenFields.includes(name); - }, - - isFieldVisible(name) { - return !this.isFieldHidden(name); - }, getRegionalPolicyAnswer(policyId) { return this.user.regionalConsentAnswers.find(a => a.id === policyId); From 97ece24e24ac220a8b610da464d5dd1995af6842 Mon Sep 17 00:00:00 2001 From: Josh Worden Date: Wed, 16 Feb 2022 11:30:41 -0600 Subject: [PATCH 04/18] Wrap with fieldset/legend --- .../browser/form/address-block.vue | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/packages/marko-web-identity-x/browser/form/address-block.vue b/packages/marko-web-identity-x/browser/form/address-block.vue index 4dba43059..9dc939498 100644 --- a/packages/marko-web-identity-x/browser/form/address-block.vue +++ b/packages/marko-web-identity-x/browser/form/address-block.vue @@ -1,5 +1,9 @@ From fba93e186e80c4af8bec21314839819949161b76 Mon Sep 17 00:00:00 2001 From: Josh Worden Date: Wed, 16 Feb 2022 11:31:34 -0600 Subject: [PATCH 05/18] move street/extra, set width logic --- .../browser/form/address-block.vue | 29 ++++++-------- .../browser/form/fields/street.vue | 40 ++++++++++++------- 2 files changed, 38 insertions(+), 31 deletions(-) diff --git a/packages/marko-web-identity-x/browser/form/address-block.vue b/packages/marko-web-identity-x/browser/form/address-block.vue index 9dc939498..e0099bfbb 100644 --- a/packages/marko-web-identity-x/browser/form/address-block.vue +++ b/packages/marko-web-identity-x/browser/form/address-block.vue @@ -4,6 +4,19 @@ Address +
+ + +
+
- -
-
- -
-
- -
-
-
diff --git a/packages/marko-web-identity-x/browser/form/fields/street.vue b/packages/marko-web-identity-x/browser/form/fields/street.vue index 3fa8acb13..88f037c76 100644 --- a/packages/marko-web-identity-x/browser/form/fields/street.vue +++ b/packages/marko-web-identity-x/browser/form/fields/street.vue @@ -1,19 +1,21 @@ diff --git a/packages/marko-web-identity-x/browser/form/fields/city.vue b/packages/marko-web-identity-x/browser/form/fields/city.vue index c24770d66..e21cb007c 100644 --- a/packages/marko-web-identity-x/browser/form/fields/city.vue +++ b/packages/marko-web-identity-x/browser/form/fields/city.vue @@ -1,5 +1,5 @@