Skip to content

Commit

Permalink
Standard form validation mixin
Browse files Browse the repository at this point in the history
  • Loading branch information
usp-npe committed Apr 21, 2022
1 parent 7f155f8 commit d171180
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 50 deletions.
5 changes: 2 additions & 3 deletions resources/js/components/accounting/SupplierForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,9 @@
</template>

<script>
import formValidationMixin from "@/mixins/formValidationMixin";
export default {
mixins: [formValidationMixin],
props: {
supplier: {
type: Object,
Expand Down Expand Up @@ -403,9 +405,6 @@ export default {
}
},
methods: {
getValidationState ({ dirty, validated, valid = null }) {
return dirty || validated ? valid : null;
},
onSubmit () {
this.$emit('submit', this.form)
},
Expand Down
5 changes: 2 additions & 3 deletions resources/js/components/accounting/WalletForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@

<script>
import rolesApi from '@/api/user_management/roles'
import formValidationMixin from "@/mixins/formValidationMixin";
export default {
mixins: [formValidationMixin],
props: {
wallet: {
type: Object,
Expand All @@ -118,9 +120,6 @@ export default {
this.fetchRoles()
},
methods: {
getValidationState ({ dirty, validated, valid = null }) {
return dirty || validated ? valid : null;
},
onSubmit () {
this.$emit('submit', this.form)
},
Expand Down
5 changes: 2 additions & 3 deletions resources/js/components/fundraising/DonorForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,9 @@
<script>
import commonApi from '@/api/common'
import donorsApi from '@/api/fundraising/donors'
import formValidationMixin from "@/mixins/formValidationMixin";
export default {
mixins: [formValidationMixin],
props: {
donor: {
type: Object,
Expand Down Expand Up @@ -364,9 +366,6 @@ export default {
let data = await commonApi.listLanguages()
this.languages = Object.values(data)
},
getValidationState ({ dirty, validated, valid = null }) {
return dirty || validated ? valid : null;
},
onSubmit () {
this.$emit('submit', this.form)
},
Expand Down
5 changes: 2 additions & 3 deletions resources/js/components/userprofile/ChangePasswordDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@
<script>
import userprofileApi from "@/api/userprofile"
import { showSnackbar } from '@/utils'
import formValidationMixin from "@/mixins/formValidationMixin";
export default {
mixins: [formValidationMixin],
data() {
return {
old_password: '',
Expand Down Expand Up @@ -123,9 +125,6 @@ export default {
}
this.isBusy = false
},
getValidationState ({ dirty, validated, valid = null }) {
return dirty || validated ? valid : null;
},
}
}
</script>
5 changes: 2 additions & 3 deletions resources/js/components/userprofile/UserProfileDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@
import userprofileApi from "@/api/userprofile"
import { showSnackbar } from '@/utils'
import moment from 'moment'
import formValidationMixin from "@/mixins/formValidationMixin";
export default {
mixins: [formValidationMixin],
props: {
user: {
required: true,
Expand Down Expand Up @@ -143,9 +145,6 @@ export default {
}
this.isBusy = false
},
getValidationState ({ dirty, validated, valid = null }) {
return dirty || validated ? valid : null;
},
}
}
</script>
4 changes: 2 additions & 2 deletions resources/js/components/visitors/VisitorForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,12 @@
</template>

<script>
import formInputMixin from "@/mixins/formInputMixin";
import formValidationMixin from "@/mixins/formValidationMixin";
import { mapState } from "vuex";
import moment from "moment";
import DateOfBirthInput from "@/components/common/DateOfBirthInput";
export default {
mixins: [formValidationMixin],
components: {
DateOfBirthInput,
},
Expand All @@ -163,7 +164,6 @@ export default {
},
disabled: Boolean,
},
mixins: [formInputMixin],
data() {
const search = this.$route.query.search;
const searchType = this.detectValueType(search);
Expand Down
27 changes: 0 additions & 27 deletions resources/js/mixins/formInputMixin.js

This file was deleted.

7 changes: 7 additions & 0 deletions resources/js/mixins/formValidationMixin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default {
methods: {
getValidationState ({ dirty, validated, valid = null }) {
return dirty || validated ? valid : null;
},
}
}
5 changes: 2 additions & 3 deletions resources/js/pages/fundraising/DonationsImportPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@
<script>
import donationsApi from '@/api/fundraising/donations'
import { showSnackbar } from '@/utils'
import formValidationMixin from "@/mixins/formValidationMixin";
export default {
mixins: [formValidationMixin],
title() {
return this.$t("Import");
},
Expand All @@ -75,9 +77,6 @@ export default {
}
},
methods: {
getValidationState ({ dirty, validated, valid = null }) {
return dirty || validated ? valid : null;
},
async onSubmit () {
this.isBusy = true
try {
Expand Down
5 changes: 2 additions & 3 deletions resources/js/pages/users/UserProfile2FAPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@
import AlertWithRetry from '@/components/alerts/AlertWithRetry'
import userprofileApi from "@/api/userprofile";
import { showSnackbar } from '@/utils'
import formValidationMixin from "@/mixins/formValidationMixin";
export default {
mixins: [formValidationMixin],
components: {
AlertWithRetry,
},
Expand Down Expand Up @@ -189,9 +191,6 @@ export default {
}
this.isBusy = false
},
getValidationState ({ dirty, validated, valid = null }) {
return dirty || validated ? valid : null;
},
}
}
</script>

0 comments on commit d171180

Please sign in to comment.