mirror of
				https://gitlab.com/Chill-Projet/chill-bundles.git
				synced 2025-10-31 09:18:24 +00:00 
			
		
		
		
	move postPerson fetch method from children to onthefly first level (to squash)
This commit is contained in:
		| @@ -14,6 +14,7 @@ | ||||
|  | ||||
|          <template v-slot:header> | ||||
|             <h3 class="modal-title">{{ $t(titleModal) }}</h3> | ||||
|             type: {{type}} | ||||
|          </template> | ||||
|  | ||||
|          <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 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'){ | ||||
|   | ||||
| @@ -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'; | ||||
|          } | ||||
|       } | ||||
|    } | ||||
|   | ||||
| @@ -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); | ||||
|          } | ||||
|       } | ||||
|   | ||||
| @@ -6,7 +6,7 @@ | ||||
|    </div> | ||||
|    <div v-else-if="action === 'edit' || action === 'create'"> | ||||
|       {{ action }} | ||||
|       thirdparty  | ||||
|       thirdparty | ||||
|       {{ id }} | ||||
|    </div> | ||||
| </template> | ||||
| @@ -16,7 +16,6 @@ export default { | ||||
|    name: "OnTheFlyThirdParty", | ||||
|    props: ['id', 'type', 'action'] | ||||
| } | ||||
| // TODO move in ChillThirdpartyAssets | ||||
| </script> | ||||
|  | ||||
| <style lang="css" scoped> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user