@@ -64,6 +65,7 @@ import Modal from 'ChillMainAssets/vuejs/_components/Modal.vue';
import OnTheFlyCreate from './OnTheFly/Create.vue';
import OnTheFlyPerson from 'ChillPersonAssets/vuejs/_components/OnTheFly/Person.vue';
import OnTheFlyThirdparty from 'ChillThirdPartyAssets/vuejs/_components/OnTheFly/ThirdParty.vue';
+import { postPerson } from "ChillPersonAssets/vuejs/_api/OnTheFly";
export default {
name: 'OnTheFly',
@@ -142,22 +144,54 @@ export default {
this.$data.action = action;
},
saveAction() {
- console.log('saveAction for create/edit action');
+ console.log('saveAction button: create/edit action with', this.type);
- // edit person
- if (this.type === 'person') {
- this.$refs.castPerson.postData();
+ let
+ type = this.type,
+ 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') {
- this.$refs.castThirdparty.postData();
+
+ // 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 new person/thirdparty
- else {
- this.$refs.castNew.createAction();
- // saveAction() =====> child.createAction()
+
+ // 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;
+
},
goToLocation(id, type){
if(type == 'person'){
diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/OnTheFly/Create.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/OnTheFly/Create.vue
index c536a5df3..b207760e9 100644
--- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/OnTheFly/Create.vue
+++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/OnTheFly/Create.vue
@@ -66,20 +66,16 @@ export default {
isActive(tab) {
return (this.type === tab) ? true : false;
},
- createAction() {
- console.log('createAction before fetch');
-
- if (this.type === 'person') {
- 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') {
- console.log('not yet implemented', type);
+ castDataByType() {
+ switch (this.radioType) {
+ case 'person':
+ return this.$refs.castPerson.$data.person;
+ //break;
+ case 'thirdparty':
+ return this.$refs.castThirdparty.$data.thirdparty;
+ //break;
+ default:
+ throw 'error with entity';
}
}
}
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons.vue
index 782c68654..d2e56c852 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons.vue
@@ -228,7 +228,7 @@ export default {
this.suggested.unshift(this.priorSuggestion);
this.selected.unshift(this.priorSuggestion);
- console.log('reset onthefly');
+ console.log('reset priorSuggestion');
this.$store.commit('newPriorSuggestion', null);
}
}
diff --git a/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue b/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue
index b8dced534..19f81c01c 100644
--- a/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue
+++ b/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue
@@ -6,7 +6,7 @@
{{ action }}
- thirdparty
+ thirdparty
{{ id }}
@@ -16,7 +16,6 @@ export default {
name: "OnTheFlyThirdParty",
props: ['id', 'type', 'action']
}
-// TODO move in ChillThirdpartyAssets