Skip to content

Commit

Permalink
Merge pull request #44 from inshopgroup/user-form-password
Browse files Browse the repository at this point in the history
add form password
  • Loading branch information
inshop authored Jan 21, 2021
2 parents 0f8d01a + 8e1c303 commit 5f4c67e
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 9 deletions.
56 changes: 56 additions & 0 deletions src/components/form/FormPassword.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<template>
<v-text-field
:value="item[property]"
:append-icon="show ? 'mdi-eye' : 'mdi-eye-off'"
:type="show ? 'text' : 'password'"
:error-messages="$t(error)"
:placeholder="placeholder"
dense
:label="$t(label)"
outlined
autocomplete="new-password"
@click:append="show = !show"
@input="$emit('formUpdated', property, $event)"
>
</v-text-field>
</template>

<script>
export default {
name: 'FormPassword',
props: {
item: {
type: Object,
required: true,
},
property: {
type: String,
required: true,
},
label: {
type: String,
default: null,
},
placeholder: {
type: String,
default: null,
},
errors: {
type: Object,
default: () => ({}),
},
},
data() {
return {
show: false,
}
},
computed: {
error() {
return Object.keys(this.errors).length > 0
? this.errors[this.property]
: ''
},
},
}
</script>
20 changes: 11 additions & 9 deletions src/pages/user/Form.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,37 +60,39 @@
import { mapActions, mapGetters } from 'vuex'
import ItemEditActions from '../../components/layout/ItemEditActions'
import ItemErrors from '../../components/layout/errors/ItemErrors'
import FormPassword from '../../components/form/FormPassword'
export default {
components: {
ItemErrors,
ItemEditActions
ItemEditActions,
FormPassword,
},
props: {
handleSubmit: {
type: Function,
required: true
required: true,
},
item: {
type: Object,
required: true
}
required: true,
},
},
computed: {
...mapGetters({
errors: 'user/errors'
})
errors: 'user/errors',
}),
},
beforeDestroy() {
this.reset()
},
methods: {
...mapActions({
reset: 'user/reset'
reset: 'user/reset',
}),
updateValue(property, value) {
this.$store.commit('user/USER_UPDATE_ITEM', { [property]: value })
}
}
},
},
}
</script>

0 comments on commit 5f4c67e

Please sign in to comment.