Skip to content

Commit

Permalink
feat: code refactor and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Amirah Chamble authored and Amirah Chamble committed Dec 10, 2018
1 parent 4dd39cd commit aa6bcba
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions src/components/FishTankTextInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
v-bind="$attrs"
class="ft-input-text__input"
@input="updateValue "
@click="removeError"
v-on="listeners">
</template>
<p
Expand Down Expand Up @@ -119,11 +120,6 @@ export default Vue.extend({
type: String,
default: ""
},
valueChange: {
required: false,
type: Boolean,
default: false
},
label: {
required: false,
type: String,
Expand Down Expand Up @@ -166,7 +162,7 @@ export default Vue.extend({
error: {
required: false,
default: null,
type: String,//[String, Object],
type: [String, Object],
validator(value: string | { fullMessage? : string }) : boolean {
if (typeof value === 'string') {
return true
Expand Down Expand Up @@ -200,8 +196,6 @@ export default Vue.extend({
errorMessage(): string | undefined {
if (!(this as any).error) {
return undefined
}else if ((this as any).error && this.$props.valueChange){
return undefined
}
if (typeof (this as any).error === "string") {
Expand All @@ -221,14 +215,15 @@ export default Vue.extend({
}
}
},
},
methods: {
updateValue(value: string | undefined) {
this.$emit("input", value)
this.$props.valueChange = true;
this.$emit("input", value)
},
removeError(){
this.$props.error = undefined
},
clearText() {
this.updateValue(undefined)
this.focusElement(this.$refs.input as HTMLInputElement)
Expand Down

0 comments on commit aa6bcba

Please sign in to comment.