mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 13:24:25 +00:00
move postPerson fetch method out of OnTheFly component for addPersons create person case
OnTheFly don't use store anymore, but addPerson still use it
This commit is contained in:
parent
a0fd3cd481
commit
ccb302ad28
@ -14,7 +14,6 @@
|
|||||||
|
|
||||||
<template v-slot:header>
|
<template v-slot:header>
|
||||||
<h3 class="modal-title">{{ $t(titleModal) }}</h3>
|
<h3 class="modal-title">{{ $t(titleModal) }}</h3>
|
||||||
type: {{type}}
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template v-slot:body v-if="type === 'person'">
|
<template v-slot:body v-if="type === 'person'">
|
||||||
@ -65,7 +64,6 @@ import Modal from 'ChillMainAssets/vuejs/_components/Modal.vue';
|
|||||||
import OnTheFlyCreate from './OnTheFly/Create.vue';
|
import OnTheFlyCreate from './OnTheFly/Create.vue';
|
||||||
import OnTheFlyPerson from 'ChillPersonAssets/vuejs/_components/OnTheFly/Person.vue';
|
import OnTheFlyPerson from 'ChillPersonAssets/vuejs/_components/OnTheFly/Person.vue';
|
||||||
import OnTheFlyThirdparty from 'ChillThirdPartyAssets/vuejs/_components/OnTheFly/ThirdParty.vue';
|
import OnTheFlyThirdparty from 'ChillThirdPartyAssets/vuejs/_components/OnTheFly/ThirdParty.vue';
|
||||||
import { postPerson } from "ChillPersonAssets/vuejs/_api/OnTheFly";
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'OnTheFly',
|
name: 'OnTheFly',
|
||||||
@ -76,6 +74,7 @@ export default {
|
|||||||
OnTheFlyCreate
|
OnTheFlyCreate
|
||||||
},
|
},
|
||||||
props: ['type', 'id', 'action', 'buttonText'],
|
props: ['type', 'id', 'action', 'buttonText'],
|
||||||
|
emits: ['saveFormOnTheFly'],
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
modal: {
|
modal: {
|
||||||
@ -169,29 +168,10 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// create/edit person
|
// pass datas to parent
|
||||||
if (type === 'person') {
|
this.$emit('saveFormOnTheFly', { type: type, data: data });
|
||||||
|
|
||||||
console.log('type person with', data);
|
|
||||||
postPerson(data)
|
|
||||||
.then(person => new Promise((resolve, reject) => {
|
|
||||||
this.person = person;
|
|
||||||
this.$store.commit('newPriorSuggestion', person);
|
|
||||||
resolve();
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
// create/edit thirdparty
|
|
||||||
else if (type === 'thirdparty') {
|
|
||||||
|
|
||||||
console.log('not yet implemented', type);
|
|
||||||
console.log('type thirdparty with', data);
|
|
||||||
// postThirdparty(data)
|
|
||||||
// .then(...)
|
|
||||||
}
|
|
||||||
|
|
||||||
this.modal.showModal = false;
|
this.modal.showModal = false;
|
||||||
|
|
||||||
},
|
},
|
||||||
goToLocation(id, type){
|
goToLocation(id, type){
|
||||||
if(type == 'person'){
|
if(type == 'person'){
|
||||||
|
@ -67,7 +67,8 @@
|
|||||||
<on-the-fly
|
<on-the-fly
|
||||||
v-if="query.length >= 3"
|
v-if="query.length >= 3"
|
||||||
v-bind:buttonText="$t('onthefly.create.button', {q: query})"
|
v-bind:buttonText="$t('onthefly.create.button', {q: query})"
|
||||||
action="create"><!-- TODO first close this modal -->
|
action="create"
|
||||||
|
@saveFormOnTheFly="saveFormOnTheFly">
|
||||||
</on-the-fly>
|
</on-the-fly>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -90,6 +91,7 @@ import Modal from 'ChillMainAssets/vuejs/_components/Modal';
|
|||||||
import OnTheFly from 'ChillMainAssets/vuejs/_components/OnTheFly.vue';
|
import OnTheFly from 'ChillMainAssets/vuejs/_components/OnTheFly.vue';
|
||||||
import PersonSuggestion from './AddPersons/PersonSuggestion';
|
import PersonSuggestion from './AddPersons/PersonSuggestion';
|
||||||
import { searchPersons, searchPersons_2 } from 'ChillPersonAssets/vuejs/_api/AddPersons';
|
import { searchPersons, searchPersons_2 } from 'ChillPersonAssets/vuejs/_api/AddPersons';
|
||||||
|
import { postPerson } from "ChillPersonAssets/vuejs/_api/OnTheFly";
|
||||||
import {mapGetters, mapState} from "vuex";
|
import {mapGetters, mapState} from "vuex";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@ -145,7 +147,7 @@ export default {
|
|||||||
return this.search.selected.length;
|
return this.search.selected.length;
|
||||||
},
|
},
|
||||||
selectedAndSuggested() {
|
selectedAndSuggested() {
|
||||||
this.checkPriorSuggestion();
|
this.addPriorSuggestion();
|
||||||
const uniqBy = (a, key) => [
|
const uniqBy = (a, key) => [
|
||||||
...new Map(
|
...new Map(
|
||||||
a.map(x => [key(x), x])
|
a.map(x => [key(x), x])
|
||||||
@ -222,15 +224,36 @@ export default {
|
|||||||
itemKey(item) {
|
itemKey(item) {
|
||||||
return item.result.type + item.result.id;
|
return item.result.type + item.result.id;
|
||||||
},
|
},
|
||||||
checkPriorSuggestion() {
|
addPriorSuggestion() {
|
||||||
if (this.hasPriorSuggestion) {
|
if (this.hasPriorSuggestion) {
|
||||||
console.log('checkPriorSuggestion',);
|
console.log('addPriorSuggestion',);
|
||||||
this.suggested.unshift(this.priorSuggestion);
|
this.suggested.unshift(this.priorSuggestion);
|
||||||
this.selected.unshift(this.priorSuggestion);
|
this.selected.unshift(this.priorSuggestion);
|
||||||
|
|
||||||
console.log('reset priorSuggestion');
|
console.log('reset priorSuggestion');
|
||||||
this.$store.commit('newPriorSuggestion', null);
|
this.$store.commit('newPriorSuggestion', null);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
saveFormOnTheFly({ type, data }) {
|
||||||
|
console.log('saveFormOnTheFly from addPersons', { type, data });
|
||||||
|
|
||||||
|
// create/edit person
|
||||||
|
if (type === 'person') {
|
||||||
|
|
||||||
|
console.log('type person with', data);
|
||||||
|
postPerson(data)
|
||||||
|
.then(person => new Promise((resolve, reject) => {
|
||||||
|
this.person = person;
|
||||||
|
this.$store.commit('newPriorSuggestion', person);
|
||||||
|
resolve();
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
// create/edit thirdparty
|
||||||
|
else if (type === 'thirdparty') {
|
||||||
|
console.log('not yet implemented: type thirdparty with', type, data);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user