mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 21:34:25 +00:00
replace store by data() for OnTheFly creation in AddPersons component
This commit is contained in:
parent
ccb302ad28
commit
34df295801
@ -70,12 +70,10 @@ export default {
|
|||||||
switch (this.radioType) {
|
switch (this.radioType) {
|
||||||
case 'person':
|
case 'person':
|
||||||
return this.$refs.castPerson.$data.person;
|
return this.$refs.castPerson.$data.person;
|
||||||
//break;
|
|
||||||
case 'thirdparty':
|
case 'thirdparty':
|
||||||
return this.$refs.castThirdparty.$data.thirdparty;
|
return this.$refs.castThirdparty.$data.thirdparty;
|
||||||
//break;
|
|
||||||
default:
|
default:
|
||||||
throw 'error with entity';
|
throw Error('Invalid type of entity')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,6 @@ let initPromise = getAccompanyingCourse(id)
|
|||||||
state: {
|
state: {
|
||||||
accompanyingCourse: accompanying_course,
|
accompanyingCourse: accompanying_course,
|
||||||
addressContext: {},
|
addressContext: {},
|
||||||
priorSuggestion: {},
|
|
||||||
errorMsg: []
|
errorMsg: []
|
||||||
},
|
},
|
||||||
getters: {
|
getters: {
|
||||||
@ -48,25 +47,9 @@ let initPromise = getAccompanyingCourse(id)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
},
|
|
||||||
hasPriorSuggestion(state, getters) {
|
|
||||||
return state.priorSuggestion.key ? true : false;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mutations: {
|
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) {
|
catchError(state, error) {
|
||||||
console.log('### mutation: a new error have been catched and pushed in store !', error);
|
console.log('### mutation: a new error have been catched and pushed in store !', error);
|
||||||
state.errorMsg.push(error);
|
state.errorMsg.push(error);
|
||||||
|
@ -92,7 +92,6 @@ import OnTheFly from 'ChillMainAssets/vuejs/_components/OnTheFly.vue';
|
|||||||
import PersonSuggestion from './AddPersons/PersonSuggestion';
|
import PersonSuggestion from './AddPersons/PersonSuggestion';
|
||||||
import { searchPersons, searchPersons_2 } from 'ChillPersonAssets/vuejs/_api/AddPersons';
|
import { searchPersons, searchPersons_2 } from 'ChillPersonAssets/vuejs/_api/AddPersons';
|
||||||
import { postPerson } from "ChillPersonAssets/vuejs/_api/OnTheFly";
|
import { postPerson } from "ChillPersonAssets/vuejs/_api/OnTheFly";
|
||||||
import {mapGetters, mapState} from "vuex";
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'AddPersons',
|
name: 'AddPersons',
|
||||||
@ -116,13 +115,12 @@ export default {
|
|||||||
search: {
|
search: {
|
||||||
query: "",
|
query: "",
|
||||||
suggested: [],
|
suggested: [],
|
||||||
selected: []
|
selected: [],
|
||||||
|
priorSuggestion: {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(['priorSuggestion']),
|
|
||||||
...mapGetters(['hasPriorSuggestion']),
|
|
||||||
query: {
|
query: {
|
||||||
set(query) {
|
set(query) {
|
||||||
return this.setQuery(query);
|
return this.setQuery(query);
|
||||||
@ -173,6 +171,12 @@ export default {
|
|||||||
return 'radio';
|
return 'radio';
|
||||||
}
|
}
|
||||||
return 'checkbox';
|
return 'checkbox';
|
||||||
|
},
|
||||||
|
priorSuggestion() {
|
||||||
|
return this.search.priorSuggestion;
|
||||||
|
},
|
||||||
|
hasPriorSuggestion() {
|
||||||
|
return this.search.priorSuggestion.key ? true : false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@ -225,13 +229,28 @@ export default {
|
|||||||
return item.result.type + item.result.id;
|
return item.result.type + item.result.id;
|
||||||
},
|
},
|
||||||
addPriorSuggestion() {
|
addPriorSuggestion() {
|
||||||
|
console.log('echo', this.hasPriorSuggestion);
|
||||||
if (this.hasPriorSuggestion) {
|
if (this.hasPriorSuggestion) {
|
||||||
console.log('addPriorSuggestion',);
|
console.log('addPriorSuggestion',);
|
||||||
this.suggested.unshift(this.priorSuggestion);
|
this.suggested.unshift(this.priorSuggestion);
|
||||||
this.selected.unshift(this.priorSuggestion);
|
this.selected.unshift(this.priorSuggestion);
|
||||||
|
|
||||||
console.log('reset 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 }) {
|
saveFormOnTheFly({ type, data }) {
|
||||||
@ -243,8 +262,8 @@ export default {
|
|||||||
console.log('type person with', data);
|
console.log('type person with', data);
|
||||||
postPerson(data)
|
postPerson(data)
|
||||||
.then(person => new Promise((resolve, reject) => {
|
.then(person => new Promise((resolve, reject) => {
|
||||||
this.person = person;
|
//this.person = person;
|
||||||
this.$store.commit('newPriorSuggestion', person);
|
this.newPriorSuggestion(person);
|
||||||
resolve();
|
resolve();
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user