on-the-fly: close modal only after validation

This commit is contained in:
nobohan 2022-02-03 11:07:32 +01:00
parent 4afea55465
commit 1f0ef6e187
5 changed files with 18 additions and 37 deletions

View File

@ -90,7 +90,7 @@ export default {
OnTheFlyThirdparty,
OnTheFlyCreate
},
props: ['type', 'id', 'action', 'buttonText', 'displayBadge', 'isDead', 'parent', 'canCloseModal'],
props: ['type', 'id', 'action', 'buttonText', 'displayBadge', 'isDead', 'parent'],
emits: ['saveFormOnTheFly'],
data() {
return {
@ -162,16 +162,6 @@ export default {
return 'entity-' + this.type + ' badge-' + this.type;
}
},
watch: {
canCloseModal: {
handler: function(val, oldVal) {
if (val) {
this.closeModal();
}
},
deep: true
}
},
methods: {
closeModal() {
this.modal.showModal = false;

View File

@ -28,7 +28,7 @@
</a>
</li>
<li><on-the-fly :type="participation.person.type" :id="participation.person.id" action="show"></on-the-fly></li>
<li><on-the-fly :type="participation.person.type" :id="participation.person.id" action="edit" @saveFormOnTheFly="saveFormOnTheFly" :canCloseModal="canCloseOnTheFlyModal"></on-the-fly></li>
<li><on-the-fly :type="participation.person.type" :id="participation.person.id" action="edit" @saveFormOnTheFly="saveFormOnTheFly" ref="onTheFly"></on-the-fly></li>
<li>
<button v-if="!participation.endDate"
class="btn btn-sm btn-remove"
@ -90,7 +90,6 @@ export default {
hLevel: 1
}
},
canCloseOnTheFlyModal: false
}
},
computed: {
@ -126,8 +125,8 @@ export default {
makeFetch('PATCH', `/api/1.0/person/person/${payload.data.id}.json`, body)
.then(response => {
this.$store.dispatch('addPerson', { target: payload.target, body: response })
this.canCloseOnTheFlyModal = true;
this.$store.dispatch('addPerson', { target: payload.target, body: response });
this.$refs.onTheFly.closeModal();
})
.catch((error) => {
if (error.name === 'ValidationException') {
@ -148,7 +147,7 @@ export default {
makeFetch('PATCH', `/api/1.0/thirdparty/thirdparty/${payload.data.id}.json`, body)
.then(response => {
this.$store.dispatch('addThirdparty', { target: payload.target, body: response })
this.canCloseOnTheFlyModal = true;
this.$refs.onTheFly.closeModal();
})
.catch((error) => {
if (error.name === 'ValidationException') {

View File

@ -26,7 +26,7 @@
<template v-slot:record-actions>
<ul class="record_actions">
<li><on-the-fly :type="accompanyingCourse.requestor.type" :id="accompanyingCourse.requestor.id" action="show"></on-the-fly></li>
<li><on-the-fly :type="accompanyingCourse.requestor.type" :id="accompanyingCourse.requestor.id" action="edit" @saveFormOnTheFly="saveFormOnTheFly"></on-the-fly></li>
<li><on-the-fly :type="accompanyingCourse.requestor.type" :id="accompanyingCourse.requestor.id" action="edit" @saveFormOnTheFly="saveFormOnTheFly" ref="onTheFly"></on-the-fly></li>
</ul>
</template>
</third-party-render-box>
@ -52,7 +52,7 @@
<template v-slot:record-actions>
<ul class="record_actions">
<li><on-the-fly :type="accompanyingCourse.requestor.type" :id="accompanyingCourse.requestor.id" action="show"></on-the-fly></li>
<li><on-the-fly :type="accompanyingCourse.requestor.type" :id="accompanyingCourse.requestor.id" action="edit" @saveFormOnTheFly="saveFormOnTheFly"></on-the-fly></li>
<li><on-the-fly :type="accompanyingCourse.requestor.type" :id="accompanyingCourse.requestor.id" action="edit" @saveFormOnTheFly="saveFormOnTheFly" ref="onTheFly"></on-the-fly></li>
</ul>
</template>
</person-render-box>
@ -92,7 +92,7 @@
<template v-slot:record-actions>
<ul class="record_actions">
<li><on-the-fly :type="accompanyingCourse.requestor.type" :id="accompanyingCourse.requestor.id" action="show"></on-the-fly></li>
<li><on-the-fly :type="accompanyingCourse.requestor.type" :id="accompanyingCourse.requestor.id" action="edit" @saveFormOnTheFly="saveFormOnTheFly"></on-the-fly></li>
<li><on-the-fly :type="accompanyingCourse.requestor.type" :id="accompanyingCourse.requestor.id" action="edit" @saveFormOnTheFly="saveFormOnTheFly" ref="onTheFly"></on-the-fly></li>
</ul>
</template>
</third-party-render-box>
@ -114,7 +114,7 @@
<template v-slot:record-actions>
<ul class="record_actions">
<li><on-the-fly :type="accompanyingCourse.requestor.type" :id="accompanyingCourse.requestor.id" action="show"></on-the-fly></li>
<li><on-the-fly :type="accompanyingCourse.requestor.type" :id="accompanyingCourse.requestor.id" action="edit" @saveFormOnTheFly="saveFormOnTheFly" :canCloseModal="canCloseOnTheFlyModal"></on-the-fly></li>
<li><on-the-fly :type="accompanyingCourse.requestor.type" :id="accompanyingCourse.requestor.id" action="edit" @saveFormOnTheFly="saveFormOnTheFly" ref="onTheFly"></on-the-fly></li>
</ul>
</template>
</person-render-box>
@ -189,7 +189,6 @@ export default {
uniq: true,
}
},
canCloseOnTheFlyModal: false
}
},
computed: {
@ -268,7 +267,7 @@ export default {
makeFetch('PATCH', `/api/1.0/person/person/${payload.data.id}.json`, body)
.then(response => {
this.$store.dispatch('addPerson', { target: payload.target, body: response })
this.canCloseOnTheFlyModal = true;
this.$refs.onTheFly.closeModal();
})
.catch((error) => {
if (error.name === 'ValidationException') {
@ -289,7 +288,7 @@ export default {
makeFetch('PATCH', `/api/1.0/thirdparty/thirdparty/${payload.data.id}.json`, body)
.then(response => {
this.$store.dispatch('addThirdparty', { target: payload.target, body: response })
this.canCloseOnTheFlyModal = true;
this.$refs.onTheFly.closeModal();
})
.catch((error) => {
if (error.name === 'ValidationException') {

View File

@ -35,7 +35,7 @@
:id="resource.resource.id"
action="edit"
@saveFormOnTheFly="saveFormOnTheFly"
:canCloseModal="canCloseOnTheFlyModal">
ref="onTheFly">
</on-the-fly>
</li>
<li>
@ -82,7 +82,7 @@
:id="resource.resource.id"
action="edit"
@saveFormOnTheFly="saveFormOnTheFly"
:canCloseModal="canCloseOnTheFlyModal">
ref="onTheFly">
</on-the-fly>
</li>
<li>
@ -116,11 +116,6 @@ export default {
},
props: ['resource'],
emits: ['remove'],
data() {
return {
canCloseOnTheFlyModal: false
}
},
computed: {
parent() {
return {
@ -159,7 +154,7 @@ export default {
makeFetch('PATCH', `/api/1.0/person/person/${payload.data.id}.json`, body)
.then(response => {
this.$store.dispatch('addPerson', { target: payload.target, body: response })
this.canCloseOnTheFlyModal = true;
this.$refs.onTheFly.closeModal();
})
.catch((error) => {
if (error.name === 'ValidationException') {
@ -180,7 +175,7 @@ export default {
makeFetch('PATCH', `/api/1.0/thirdparty/thirdparty/${payload.data.id}.json`, body)
.then(response => {
this.$store.dispatch('addThirdparty', { target: payload.target, body: response })
this.canCloseOnTheFlyModal = true;
this.$refs.onTheFly.closeModal();
})
.catch((error) => {
if (error.name === 'ValidationException') {

View File

@ -69,7 +69,7 @@
:buttonText="$t('onthefly.create.button', {q: query})"
action="create"
@saveFormOnTheFly="saveFormOnTheFly"
:canCloseModal="canCloseOnTheFlyModal">
ref="onTheFly">
</on-the-fly>
</div>
@ -121,7 +121,6 @@ export default {
selected: [],
priorSuggestion: {}
},
canCloseOnTheFlyModal: false
}
},
computed: {
@ -271,7 +270,7 @@ export default {
makeFetch('POST', '/api/1.0/person/person.json', data)
.then(response => {
this.newPriorSuggestion(response);
this.canCloseOnTheFlyModal = true;
this.$refs.onTheFly.closeModal();
})
.catch((error) => {
if (error.name === 'ValidationException') {
@ -287,7 +286,7 @@ export default {
makeFetch('POST', '/api/1.0/thirdparty/thirdparty.json', data)
.then(response => {
this.newPriorSuggestion(response);
this.canCloseOnTheFlyModal = true;
this.$refs.onTheFly.closeModal();
})
.catch((error) => {
if (error.name === 'ValidationException') {
@ -299,7 +298,6 @@ export default {
}
})
}
this.canCloseOnTheFlyModal = false;
}
},
}