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 b207760e9..3ffb3f7df 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/OnTheFly/Create.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/OnTheFly/Create.vue @@ -70,12 +70,10 @@ export default { 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'; + throw Error('Invalid type of entity') } } } diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/store/index.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/store/index.js index fa168ba9b..34a6786fc 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/store/index.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/store/index.js @@ -22,7 +22,6 @@ let initPromise = getAccompanyingCourse(id) state: { accompanyingCourse: accompanying_course, addressContext: {}, - priorSuggestion: {}, errorMsg: [] }, getters: { @@ -48,25 +47,9 @@ let initPromise = getAccompanyingCourse(id) return true; } return false; - }, - hasPriorSuggestion(state, getters) { - return state.priorSuggestion.key ? true : false; } }, mutations: { - newPriorSuggestion(state, entity) { - console.log('### mutation newPriorSuggestion', entity); - if (entity !== null) { - let suggestion = { - key: entity.type + entity.id, - relevance: 0.5, - result: entity - } - state.priorSuggestion = suggestion; - } else { - state.priorSuggestion = {}; - } - }, catchError(state, error) { console.log('### mutation: a new error have been catched and pushed in store !', error); state.errorMsg.push(error); diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons.vue index 4f836edc4..160d5d00b 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons.vue @@ -92,7 +92,6 @@ 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 {mapGetters, mapState} from "vuex"; export default { name: 'AddPersons', @@ -116,13 +115,12 @@ export default { search: { query: "", suggested: [], - selected: [] + selected: [], + priorSuggestion: {} } } }, computed: { - ...mapState(['priorSuggestion']), - ...mapGetters(['hasPriorSuggestion']), query: { set(query) { return this.setQuery(query); @@ -173,6 +171,12 @@ export default { return 'radio'; } return 'checkbox'; + }, + priorSuggestion() { + return this.search.priorSuggestion; + }, + hasPriorSuggestion() { + return this.search.priorSuggestion.key ? true : false; } }, methods: { @@ -225,13 +229,28 @@ export default { return item.result.type + item.result.id; }, addPriorSuggestion() { + console.log('echo', this.hasPriorSuggestion); if (this.hasPriorSuggestion) { console.log('addPriorSuggestion',); this.suggested.unshift(this.priorSuggestion); this.selected.unshift(this.priorSuggestion); console.log('reset priorSuggestion'); - this.$store.commit('newPriorSuggestion', null); + this.newPriorSuggestion(null); + } + }, + newPriorSuggestion(entity) { + console.log('newPriorSuggestion', entity); + if (entity !== null) { + let suggestion = { + key: entity.type + entity.id, + relevance: 0.5, + result: entity + } + this.search.priorSuggestion = suggestion; + console.log('ici', this.search.priorSuggestion); + } else { + this.search.priorSuggestion = {}; } }, saveFormOnTheFly({ type, data }) { @@ -243,8 +262,8 @@ export default { console.log('type person with', data); postPerson(data) .then(person => new Promise((resolve, reject) => { - this.person = person; - this.$store.commit('newPriorSuggestion', person); + //this.person = person; + this.newPriorSuggestion(person); resolve(); })); }