Skip to content
This repository has been archived by the owner on Dec 9, 2024. It is now read-only.

Commit

Permalink
Merge pull request #248 from solocommand/idx-address-fields
Browse files Browse the repository at this point in the history
Add city, street, extra fields, hidden support
  • Loading branch information
zarathustra323 authored Feb 17, 2022
2 parents 0bda447 + 56f5882 commit 5f4e86b
Show file tree
Hide file tree
Showing 11 changed files with 426 additions and 45 deletions.
3 changes: 3 additions & 0 deletions packages/marko-web-identity-x/api/fragments/active-user.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ fragment ActiveUserFragment on AppUser {
countryCode
regionCode
postalCode
city
street
addressExtra
receiveEmail
mustReVerifyProfile
externalIds {
Expand Down
99 changes: 99 additions & 0 deletions packages/marko-web-identity-x/browser/form/address-block.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<template>
<fieldset class="px-3 border mb-3">
<legend class="h6 w-auto">
Address
</legend>

<div v-if="street.visible" class="row">
<street
v-model="user.street"
:required="street.required"
:class-name="addressExtra.visible ? 'col-md-8' : 'col-md-12'"
/>
<address-extra
v-if="addressExtra.visible"
v-model="user.addressExtra"
:required="addressExtra.required"
/>
</div>

<div v-if="city.visible || regionCode.visible" class="row">
<city
v-if="city.visible"
v-model="user.city"
:required="city.required"
:class-name="regionCode.visible ? 'col-md-4' : 'col-md-6'"
/>
<region
v-if="regionCode.visible"
v-model="user.regionCode"
:country-code="user.countryCode"
:required="regionCode.required"
:class-name="city.visible ? 'col-md-4' : 'col-md-6'"
/>
<postal-code
v-if="regionCode.visible"
v-model="user.postalCode"
:required="postalCode.required"
:class-name="city.visible ? 'col-md-4' : 'col-md-6'"
/>
</div>
</fieldset>
</template>

<script>
import City from './fields/city.vue';
import Region from './fields/region.vue';
import PostalCode from './fields/postal-code.vue';
import Street from './fields/street.vue';
import AddressExtra from './fields/address-extra.vue';
export default {
components: {
City,
Region,
PostalCode,
Street,
AddressExtra,
},
props: {
user: {
type: Object,
required: true,
},
street: {
type: Object,
required: true,
},
addressExtra: {
type: Object,
required: true,
},
city: {
type: Object,
required: true,
},
regionCode: {
type: Object,
required: true,
},
postalCode: {
type: Object,
required: true,
},
},
computed: {
classNames() {
const classNames = ['form-group'];
const { className } = this;
if (className) classNames.push(className);
return classNames;
},
countryCode() {
const { user } = this;
if (!user) return null;
return user.countryCode;
},
},
};
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<template>
<form-group class-name="col-md-4">
<form-label :for="id" :required="required">
{{ label }}
</form-label>
<input
:id="id"
v-model="addressExtra"
class="form-control"
type="text"
:required="required"
:disabled="disabled"
:placeholder="placeholder"
autocomplete="address-extra"
>
</form-group>
</template>

<script>
import FormGroup from '../common/form-group.vue';
import FormLabel from '../common/form-label.vue';
export default {
components: {
FormGroup,
FormLabel,
},
props: {
disabled: {
type: Boolean,
default: false,
},
required: {
type: Boolean,
default: false,
},
label: {
type: String,
default: 'Extra (Apt, Suite, etc.)',
},
placeholder: {
type: String,
default: '',
},
value: {
type: String,
default: '',
},
},
data: () => ({
id: 'sign-on-address-extra',
}),
computed: {
addressExtra: {
get() {
return this.value || '';
},
set(addressExtra) {
this.$emit('input', addressExtra || null);
},
},
},
};
</script>
68 changes: 68 additions & 0 deletions packages/marko-web-identity-x/browser/form/fields/city.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<template>
<form-group :class-name="className">
<form-label :for="id" :required="required">
{{ label }}
</form-label>
<input
:id="id"
v-model="city"
class="form-control"
type="text"
:required="required"
:disabled="disabled"
:placeholder="placeholder"
autocomplete="city"
>
</form-group>
</template>

<script>
import FormGroup from '../common/form-group.vue';
import FormLabel from '../common/form-label.vue';
export default {
components: {
FormGroup,
FormLabel,
},
props: {
disabled: {
type: Boolean,
default: false,
},
required: {
type: Boolean,
default: false,
},
label: {
type: String,
default: 'City',
},
placeholder: {
type: String,
default: '',
},
value: {
type: String,
default: '',
},
className: {
type: String,
default: 'col-md-6',
},
},
data: () => ({
id: 'sign-on-city',
}),
computed: {
city: {
get() {
return this.value || '';
},
set(city) {
this.$emit('input', city || null);
},
},
},
};
</script>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<form-group>
<form-group :class-name="className">
<form-label :for="id" :required="required">
{{ label }}
</form-label>
Expand Down Expand Up @@ -46,6 +46,10 @@ export default {
type: String,
default: '',
},
className: {
type: String,
default: 'col-md-12',
},
},
data: () => ({
id: 'sign-on-postal-code',
Expand Down
6 changes: 5 additions & 1 deletion packages/marko-web-identity-x/browser/form/fields/region.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<form-group>
<form-group :class-name="className">
<form-label :for="id" :required="required">
{{ label }}
</form-label>
Expand Down Expand Up @@ -57,6 +57,10 @@ export default {
type: String,
default: '',
},
className: {
type: String,
default: 'col-md-6',
},
},
data: () => ({
id: 'sign-on-region',
Expand Down
68 changes: 68 additions & 0 deletions packages/marko-web-identity-x/browser/form/fields/street.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<template>
<form-group :class-name="className">
<form-label :for="id" :required="required">
{{ label }}
</form-label>
<input
:id="id"
v-model="street"
class="form-control"
type="text"
:required="required"
:disabled="disabled"
:placeholder="placeholder"
autocomplete="street"
>
</form-group>
</template>

<script>
import FormGroup from '../common/form-group.vue';
import FormLabel from '../common/form-label.vue';
export default {
components: {
FormGroup,
FormLabel,
},
props: {
disabled: {
type: Boolean,
default: false,
},
required: {
type: Boolean,
default: false,
},
label: {
type: String,
default: 'Street',
},
placeholder: {
type: String,
default: '',
},
value: {
type: String,
default: '',
},
className: {
type: String,
default: 'col-md-12',
},
},
data: () => ({
id: 'sign-on-street',
}),
computed: {
street: {
get() {
return this.value || '';
},
set(street) {
this.$emit('input', street || null);
},
},
},
};
</script>
Loading

0 comments on commit 5f4e86b

Please sign in to comment.