Added code to enable / disable the Footer Button
This commit is contained in:
parent
040f3490e4
commit
31334370bb
1 changed files with 23 additions and 7 deletions
|
|
@ -32,7 +32,8 @@
|
||||||
ref="buttonMain"
|
ref="buttonMain"
|
||||||
suppressLoader
|
suppressLoader
|
||||||
:buttonText="footerButtonText"
|
:buttonText="footerButtonText"
|
||||||
@click-event="validateAndEmit" />
|
@click-event="validateAndEmit"
|
||||||
|
:class="isFooterButtonDisabled && 'form-test-invalid'" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -42,6 +43,7 @@
|
||||||
<script>
|
<script>
|
||||||
import buttonMain from "@/ux-components/button-main/button-main";
|
import buttonMain from "@/ux-components/button-main/button-main";
|
||||||
import { Modal } from "bootstrap";
|
import { Modal } from "bootstrap";
|
||||||
|
import { useIsFormTouched, useIsFormDirty, useIsFormValid } from "vee-validate";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "modal",
|
name: "modal",
|
||||||
|
|
@ -49,20 +51,26 @@ export default {
|
||||||
modalId: String,
|
modalId: String,
|
||||||
headerText: String,
|
headerText: String,
|
||||||
footerButtonText: String,
|
footerButtonText: String,
|
||||||
modalForm: {
|
|
||||||
type: Object,
|
|
||||||
},
|
|
||||||
onModalOpenedCallback: {
|
onModalOpenedCallback: {
|
||||||
type: Function,
|
type: Function,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
setup() {
|
||||||
|
const isTouched = useIsFormTouched();
|
||||||
|
const isDirty = useIsFormDirty();
|
||||||
|
const isValid = useIsFormValid();
|
||||||
|
|
||||||
|
return {
|
||||||
|
isTouched,
|
||||||
|
isDirty,
|
||||||
|
isValid,
|
||||||
|
};
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async validateAndEmit() {
|
async validateAndEmit() {
|
||||||
const validationResult = await this.modalForm.validate();
|
if (!this.isModalSubmitDisabled) {
|
||||||
if (validationResult.valid) {
|
|
||||||
this.$emit("footer-button-event");
|
this.$emit("footer-button-event");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.resetButtonStyle();
|
this.resetButtonStyle();
|
||||||
},
|
},
|
||||||
resetButtonStyle() {
|
resetButtonStyle() {
|
||||||
|
|
@ -77,6 +85,14 @@ export default {
|
||||||
modal.hide();
|
modal.hide();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
isFooterButtonDisabled() {
|
||||||
|
if (!this.isTouched) {
|
||||||
|
return !this.isValid;
|
||||||
|
}
|
||||||
|
return !this.isDirty || !this.isValid;
|
||||||
|
},
|
||||||
|
},
|
||||||
components: {
|
components: {
|
||||||
buttonMain,
|
buttonMain,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue