mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 13:24:25 +00:00
move postPerson fetch method from grant-children to children (to squash)
This commit is contained in:
parent
e369e43b00
commit
25f43bc758
@ -142,15 +142,20 @@ export default {
|
|||||||
this.$data.action = action;
|
this.$data.action = action;
|
||||||
},
|
},
|
||||||
saveAction() {
|
saveAction() {
|
||||||
console.log('saveAction');
|
console.log('saveAction for create/edit action');
|
||||||
|
|
||||||
|
// edit person
|
||||||
if (this.type === 'person') {
|
if (this.type === 'person') {
|
||||||
this.$refs.castPerson.postData();
|
this.$refs.castPerson.postData();
|
||||||
} else if (this.type === 'thirdparty') {
|
}
|
||||||
|
// edit thirdparty
|
||||||
|
else if (this.type === 'thirdparty') {
|
||||||
this.$refs.castThirdparty.postData();
|
this.$refs.castThirdparty.postData();
|
||||||
} else {
|
}
|
||||||
// => save new person created
|
// create new person/thirdparty
|
||||||
// saveAction() ==cast=to==> child.castByType() ==cast=to==> grand-child.postData()
|
else {
|
||||||
this.$refs.castNew.castByType();
|
this.$refs.castNew.createAction();
|
||||||
|
// saveAction() =====> child.createAction()
|
||||||
}
|
}
|
||||||
this.modal.showModal = false;
|
this.modal.showModal = false;
|
||||||
},
|
},
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<template>
|
<template>
|
||||||
<ul class="nav nav-tabs">
|
<ul class="nav nav-tabs">
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" :class="{ active: isActive('person') }">
|
<a class="nav-link" :class="{ active: isActive('person') }">
|
||||||
@ -17,29 +17,32 @@
|
|||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<div class="my-4">
|
<div class="my-4">
|
||||||
<on-the-fly-person
|
<on-the-fly-person
|
||||||
v-if="type === 'person'"
|
v-if="type === 'person'"
|
||||||
v-bind:action="action"
|
v-bind:action="action"
|
||||||
ref="castPerson">
|
ref="castPerson"
|
||||||
|
>
|
||||||
</on-the-fly-person>
|
</on-the-fly-person>
|
||||||
|
|
||||||
<on-the-fly-thirdparty
|
<on-the-fly-thirdparty
|
||||||
v-if="type === 'thirdparty'"
|
v-if="type === 'thirdparty'"
|
||||||
v-bind:action="action"
|
v-bind:action="action"
|
||||||
ref="castThirdparty">
|
ref="castThirdparty"
|
||||||
|
>
|
||||||
</on-the-fly-thirdparty>
|
</on-the-fly-thirdparty>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
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: "OnTheFlyCreate",
|
name: "OnTheFlyCreate",
|
||||||
props: ['action'],
|
props: ['action'],
|
||||||
components: {
|
components: {
|
||||||
OnTheFlyPerson,
|
OnTheFlyPerson,
|
||||||
OnTheFlyThirdparty
|
OnTheFlyThirdparty
|
||||||
@ -61,16 +64,22 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
isActive(tab) {
|
isActive(tab) {
|
||||||
return (this.type === tab) ? true : false;
|
return (this.type === tab) ? true : false;
|
||||||
},
|
},
|
||||||
castByType() {
|
createAction() {
|
||||||
console.log('saveActionByType');
|
console.log('createAction before fetch');
|
||||||
|
|
||||||
if (this.type === 'person') {
|
if (this.type === 'person') {
|
||||||
this.$refs.castPerson.postData();
|
console.log('create person with', this.$refs.castPerson.$data.person);
|
||||||
|
postPerson(this.$refs.castPerson.$data.person)
|
||||||
|
.then(person => new Promise((resolve, reject) => {
|
||||||
|
this.person = person;
|
||||||
|
this.$store.commit('newPriorSuggestion', person);
|
||||||
|
resolve();
|
||||||
|
}));
|
||||||
|
|
||||||
} else if (this.type === 'thirdparty') {
|
} else if (this.type === 'thirdparty') {
|
||||||
this.$refs.castThirdparty.postData();
|
console.log('not yet implemented', type);
|
||||||
} else {
|
|
||||||
throw Error('Invalid type of entity');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,6 +80,7 @@ import PersonRenderBox from '../Entity/PersonRenderBox.vue';
|
|||||||
export default {
|
export default {
|
||||||
name: "OnTheFlyPerson",
|
name: "OnTheFlyPerson",
|
||||||
props: ['id', 'type', 'action'],
|
props: ['id', 'type', 'action'],
|
||||||
|
//emits: ['createAction'],
|
||||||
components: {
|
components: {
|
||||||
PersonRenderBox
|
PersonRenderBox
|
||||||
},
|
},
|
||||||
@ -160,15 +161,6 @@ export default {
|
|||||||
//console.log('get person', this.person);
|
//console.log('get person', this.person);
|
||||||
resolve();
|
resolve();
|
||||||
}));
|
}));
|
||||||
},
|
|
||||||
postData() {
|
|
||||||
console.log('postdata before fetch', this.person);
|
|
||||||
postPerson(this.person)
|
|
||||||
.then(person => new Promise((resolve, reject) => {
|
|
||||||
this.person = person;
|
|
||||||
this.$store.commit('newPriorSuggestion', person);
|
|
||||||
resolve();
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user