mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 23:23:51 +00:00
Merge branch 'master' of gitlab.com:Chill-Projet/chill-bundles
This commit is contained in:
@@ -1,374 +0,0 @@
|
||||
import { createStore } from 'vuex';
|
||||
import { householdMove, fetchHouseholdSuggestionByAccompanyingPeriod, fetchAddressSuggestionByPerson} from './../api.js';
|
||||
import { datetimeToISO } from 'ChillMainAssets/chill/js/date.js';
|
||||
|
||||
const debug = process.env.NODE_ENV !== 'production';
|
||||
|
||||
const concerned = window.household_members_editor_data.persons.map(p => {
|
||||
return {
|
||||
person: p,
|
||||
position: null,
|
||||
allowRemove: false,
|
||||
holder: false,
|
||||
comment: "",
|
||||
};
|
||||
});
|
||||
|
||||
console.log('expand suggestions', window.household_members_editor_expand_suggestions === 1);
|
||||
|
||||
const store = createStore({
|
||||
strict: debug,
|
||||
state: {
|
||||
concerned,
|
||||
household: window.household_members_editor_data.household,
|
||||
positions: window.household_members_editor_data.positions.sort((a, b) => {
|
||||
if (a.ordering < b.ordering) {
|
||||
return -1;
|
||||
}
|
||||
if (a.ordering > b.ordering) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}),
|
||||
startDate: new Date(),
|
||||
allowHouseholdCreate: window.household_members_editor_data.allowHouseholdCreate,
|
||||
allowHouseholdSearch: window.household_members_editor_data.allowHouseholdSearch,
|
||||
allowLeaveWithoutHousehold: window.household_members_editor_data.allowLeaveWithoutHousehold,
|
||||
forceLeaveWithoutHousehold: false,
|
||||
householdSuggestionByAccompanyingPeriod: [],
|
||||
showHouseholdSuggestion: window.household_members_editor_expand_suggestions === 1,
|
||||
addressesSuggestion: [],
|
||||
warnings: [],
|
||||
errors: []
|
||||
},
|
||||
getters: {
|
||||
isHouseholdNew(state) {
|
||||
if (state.household === null) {
|
||||
return false;
|
||||
}
|
||||
return !Number.isInteger(state.household.id);
|
||||
},
|
||||
hasHousehold(state) {
|
||||
return state.household !== null;
|
||||
},
|
||||
hasHouseholdOrLeave(state) {
|
||||
return state.household !== null || state.forceLeaveWithoutHousehold;
|
||||
},
|
||||
hasHouseholdSuggestion(state, getters) {
|
||||
return getters.filterHouseholdSuggestionByAccompanyingPeriod.length > 0;
|
||||
},
|
||||
countHouseholdSuggestion(state, getters) {
|
||||
return getters.filterHouseholdSuggestionByAccompanyingPeriod.length;
|
||||
},
|
||||
filterHouseholdSuggestionByAccompanyingPeriod(state) {
|
||||
if (state.household === null) {
|
||||
return state.householdSuggestionByAccompanyingPeriod;
|
||||
}
|
||||
|
||||
return state.householdSuggestionByAccompanyingPeriod
|
||||
.filter(h => h.id !== state.household.id)
|
||||
;
|
||||
},
|
||||
hasPersonsWellPositionnated(state, getters) {
|
||||
return getters.needsPositionning === false
|
||||
|| (getters.persons.length > 0 && getters.concUnpositionned.length === 0);
|
||||
},
|
||||
persons(state) {
|
||||
return state.concerned.map(conc => conc.person);
|
||||
},
|
||||
concUnpositionned(state) {
|
||||
return state.concerned
|
||||
.filter(conc => conc.position === null)
|
||||
;
|
||||
},
|
||||
positions(state) {
|
||||
return state.positions;
|
||||
},
|
||||
personByPosition: (state) => (position_id) => {
|
||||
return state.concerned
|
||||
.filter(conc =>
|
||||
conc.position !== null ? conc.position.id === position_id : false
|
||||
)
|
||||
.map(conc => conc.person)
|
||||
;
|
||||
},
|
||||
concByPosition: (state) => (position_id) => {
|
||||
return state.concerned
|
||||
.filter(conc =>
|
||||
conc.position !== null ? conc.position.id === position_id : false
|
||||
)
|
||||
;
|
||||
},
|
||||
concByPersonId: (state) => (person_id) => {
|
||||
return state.concerned
|
||||
.find(conc => conc.person.id === person_id)
|
||||
;
|
||||
},
|
||||
needsPositionning(state) {
|
||||
return state.forceLeaveWithoutHousehold === false;
|
||||
},
|
||||
buildPayload: (state) => {
|
||||
let
|
||||
conc,
|
||||
payload_conc,
|
||||
payload = {
|
||||
concerned: [],
|
||||
destination: null
|
||||
}
|
||||
;
|
||||
|
||||
if (state.forceLeaveWithoutHousehold === false) {
|
||||
payload.destination = {
|
||||
id: state.household.id,
|
||||
type: state.household.type
|
||||
};
|
||||
}
|
||||
|
||||
for (let i in state.concerned) {
|
||||
conc = state.concerned[i];
|
||||
payload_conc = {
|
||||
person: {
|
||||
id: conc.person.id,
|
||||
type: conc.person.type
|
||||
},
|
||||
start_date: {
|
||||
datetime: datetimeToISO(state.startDate)
|
||||
}
|
||||
};
|
||||
|
||||
if (state.forceLeaveWithoutHousehold === false) {
|
||||
payload_conc.position = {
|
||||
id: conc.position.id,
|
||||
type: conc.position.type
|
||||
};
|
||||
payload_conc.holder = conc.holder;
|
||||
payload_conc.comment = conc.comment;
|
||||
}
|
||||
|
||||
payload.concerned.push(payload_conc);
|
||||
}
|
||||
|
||||
return payload;
|
||||
},
|
||||
},
|
||||
mutations: {
|
||||
addConcerned(state, person) {
|
||||
let persons = state.concerned.map(conc => conc.person.id);
|
||||
if (!persons.includes(person.id)) {
|
||||
state.concerned.push({
|
||||
person,
|
||||
position: null,
|
||||
allowRemove: true,
|
||||
holder: false,
|
||||
comment: "",
|
||||
});
|
||||
} else {
|
||||
console.err("person already included");
|
||||
}
|
||||
},
|
||||
markPosition(state, { person_id, position_id}) {
|
||||
let
|
||||
position = state.positions.find(pos => pos.id === position_id),
|
||||
conc = state.concerned.find(c => c.person.id === person_id);
|
||||
conc.position = position;
|
||||
},
|
||||
setComment(state, {conc, comment}) {
|
||||
conc.comment = comment;
|
||||
},
|
||||
toggleHolder(state, conc) {
|
||||
conc.holder = !conc.holder;
|
||||
},
|
||||
removePosition(state, conc) {
|
||||
conc.holder = false;
|
||||
conc.position = null;
|
||||
},
|
||||
removeConcerned(state, conc) {
|
||||
state.concerned = state.concerned.filter(c =>
|
||||
c.person.id !== conc.person.id
|
||||
)
|
||||
},
|
||||
createHousehold(state) {
|
||||
state.household = { type: 'household', members: [], current_address: null,
|
||||
current_members_id: [] };
|
||||
state.forceLeaveWithoutHousehold = false;
|
||||
},
|
||||
removeHousehold(state) {
|
||||
state.household = null;
|
||||
state.forceLeaveWithoutHousehold = false;
|
||||
},
|
||||
setHouseholdAddress(state, address) {
|
||||
if (null === state.household) {
|
||||
console.error("no household");
|
||||
throw new Error("No household");
|
||||
}
|
||||
|
||||
state.household.current_address = address;
|
||||
state.household.force_new_address = address;
|
||||
},
|
||||
forceLeaveWithoutHousehold(state) {
|
||||
state.household = null;
|
||||
state.forceLeaveWithoutHousehold = true;
|
||||
},
|
||||
selectHousehold(state, household) {
|
||||
state.household = household;
|
||||
state.forceLeaveWithoutHousehold = false;
|
||||
},
|
||||
setHouseholdSuggestionByAccompanyingPeriod(state, households) {
|
||||
let existingIds = state.householdSuggestionByAccompanyingPeriod
|
||||
.map(h => h.id);
|
||||
for (let i in households) {
|
||||
if (!existingIds.includes(households[i].id)) {
|
||||
state.householdSuggestionByAccompanyingPeriod.push(households[i]);
|
||||
}
|
||||
}
|
||||
},
|
||||
setStartDate(state, dateI) {
|
||||
state.startDate = dateI;
|
||||
},
|
||||
toggleHouseholdSuggestion(state) {
|
||||
state.showHouseholdSuggestion = !state.showHouseholdSuggestion;
|
||||
},
|
||||
setWarnings(state, warnings) {
|
||||
state.warnings = warnings;
|
||||
// reset errors, which should come from servers
|
||||
state.errors.splice(0, state.errors.length);
|
||||
},
|
||||
setErrors(state, errors) {
|
||||
state.errors = errors;
|
||||
},
|
||||
addAddressesSuggestion(state, addresses) {
|
||||
let existingIds = state.addressesSuggestion
|
||||
.map(a => a.id);
|
||||
|
||||
for (let i in addresses) {
|
||||
if (!existingIds.includes(addresses[i].id)) {
|
||||
state.addressesSuggestion.push(addresses[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
addConcerned({ commit, dispatch }, person) {
|
||||
commit('addConcerned', person);
|
||||
dispatch('computeWarnings');
|
||||
dispatch('fetchAddressSuggestions');
|
||||
},
|
||||
markPosition({ commit, state, dispatch }, { person_id, position_id }) {
|
||||
commit('markPosition', { person_id, position_id });
|
||||
dispatch('computeWarnings');
|
||||
},
|
||||
toggleHolder({ commit, dispatch }, conc) {
|
||||
commit('toggleHolder', conc);
|
||||
dispatch('computeWarnings');
|
||||
},
|
||||
removePosition({ commit, dispatch }, conc) {
|
||||
commit('removePosition', conc);
|
||||
dispatch('computeWarnings');
|
||||
},
|
||||
removeConcerned({ commit, dispatch }, conc) {
|
||||
commit('removeConcerned', conc);
|
||||
dispatch('computeWarnings');
|
||||
dispatch('fetchAddressSuggestions');
|
||||
},
|
||||
removeHousehold({ commit, dispatch }) {
|
||||
commit('removeHousehold');
|
||||
dispatch('computeWarnings');
|
||||
},
|
||||
createHousehold({ commit, dispatch }) {
|
||||
commit('createHousehold');
|
||||
dispatch('computeWarnings');
|
||||
},
|
||||
forceLeaveWithoutHousehold({ commit, dispatch }) {
|
||||
commit('forceLeaveWithoutHousehold');
|
||||
dispatch('computeWarnings');
|
||||
},
|
||||
selectHousehold({ commit }, h) {
|
||||
commit('selectHousehold', h);
|
||||
dispatch('computeWarnings');
|
||||
},
|
||||
setStartDate({ commit, dispatch }, date) {
|
||||
commit('setStartDate', date);
|
||||
dispatch('computeWarnings');
|
||||
},
|
||||
setComment({ commit }, payload) {
|
||||
commit('setComment', payload);
|
||||
},
|
||||
fetchHouseholdSuggestionForConcerned({ commit, state }, person) {
|
||||
fetchHouseholdSuggestionByAccompanyingPeriod(person.id)
|
||||
.then(households => {
|
||||
commit('setHouseholdSuggestionByAccompanyingPeriod', households);
|
||||
});
|
||||
},
|
||||
fetchAddressSuggestions({ commit, state }) {
|
||||
for (let i in state.concerned) {
|
||||
fetchAddressSuggestionByPerson(state.concerned[i].person.id)
|
||||
.then(addresses => {
|
||||
commit('addAddressesSuggestion', addresses);
|
||||
})
|
||||
.catch(e => {
|
||||
console.log(e);
|
||||
});
|
||||
}
|
||||
},
|
||||
computeWarnings({ commit, state, getters }) {
|
||||
let warnings = [],
|
||||
payload;
|
||||
|
||||
if (!getters.hasHousehold && !state.forceLeaveWithoutHousehold) {
|
||||
warnings.push({ m: 'household_members_editor.add_destination', a: {} });
|
||||
}
|
||||
|
||||
if (state.concerned.length === 0) {
|
||||
warnings.push({ m: 'household_members_editor.add_at_least_onePerson', a: {} });
|
||||
}
|
||||
|
||||
if (getters.concUnpositionned.length > 0
|
||||
&& !state.forceLeaveWithoutHousehold) {
|
||||
warnings.push({ m: 'household_members_editor.give_a_position_to_every_person', a: {} })
|
||||
}
|
||||
|
||||
commit('setWarnings', warnings);
|
||||
},
|
||||
confirm({ getters, state, commit }) {
|
||||
let payload = getters.buildPayload,
|
||||
errors = [],
|
||||
person_id,
|
||||
household_id,
|
||||
error
|
||||
;
|
||||
|
||||
householdMove(payload).then(household => {
|
||||
if (household === null) {
|
||||
person_id = getters.persons[0].id;
|
||||
window.location.replace(`/fr/person/${person_id}/general`);
|
||||
} else {
|
||||
if (household.type === 'household') {
|
||||
household_id = household.id;
|
||||
// nothing to do anymore here, bye-bye !
|
||||
window.location.replace(`/fr/person/household/${household_id}/summary`);
|
||||
} else {
|
||||
// we assume the answer was 422...
|
||||
error = household;
|
||||
for (let i in error.violations) {
|
||||
let e = error.violations[i];
|
||||
errors.push(e.title);
|
||||
}
|
||||
|
||||
commit('setErrors', errors);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
store.dispatch('computeWarnings');
|
||||
store.dispatch('fetchAddressSuggestions');
|
||||
|
||||
if (concerned.length > 0) {
|
||||
concerned.forEach(c => {
|
||||
store.dispatch('fetchHouseholdSuggestionForConcerned', c.person);
|
||||
});
|
||||
}
|
||||
|
||||
export { store };
|
@@ -68,12 +68,15 @@
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<ul class="record_actions">
|
||||
<ul class="record_actions" v-if="availableForCheckGoal.length > 0">
|
||||
<li>
|
||||
<button :title="$t('add_an_objective')" class="btn btn-create"
|
||||
@click="toggleAddObjective"></button>
|
||||
</li>
|
||||
</ul>
|
||||
<div v-else>
|
||||
<span class="chill-no-data-statement">{{ $t('no_goals_available') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div><!-- empty for results --></div>
|
||||
</div>
|
||||
@@ -102,11 +105,14 @@
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<ul class="record_actions">
|
||||
<ul class="record_actions" v-if="evaluationsForAction.length > 0">
|
||||
<li>
|
||||
<button :title="$t('add_an_evaluation')" class="btn btn-create" @click="toggleAddEvaluation"></button>
|
||||
</li>
|
||||
</ul>
|
||||
<div v-else>
|
||||
<span class="chill-no-data-statement">{{ $t('no_evaluations_available') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -255,6 +261,8 @@ const i18n = {
|
||||
choose_thirdparties: "Choisir des tiers",
|
||||
fix_these_errors: "Veuillez corriger les erreurs suivantes :",
|
||||
available_evaluations_text: "Évaluations disponibles pour ajout :",
|
||||
no_evaluations_available: "Aucune évaluation disponible",
|
||||
no_goals_available: "Aucun objectif disponible",
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -378,7 +386,6 @@ export default {
|
||||
this.$store.commit('removeGoal', g);
|
||||
},
|
||||
addEvaluation(e) {
|
||||
console.log('add Evaluation', e);
|
||||
this.$store.commit('addEvaluation', e);
|
||||
},
|
||||
toggleAddEvaluation() {
|
||||
|
@@ -19,8 +19,20 @@
|
||||
<dt v-if="evaluation.warningInterval">{{ $t('warningInterval') }} :</dt>
|
||||
<dd v-if="evaluation.warningInterval">{{ evaluation.warningInterval }}</dd>
|
||||
|
||||
<dt v-if="evaluation.documents && evaluation.documents.length > 0">{{ $t('documents') }} :</dt>
|
||||
<dd v-if="evaluation.documents && evaluation.documents.length > 0">{{ evaluation.documents.length }}</dd>
|
||||
<template v-if="evaluation.documents.length > 0">
|
||||
<dt>{{ $t('documents') }} :</dt>
|
||||
<dd>
|
||||
<ul>
|
||||
<li v-for="d in evaluation.documents">
|
||||
{{ d.template.name.fr }}
|
||||
<a :href="buildEditLink(d.storedObject)" class="btn btn-action btn-sm">
|
||||
<i class="fa fa-edit"></i>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</dd>
|
||||
|
||||
</template>
|
||||
|
||||
</dl>
|
||||
<dl class="item-details">
|
||||
@@ -82,7 +94,7 @@ export default {
|
||||
computed: {
|
||||
pickedEvaluations() {
|
||||
return this.$store.state.evaluationsPicked;
|
||||
}
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
removeEvaluation(e) {
|
||||
@@ -95,7 +107,11 @@ export default {
|
||||
},
|
||||
submitForm() {
|
||||
this.toggleEditEvaluation();
|
||||
}
|
||||
},
|
||||
buildEditLink(storedObject) {
|
||||
return `/fr/chill_wopi/edit/${storedObject.filename}?returnPath=` + encodeURIComponent(
|
||||
window.location.pathname + window.location.search + window.location.hash);
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
@@ -67,19 +67,15 @@
|
||||
<div class="input-group">
|
||||
<select class="form-select form-select-sm" v-model="template">
|
||||
<option disabled value="">{{ $t('evaluation_choose_a_template') }}</option>
|
||||
<option>A</option>
|
||||
<template v-for="t in getTemplatesAvailaibleForEvaluation">
|
||||
<option v-bind:value="t.id">{{ t.name.fr }}</option>
|
||||
</template>
|
||||
</select>
|
||||
<button class="btn btn-update btn-sm change-icon" type="button"><i class="fa fa-fw fa-cog"></i></button>
|
||||
<button v-if="canGenerate" class="btn btn-update btn-sm change-icon" type="button" @click="generateDocument"><i class="fa fa-fw fa-cog"></i></button>
|
||||
<button v-else class="btn btn-update btn-sm change-icon" type="button" disabled ><i class="fa fa-fw fa-cog"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--div class="row mb-3">
|
||||
<label class="col-sm-4 col-form-label">{{ $t('evaluation_add_a_document') }}</label>
|
||||
<div class="col-sm-8">
|
||||
<button class="btn btn-create btn-sm" @click="documents"></button>
|
||||
</div>
|
||||
</div-->
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -88,6 +84,7 @@
|
||||
import {dateToISO, ISOToDate, ISOToDatetime} from 'ChillMainAssets/chill/js/date.js';
|
||||
import CKEditor from '@ckeditor/ckeditor5-vue';
|
||||
import ClassicEditor from 'ChillMainAssets/module/ckeditor5/index.js';
|
||||
import { mapGetters, mapState } from 'vuex';
|
||||
|
||||
const i18n = {
|
||||
messages: {
|
||||
@@ -119,25 +116,19 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
editor: ClassicEditor,
|
||||
//evaluation: {
|
||||
// status: null,
|
||||
// startDate: null,
|
||||
// endDate: null,
|
||||
// maxDate: null,
|
||||
// warningInterval: null,
|
||||
// comment: null,
|
||||
// template: null,
|
||||
// //documents: null
|
||||
//}
|
||||
template: null,
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
/*
|
||||
status: {
|
||||
get() { return this.evaluation.status; },
|
||||
set(v) { this.evaluation.status = v; }
|
||||
...mapGetters([
|
||||
'getTemplatesAvailaibleForEvaluation'
|
||||
]),
|
||||
...mapState([
|
||||
'isPosting'
|
||||
]),
|
||||
canGenerate() {
|
||||
return !this.$store.state.isPosting && this.template !== null;
|
||||
},
|
||||
*/
|
||||
startDate: {
|
||||
get() {
|
||||
return dateToISO(this.evaluation.startDate);
|
||||
@@ -171,10 +162,6 @@ export default {
|
||||
get() { return this.evaluation.comment; },
|
||||
set(v) { this.$store.commit('setEvaluationComment', { key: this.evaluation.key, comment: v }); }
|
||||
},
|
||||
template: {
|
||||
get() { return this.evaluation.template; },
|
||||
set(v) { this.evaluation.template = v; }
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
listAllStatus() {
|
||||
@@ -189,6 +176,10 @@ export default {
|
||||
})
|
||||
;
|
||||
},
|
||||
generateDocument() {
|
||||
console.log('template picked', this.template);
|
||||
this.$store.dispatch('generateDocument', { key: this.evaluation.key, templateId: this.template})
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
//this.listAllStatus();
|
||||
|
@@ -4,6 +4,7 @@ import { findSocialActionsBySocialIssue } from 'ChillPersonAssets/vuejs/_api/Soc
|
||||
import { create } from 'ChillPersonAssets/vuejs/_api/AccompanyingCourseWork.js';
|
||||
|
||||
const debug = process.env.NODE_ENV !== 'production';
|
||||
const evalFQDN = encodeURIComponent("Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWorkEvaluation");
|
||||
|
||||
const store = createStore({
|
||||
strict: debug,
|
||||
@@ -32,6 +33,7 @@ const store = createStore({
|
||||
return k;
|
||||
}),
|
||||
evaluationsForAction: [],
|
||||
templatesAvailableForEvaluation: [],
|
||||
personsPicked: window.accompanyingCourseWork.persons,
|
||||
personsReachables: window.accompanyingCourseWork.accompanyingPeriod.participations.filter(p => p.endDate == null)
|
||||
.map(p => p.person),
|
||||
@@ -63,6 +65,9 @@ const store = createStore({
|
||||
hasThirdParties(state) {
|
||||
return state.thirdParties.length > 0;
|
||||
},
|
||||
getTemplatesAvailaibleForEvaluation(state) {
|
||||
return state.templatesAvailableForEvaluation;
|
||||
},
|
||||
buildPayload(state) {
|
||||
return {
|
||||
type: 'accompanying_period_work',
|
||||
@@ -99,6 +104,7 @@ const store = createStore({
|
||||
accompanyingPeriodWorkEvaluations: state.evaluationsPicked.map(e => {
|
||||
let o = {
|
||||
type: e.type,
|
||||
key: e.key,
|
||||
evaluation: {
|
||||
id: e.evaluation.id,
|
||||
type: e.evaluation.type
|
||||
@@ -216,6 +222,11 @@ const store = createStore({
|
||||
let evaluation = state.evaluationsPicked.find(e => e.key === key);
|
||||
evaluation.editEvaluation = !evaluation.editEvaluation;
|
||||
},
|
||||
setTemplatesAvailableForEvaluation(state, templates) {
|
||||
for (let i in templates) {
|
||||
state.templatesAvailableForEvaluation.push(templates[i]);
|
||||
}
|
||||
},
|
||||
setPersonsPickedIds(state, ids) {
|
||||
state.personsPicked = state.personsReachables
|
||||
.filter(p => ids.includes(p.id))
|
||||
@@ -317,7 +328,38 @@ const store = createStore({
|
||||
commit('setEvaluationsForAction', data.results);
|
||||
});
|
||||
},
|
||||
submit({ getters, state, commit }) {
|
||||
getReachableTemplatesForEvaluation({commit}) {
|
||||
const
|
||||
url = `/fr/doc/gen/templates/for/${evalFQDN}`
|
||||
;
|
||||
window.fetch(url).then(r => {
|
||||
if (r.ok) {
|
||||
return r.json();
|
||||
}
|
||||
throw new Error("not possible to load templates for evaluations")
|
||||
}).then(data => {
|
||||
commit('setTemplatesAvailableForEvaluation', data.results);
|
||||
}).catch(e => {
|
||||
console.error(e);
|
||||
})
|
||||
},
|
||||
generateDocument({ dispatch }, {key, templateId}) {
|
||||
const callback = function(data) {
|
||||
// get the evaluation id from the data
|
||||
const
|
||||
evaluationId = data.accompanyingPeriodWorkEvaluations.find(e => e.key === key).id,
|
||||
returnPath = encodeURIComponent(window.location.pathname + window.location.search + window.location.hash),
|
||||
url = `/fr/doc/gen/generate/from/${templateId}/for/${evalFQDN}/${evaluationId}?returnPath=${returnPath}`
|
||||
;
|
||||
//http://localhost:8001/fr/doc/gen/generate/from/12/for/Chill%5CPersonBundle%5CEntity%5CAccompanyingPeriod%5CAccompanyingPeriodWorkEvaluation/41
|
||||
|
||||
console.log('I will generate your doc at', url);
|
||||
window.location.assign(url);
|
||||
};
|
||||
|
||||
dispatch('submit', callback);
|
||||
},
|
||||
submit({ getters, state, commit }, callback) {
|
||||
let
|
||||
payload = getters.buildPayload,
|
||||
url = `/api/1.0/person/accompanying-course/work/${state.work.id}.json`,
|
||||
@@ -345,6 +387,8 @@ const store = createStore({
|
||||
}
|
||||
commit('setErrors', errors);
|
||||
commit('setIsPosting', false);
|
||||
} else if (typeof(callback) !== 'undefined') {
|
||||
callback(data);
|
||||
} else {
|
||||
console.info('nothing to do here, bye bye');
|
||||
window.location.assign(`/fr/person/accompanying-period/${state.work.accompanyingPeriod.id}/work`);
|
||||
@@ -360,6 +404,7 @@ const store = createStore({
|
||||
dispatch('getReachablesResultsForAction');
|
||||
dispatch('getReachablesGoalsForAction');
|
||||
dispatch('getReachablesEvaluationsForAction');
|
||||
dispatch('getReachableTemplatesForEvaluation');
|
||||
},
|
||||
}
|
||||
});
|
||||
|
@@ -7,35 +7,43 @@
|
||||
</div>
|
||||
<div v-if="isHouseholdNew && !hasHouseholdAddress">
|
||||
|
||||
<h3>À quelle adresse habite ce ménage ?</h3>
|
||||
<h3 >À quelle adresse habite ce ménage ?</h3>
|
||||
|
||||
<ul v-if="filterAddressesSuggestion.length > 0">
|
||||
<li v-for="a in filterAddressesSuggestion">
|
||||
<show-address :address="a"></show-address>
|
||||
<button class="btn" @click="setHouseholdAddress(a)">
|
||||
<div v-if="filterAddressesSuggestion.length > 0" class="flex-table householdAddressSuggestionList">
|
||||
<div v-for="a in filterAddressesSuggestion" class="item-bloc">
|
||||
<show-address :address="a"></show-address>
|
||||
<button class="btn btn-action" @click="setHouseholdAddress(a)">
|
||||
Le ménage habite cette adresse
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else>
|
||||
<span class="chill-no-data-statement">Aucune adresse à suggérer</span>
|
||||
</div>
|
||||
|
||||
<ul class="record_actions">
|
||||
<li >
|
||||
<button class="btn">
|
||||
Créer une adresse
|
||||
</button>
|
||||
<add-address
|
||||
:context="addAddress.context"
|
||||
:key="addAddress.key"
|
||||
:options="addAddress.options"
|
||||
:result="addAddress.result"
|
||||
@submitAddress="setHouseholdCreatedAddress"
|
||||
ref="addAddress">
|
||||
</add-address>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
</div>
|
||||
<div v-if="isHouseholdNew && hasHouseholdAddress">
|
||||
<ul class="record_actions">
|
||||
<li >
|
||||
<button class="btn" @click="removeHouseholdAddress">
|
||||
<button class="btn btn-misc" @click="removeHouseholdAddress">
|
||||
Supprimer cette adresse
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div v-else-if="isForceLeaveWithoutHousehold">
|
||||
@@ -51,7 +59,7 @@
|
||||
class="btn btn-misc"
|
||||
@click="toggleHouseholdSuggestion"
|
||||
>
|
||||
{{ $tc('household_members_editor.show_household_suggestion',
|
||||
{{ $tc('household_members_editor.show_household_suggestion',
|
||||
countHouseholdSuggestion) }}
|
||||
</button>
|
||||
</li>
|
||||
@@ -106,11 +114,24 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</template>
|
||||
|
||||
<style lang="scss">
|
||||
|
||||
div.householdAddressSuggestionList {
|
||||
/*
|
||||
display: flex;
|
||||
list-style-type: none;
|
||||
padding: 0;
|
||||
|
||||
*/
|
||||
|
||||
& > li {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
.householdSuggestionList {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
@@ -136,12 +157,45 @@
|
||||
import { mapGetters, mapState } from 'vuex';
|
||||
import HouseholdViewer from 'ChillPersonAssets/vuejs/_components/Household/Household.vue';
|
||||
import ShowAddress from 'ChillMainAssets/vuejs/Address/components/ShowAddress.vue';
|
||||
import AddAddress from 'ChillMainAssets/vuejs/Address/components/AddAddress.vue';
|
||||
|
||||
export default {
|
||||
name: 'Household',
|
||||
components: {
|
||||
HouseholdViewer,
|
||||
ShowAddress,
|
||||
AddAddress,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
addAddress: {
|
||||
context: {
|
||||
entity: {
|
||||
type: 'household_create',
|
||||
id: 0
|
||||
},
|
||||
edit: false,
|
||||
addressId: null
|
||||
},
|
||||
key: 'household_new',
|
||||
options: {
|
||||
hideDateFrom: true,
|
||||
bindModal: {
|
||||
|
||||
},
|
||||
button: {
|
||||
text: {
|
||||
create: null,
|
||||
edit: null,
|
||||
}
|
||||
},
|
||||
title: {
|
||||
create: null,
|
||||
edit: null,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapGetters([
|
||||
@@ -172,13 +226,13 @@ export default {
|
||||
allowRemoveHousehold() {
|
||||
return this.$store.getters.hasHousehold &&
|
||||
(
|
||||
this.allowHouseholdCreate || this.allowHouseholdSearch ||
|
||||
this.allowHouseholdCreate || this.allowHouseholdSearch ||
|
||||
this.allowLeaveWithoutHousehold
|
||||
)
|
||||
;
|
||||
},
|
||||
allowChangeHousehold() {
|
||||
return this.allowHouseholdCreate || this.allowHouseholdSearch ||
|
||||
return this.allowHouseholdCreate || this.allowHouseholdSearch ||
|
||||
this.allowLeaveWithoutHousehold;
|
||||
},
|
||||
isForceLeaveWithoutHousehold() {
|
||||
@@ -202,8 +256,15 @@ export default {
|
||||
this.$store.dispatch('removeHousehold');
|
||||
},
|
||||
setHouseholdAddress(a) {
|
||||
let payload = this.$refs.addAddress.submitNewAddress();
|
||||
console.log('setHouseholdAddress', a);
|
||||
this.$store.commit('setHouseholdAddress', a);
|
||||
},
|
||||
setHouseholdCreatedAddress() {
|
||||
let payload = this.$refs.addAddress.submitNewAddress();
|
||||
console.log('setHouseholdAddress', payload);
|
||||
this.$store.dispatch('setHouseholdNewAddress', payload);
|
||||
},
|
||||
removeHouseholdAddress() {
|
||||
this.$store.commit('removeHouseholdAddress');
|
||||
}
|
||||
|
@@ -14,8 +14,6 @@ const concerned = window.household_members_editor_data.persons.map(p => {
|
||||
};
|
||||
});
|
||||
|
||||
console.log('expand suggestions', window.household_members_editor_expand_suggestions === 1);
|
||||
|
||||
const store = createStore({
|
||||
strict: debug,
|
||||
state: {
|
||||
@@ -211,7 +209,12 @@ const store = createStore({
|
||||
)
|
||||
},
|
||||
createHousehold(state) {
|
||||
state.household = { type: 'household', members: [], current_address: null, current_members_id: [] }
|
||||
state.household = {
|
||||
type: 'household',
|
||||
members: [],
|
||||
current_address: null,
|
||||
current_members_id: []
|
||||
};
|
||||
state.forceLeaveWithoutHousehold = false;
|
||||
},
|
||||
removeHousehold(state) {
|
||||
@@ -274,7 +277,7 @@ const store = createStore({
|
||||
state.addressesSuggestion.push(addresses[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
actions: {
|
||||
addConcerned({ commit, dispatch }, person) {
|
||||
@@ -307,6 +310,19 @@ const store = createStore({
|
||||
commit('createHousehold');
|
||||
dispatch('computeWarnings');
|
||||
},
|
||||
setHouseholdNewAddress({ commit }, payload) {
|
||||
let url = `/api/1.0/main/address/${payload.addressId}.json`;
|
||||
window.fetch(url).then(r => {
|
||||
if (r.ok) {
|
||||
return r.json();
|
||||
}
|
||||
throw new Error("error while fetch address");
|
||||
}).then(data => {
|
||||
commit('setHouseholdAddress', data);
|
||||
}).catch(e => {
|
||||
console.error(e);
|
||||
});
|
||||
},
|
||||
forceLeaveWithoutHousehold({ commit, dispatch }) {
|
||||
commit('forceLeaveWithoutHousehold');
|
||||
dispatch('computeWarnings');
|
||||
@@ -373,8 +389,14 @@ const store = createStore({
|
||||
} else {
|
||||
if (household.type === 'household') {
|
||||
household_id = household.id;
|
||||
|
||||
// nothing to do anymore here, bye-bye !
|
||||
window.location.replace(`/fr/person/household/${household_id}/summary`);
|
||||
let params = new URLSearchParams(window.location.search);
|
||||
if (params.has('returnPath')) {
|
||||
window.location.replace(params.get('returnPath'));
|
||||
} else {
|
||||
window.location.replace(`/fr/person/household/${household_id}/summary`);
|
||||
}
|
||||
} else {
|
||||
// we assume the answer was 422...
|
||||
error = household;
|
||||
|
@@ -10,7 +10,7 @@
|
||||
{{ $t('household_number', { number: household.id } ) }}
|
||||
</div>
|
||||
|
||||
<!-- member part -->
|
||||
<!-- member part -->
|
||||
<div v-if="hasCurrentMembers" class="members">
|
||||
<span class="current-members">{{ $t('current_members') }}: </span>
|
||||
<template v-for="(m, index) in currentMembers()" :key="m.id">
|
||||
@@ -40,7 +40,7 @@
|
||||
<style lang="scss">
|
||||
.chill-entity__household {
|
||||
display: grid;
|
||||
grid-template-areas:
|
||||
grid-template-areas:
|
||||
"identifier identifier where"
|
||||
"who who where"
|
||||
;
|
||||
@@ -50,7 +50,7 @@
|
||||
|
||||
.identifier {
|
||||
grid-area: identifier;
|
||||
|
||||
|
||||
font-size: 1.3em;
|
||||
font-weight: 700;
|
||||
color: var(--chill-blue);
|
||||
@@ -110,7 +110,7 @@ export default {
|
||||
return this.household.members.filter(m => this.household.current_members_id.includes(m.id))
|
||||
.sort((a, b) => {
|
||||
if (a.position.ordering < b.position.ordering) {
|
||||
return -1;
|
||||
return -1;
|
||||
}
|
||||
if (a.position.ordering > b.position.ordering) {
|
||||
return 1;
|
||||
|
Reference in New Issue
Block a user