otf: patch person and thirdparty from the store, emit parent method saveFormOnTheFly()

This commit is contained in:
2021-09-29 17:35:37 +02:00
parent 9420c34f58
commit 008a10dab8
7 changed files with 103 additions and 47 deletions

View File

@@ -92,6 +92,7 @@ import OnTheFly from 'ChillMainAssets/vuejs/_components/OnTheFly.vue';
import PersonSuggestion from './AddPersons/PersonSuggestion';
import { searchPersons, searchPersons_2 } from 'ChillPersonAssets/vuejs/_api/AddPersons';
import { postPerson } from "ChillPersonAssets/vuejs/_api/OnTheFly";
import { postThirdparty } from "ChillThirdPartyAssets/vuejs/_api/OnTheFly";
export default {
name: 'AddPersons',
@@ -254,25 +255,25 @@ export default {
}
},
saveFormOnTheFly({ type, data }) {
console.log('saveFormOnTheFly from addPersons', { type, data });
// create/edit person
console.log('saveFormOnTheFly from addPersons, type', type, ', data', data);
if (type === 'person') {
console.log('type person with', data);
postPerson(data)
.then(person => new Promise((resolve, reject) => {
//this.person = person;
console.log('onthefly create: post person', person);
this.newPriorSuggestion(person);
resolve();
}));
}
// create/edit thirdparty
else if (type === 'thirdparty') {
console.log('not yet implemented: type thirdparty with', type, data);
console.log('type thirdparty with', data);
postThirdparty(data)
.then(thirdparty => new Promise((resolve, reject) => {
console.log('onthefly create: post thirdparty', thirdparty);
this.newPriorSuggestion(thirdparty);
resolve();
}));
}
}
},
}