Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions core/components/blocks/MyAccount/MyProfile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,21 @@ export default {
password: '',
rPassword: '',
addCompany: false,
isEdited: false
isEdited: false,
remainInEditMode: false
}
},
created () {
this.$bus.$on('user-after-loggedin', this.onLoggedIn)
this.$bus.$on('myAccount-before-remainInEditMode', block => {
if (block === 'MyProfile') {
this.remainInEditMode = true
}
})
},
destroyed () {
this.$bus.$off('user-after-loggedin', this.onLoggedIn)
this.$bus.$off('myAccount-before-remainInEditMode')
},
mounted () {
this.userCompany = this.getUserCompany()
Expand Down Expand Up @@ -84,7 +91,10 @@ export default {
!this.objectsEqual(this.userCompany, this.getUserCompany()) ||
(this.userCompany.company && !this.addCompany)
) {
updatedProfile = this.$store.state.user.current
updatedProfile = JSON.parse(JSON.stringify(this.$store.state.user.current))
updatedProfile.firstname = this.currentUser.firstname
updatedProfile.lastname = this.currentUser.lastname
updatedProfile.email = this.currentUser.email
if (updatedProfile.hasOwnProperty('default_billing')) {
let index
for (let i = 0; i < updatedProfile.addresses.length; i++) {
Expand Down Expand Up @@ -154,8 +164,11 @@ export default {
if (!this.userCompany.company) {
this.addCompany = false
}
this.remainInEditMode = false
}
if (!this.remainInEditMode) {
this.isEdited = false
}
this.isEdited = false
},
getUserCompany () {
if (this.currentUser.hasOwnProperty('default_billing')) {
Expand Down
16 changes: 13 additions & 3 deletions core/components/blocks/MyAccount/MyShippingDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,21 @@ export default {
countries: Countries,
useCompanyAddress: false,
currentUser: Object.assign({}, this.$store.state.user.current),
isEdited: false
isEdited: false,
remainInEditMode: false
}
},
created () {
this.$bus.$on('user-after-loggedin', this.onLoggedIn)
this.$bus.$on('myAccount-before-remainInEditMode', block => {
if (block === 'MyShippingDetails') {
this.remainInEditMode = true
}
})
},
destroyed () {
this.$bus.$off('user-after-loggedin', this.onLoggedIn)
this.$bus.$off('myAccount-before-remainInEditMode')
},
mounted () {
this.shippingDetails = this.getShippingDetails()
Expand Down Expand Up @@ -72,7 +79,7 @@ export default {
updateDetails () {
let updatedShippingDetails
if (!this.objectsEqual(this.shippingDetails, this.getShippingDetails())) {
updatedShippingDetails = this.$store.state.user.current
updatedShippingDetails = JSON.parse(JSON.stringify(this.$store.state.user.current))
if (this.currentUser.hasOwnProperty('default_shipping')) {
let index
for (let i = 0; i < this.currentUser.addresses.length; i++) {
Expand Down Expand Up @@ -115,8 +122,11 @@ export default {
if (!updatedShippingDetails) {
this.shippingDetails = this.getShippingDetails()
this.useCompanyAddress = false
this.remainInEditMode = false
}
if (!this.remainInEditMode) {
this.isEdited = false
}
this.isEdited = false
},
fillCompanyAddress () {
this.useCompanyAddress = !this.useCompanyAddress
Expand Down
10 changes: 8 additions & 2 deletions core/pages/MyAccount.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ export default {
},
data () {
return {
navigation: []
navigation: [],
returnEditMode: false
}
},
created () {
Expand Down Expand Up @@ -72,7 +73,12 @@ export default {
},
onBeforeUpdateUser (updatedData) {
if (updatedData) {
this.$store.dispatch('user/update', { customer: updatedData })
try {
this.$store.dispatch('user/update', { customer: updatedData })
} catch (err) {
this.$bus.$emit('myAccount-before-remainInEditMode', this.$props.activeBlock)
console.error(err)
}
}
},
notify (title) {
Expand Down
1 change: 0 additions & 1 deletion core/store/modules/user/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ export default {
const validate = ajv.compile(require('./userProfile.schema.json'))

if (!validate(userData)) { // schema validation of user profile data
console.error(validate.errors)
EventBus.$emit('notification', {
type: 'error',
message: i18n.t('Internal validation error. Please check if all required fields are filled in. Please contact us on contributors@vuestorefront.io'),
Expand Down
1 change: 1 addition & 0 deletions src/themes/default/components/core/Notification.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<div
class="py10 px20 pointer weight-400 uppercase"
@click="action(notification.action2.action, index)"
v-if="notification.action2"
>
{{ notification.action2.label }}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@
v-for="country in countries"
:key="country.code"
:value="country.code"
class="cl-black"
>
{{ country.name }}
</option>
Expand Down Expand Up @@ -375,7 +376,7 @@ export default {
},
postcode: {
required,
minLength: minLength(3)
minLength: minLength(5)
},
city: {
required
Expand Down
Loading