mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 05:44:24 +00:00
move postPerson fetch method from children to onthefly first level (to squash)
This commit is contained in:
parent
25f43bc758
commit
a0fd3cd481
@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
<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'">
|
||||||
@ -64,6 +65,7 @@ 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',
|
||||||
@ -142,22 +144,54 @@ export default {
|
|||||||
this.$data.action = action;
|
this.$data.action = action;
|
||||||
},
|
},
|
||||||
saveAction() {
|
saveAction() {
|
||||||
console.log('saveAction for create/edit action');
|
console.log('saveAction button: create/edit action with', this.type);
|
||||||
|
|
||||||
// edit person
|
let
|
||||||
if (this.type === 'person') {
|
type = this.type,
|
||||||
this.$refs.castPerson.postData();
|
data = {} ;
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case 'person':
|
||||||
|
data = this.$refs.castPerson.$data.person;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'thirdparty':
|
||||||
|
data = this.$refs.castThirdparty.$data.thirdparty;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
if (typeof this.type === 'undefined') {
|
||||||
|
type = this.$refs.castNew.radioType;
|
||||||
|
data = this.$refs.castNew.castDataByType();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
throw 'error with object type';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// edit thirdparty
|
|
||||||
else if (this.type === 'thirdparty') {
|
// create/edit person
|
||||||
this.$refs.castThirdparty.postData();
|
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 new person/thirdparty
|
|
||||||
else {
|
// create/edit thirdparty
|
||||||
this.$refs.castNew.createAction();
|
else if (type === 'thirdparty') {
|
||||||
// saveAction() =====> child.createAction()
|
|
||||||
|
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'){
|
||||||
|
@ -66,20 +66,16 @@ export default {
|
|||||||
isActive(tab) {
|
isActive(tab) {
|
||||||
return (this.type === tab) ? true : false;
|
return (this.type === tab) ? true : false;
|
||||||
},
|
},
|
||||||
createAction() {
|
castDataByType() {
|
||||||
console.log('createAction before fetch');
|
switch (this.radioType) {
|
||||||
|
case 'person':
|
||||||
if (this.type === 'person') {
|
return this.$refs.castPerson.$data.person;
|
||||||
console.log('create person with', this.$refs.castPerson.$data.person);
|
//break;
|
||||||
postPerson(this.$refs.castPerson.$data.person)
|
case 'thirdparty':
|
||||||
.then(person => new Promise((resolve, reject) => {
|
return this.$refs.castThirdparty.$data.thirdparty;
|
||||||
this.person = person;
|
//break;
|
||||||
this.$store.commit('newPriorSuggestion', person);
|
default:
|
||||||
resolve();
|
throw 'error with entity';
|
||||||
}));
|
|
||||||
|
|
||||||
} else if (this.type === 'thirdparty') {
|
|
||||||
console.log('not yet implemented', type);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -228,7 +228,7 @@ export default {
|
|||||||
this.suggested.unshift(this.priorSuggestion);
|
this.suggested.unshift(this.priorSuggestion);
|
||||||
this.selected.unshift(this.priorSuggestion);
|
this.selected.unshift(this.priorSuggestion);
|
||||||
|
|
||||||
console.log('reset onthefly');
|
console.log('reset priorSuggestion');
|
||||||
this.$store.commit('newPriorSuggestion', null);
|
this.$store.commit('newPriorSuggestion', null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div v-else-if="action === 'edit' || action === 'create'">
|
<div v-else-if="action === 'edit' || action === 'create'">
|
||||||
{{ action }}
|
{{ action }}
|
||||||
thirdparty
|
thirdparty
|
||||||
{{ id }}
|
{{ id }}
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -16,7 +16,6 @@ export default {
|
|||||||
name: "OnTheFlyThirdParty",
|
name: "OnTheFlyThirdParty",
|
||||||
props: ['id', 'type', 'action']
|
props: ['id', 'type', 'action']
|
||||||
}
|
}
|
||||||
// TODO move in ChillThirdpartyAssets
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="css" scoped>
|
<style lang="css" scoped>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user