mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-10-07 13:59:43 +00:00
Apply prettier rules
This commit is contained in:
@@ -6,40 +6,25 @@
|
||||
class="breadcrumb-item"
|
||||
:class="{ active: step === s }"
|
||||
>
|
||||
{{ $t('household_members_editor.app.steps.'+s) }}
|
||||
{{ $t("household_members_editor.app.steps." + s) }}
|
||||
</li>
|
||||
</ol>
|
||||
<concerned v-if="step === 'concerned'" />
|
||||
<household
|
||||
v-if="step === 'household'"
|
||||
@ready-to-go="goToNext"
|
||||
/>
|
||||
<household v-if="step === 'household'" @ready-to-go="goToNext" />
|
||||
<household-address v-if="step === 'household_address'" />
|
||||
<positioning v-if="step === 'positioning'" />
|
||||
<dates v-if="step === 'confirm'" />
|
||||
<confirmation v-if="step === 'confirm'" />
|
||||
|
||||
<ul class="record_actions sticky-form-buttons">
|
||||
<li
|
||||
class="cancel"
|
||||
v-if="step !== 'concerned'"
|
||||
>
|
||||
<button
|
||||
class="btn btn-cancel"
|
||||
@click="goToPrevious"
|
||||
>
|
||||
{{ $t('household_members_editor.app.previous') }}
|
||||
<li class="cancel" v-if="step !== 'concerned'">
|
||||
<button class="btn btn-cancel" @click="goToPrevious">
|
||||
{{ $t("household_members_editor.app.previous") }}
|
||||
</button>
|
||||
</li>
|
||||
<li
|
||||
class="cancel"
|
||||
v-else-if="hasReturnPath"
|
||||
>
|
||||
<button
|
||||
class="btn btn-cancel"
|
||||
@click="goToPrevious"
|
||||
>
|
||||
{{ $t('household_members_editor.app.cancel') }}
|
||||
<li class="cancel" v-else-if="hasReturnPath">
|
||||
<button class="btn btn-cancel" @click="goToPrevious">
|
||||
{{ $t("household_members_editor.app.cancel") }}
|
||||
</button>
|
||||
</li>
|
||||
<li v-if="step !== 'confirm'">
|
||||
@@ -48,7 +33,9 @@
|
||||
@click="goToNext"
|
||||
:disabled="!isNextAllowed"
|
||||
>
|
||||
{{ $t('household_members_editor.app.next') }} <i class="fa fa-arrow-right" />
|
||||
{{ $t("household_members_editor.app.next") }} <i
|
||||
class="fa fa-arrow-right"
|
||||
/>
|
||||
</button>
|
||||
</li>
|
||||
<li v-else>
|
||||
@@ -57,24 +44,23 @@
|
||||
@click="confirm"
|
||||
:disabled="hasWarnings || !lastStepIsSaveAllowed"
|
||||
>
|
||||
{{ $t('household_members_editor.app.save') }}
|
||||
{{ $t("household_members_editor.app.save") }}
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
import {mapState} from 'vuex';
|
||||
import Concerned from './components/Concerned.vue';
|
||||
import Household from './components/Household.vue';
|
||||
import HouseholdAddress from './components/HouseholdAddress';
|
||||
import Dates from './components/Dates.vue';
|
||||
import Confirmation from './components/Confirmation.vue';
|
||||
import { mapState } from "vuex";
|
||||
import Concerned from "./components/Concerned.vue";
|
||||
import Household from "./components/Household.vue";
|
||||
import HouseholdAddress from "./components/HouseholdAddress";
|
||||
import Dates from "./components/Dates.vue";
|
||||
import Confirmation from "./components/Confirmation.vue";
|
||||
import Positioning from "./components/Positioning";
|
||||
|
||||
export default {
|
||||
name: 'App',
|
||||
name: "App",
|
||||
components: {
|
||||
Positioning,
|
||||
Concerned,
|
||||
@@ -85,88 +71,96 @@ export default {
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
step: 'concerned',
|
||||
step: "concerned",
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
...mapState({
|
||||
hasWarnings: (state) => state.warnings.length > 0 || state.errors.length > 0,
|
||||
hasWarnings: (state) =>
|
||||
state.warnings.length > 0 || state.errors.length > 0,
|
||||
}),
|
||||
steps() {
|
||||
let s = ['concerned', 'household'];
|
||||
let s = ["concerned", "household"];
|
||||
|
||||
if (this.$store.getters.isHouseholdNew) {
|
||||
s.push('household_address');
|
||||
s.push("household_address");
|
||||
}
|
||||
|
||||
if (!this.$store.getters.isModeLeave) {
|
||||
s.push('positioning');
|
||||
s.push("positioning");
|
||||
}
|
||||
|
||||
s.push('confirm');
|
||||
s.push("confirm");
|
||||
|
||||
return s;
|
||||
},
|
||||
hasReturnPath() {
|
||||
let params = new URLSearchParams(window.location.search);
|
||||
|
||||
return params.has('returnPath');
|
||||
return params.has("returnPath");
|
||||
},
|
||||
// return true if the next step is allowed
|
||||
isNextAllowed() {
|
||||
switch (this.$data.step) {
|
||||
case 'concerned':
|
||||
case "concerned":
|
||||
return this.$store.state.concerned.length > 0;
|
||||
case 'household':
|
||||
case "household":
|
||||
return this.$store.state.mode !== null;
|
||||
case 'household_address':
|
||||
return this.$store.getters.hasHouseholdAddress || this.$store.getters.isHouseholdForceNoAddress;
|
||||
case 'positioning':
|
||||
return this.$store.getters.hasHouseholdOrLeave
|
||||
&& this.$store.getters.hasPersonsWellPositionnated;
|
||||
case "household_address":
|
||||
return (
|
||||
this.$store.getters.hasHouseholdAddress ||
|
||||
this.$store.getters.isHouseholdForceNoAddress
|
||||
);
|
||||
case "positioning":
|
||||
return (
|
||||
this.$store.getters.hasHouseholdOrLeave &&
|
||||
this.$store.getters.hasPersonsWellPositionnated
|
||||
);
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
lastStepIsSaveAllowed() {
|
||||
let r = !this.$store.getters.isHouseholdNew ||
|
||||
(this.$store.state.numberOfChildren !== null && this.$store.state.householdCompositionType !== null);
|
||||
console.log('is saved allowed ?', r);
|
||||
let r =
|
||||
!this.$store.getters.isHouseholdNew ||
|
||||
(this.$store.state.numberOfChildren !== null &&
|
||||
this.$store.state.householdCompositionType !== null);
|
||||
console.log("is saved allowed ?", r);
|
||||
|
||||
return r;
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
goToNext() {
|
||||
console.log('go to next');
|
||||
console.log("go to next");
|
||||
switch (this.$data.step) {
|
||||
case 'concerned':
|
||||
this.$data.step = 'household';
|
||||
case "concerned":
|
||||
this.$data.step = "household";
|
||||
break;
|
||||
case 'household':
|
||||
case "household":
|
||||
if (this.$store.getters.isHouseholdNew) {
|
||||
this.$data.step = 'household_address';
|
||||
this.$data.step = "household_address";
|
||||
break;
|
||||
} else if (this.$store.getters.isModeLeave) {
|
||||
this.$data.step = 'confirm';
|
||||
this.$data.step = "confirm";
|
||||
break;
|
||||
} else {
|
||||
this.$data.step = 'positioning';
|
||||
this.$data.step = "positioning";
|
||||
break;
|
||||
}
|
||||
case 'household_address':
|
||||
this.$data.step = 'positioning';
|
||||
case "household_address":
|
||||
this.$data.step = "positioning";
|
||||
break;
|
||||
case 'positioning':
|
||||
this.$data.step = 'confirm';
|
||||
case "positioning":
|
||||
this.$data.step = "confirm";
|
||||
break;
|
||||
}
|
||||
},
|
||||
goToPrevious() {
|
||||
if (this.$data.step === 'concerned') {
|
||||
if (this.$data.step === "concerned") {
|
||||
let params = new URLSearchParams(window.location.search);
|
||||
if (params.has('returnPath')) {
|
||||
window.location.replace(params.get('returnPath'));
|
||||
if (params.has("returnPath")) {
|
||||
window.location.replace(params.get("returnPath"));
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
@@ -181,9 +175,8 @@ export default {
|
||||
this.$data.step = s[index - 1];
|
||||
},
|
||||
confirm() {
|
||||
this.$store.dispatch('confirm');
|
||||
this.$store.dispatch("confirm");
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
@@ -1,55 +1,60 @@
|
||||
/*
|
||||
*/
|
||||
*/
|
||||
const householdMove = (payload) => {
|
||||
const url = `/api/1.0/person/household/members/move.json`;
|
||||
console.log(payload);
|
||||
console.log(JSON.stringify(payload));
|
||||
|
||||
return fetch(url, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(payload),
|
||||
})
|
||||
.then(response => {
|
||||
if (response.ok) {
|
||||
return response.json();
|
||||
}
|
||||
if (response.status === 422) {
|
||||
return response.json();
|
||||
}
|
||||
throw Error('Error with testing move');
|
||||
});
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(payload),
|
||||
}).then((response) => {
|
||||
if (response.ok) {
|
||||
return response.json();
|
||||
}
|
||||
if (response.status === 422) {
|
||||
return response.json();
|
||||
}
|
||||
throw Error("Error with testing move");
|
||||
});
|
||||
};
|
||||
|
||||
const fetchHouseholdSuggestionByAccompanyingPeriod = (personId) => {
|
||||
const url = `/api/1.0/person/household/suggest/by-person/${personId}/through-accompanying-period-participation.json`;
|
||||
return window.fetch(url)
|
||||
.then(response => {
|
||||
return window
|
||||
.fetch(url)
|
||||
.then((response) => {
|
||||
if (response.ok) {
|
||||
return response.json();
|
||||
}
|
||||
|
||||
throw Error ({m: 'Error while fetching household suggestion', status: response.status});
|
||||
}).then(data => Promise.resolve(data.results))
|
||||
.catch(e => console.error(e));
|
||||
;
|
||||
throw Error({
|
||||
m: "Error while fetching household suggestion",
|
||||
status: response.status,
|
||||
});
|
||||
})
|
||||
.then((data) => Promise.resolve(data.results))
|
||||
.catch((e) => console.error(e));
|
||||
};
|
||||
|
||||
const fetchAddressSuggestionByPerson = (personId) => {
|
||||
const url = `/api/1.0/person/address/suggest/by-person/${personId}.json`;
|
||||
return window.fetch(url)
|
||||
.then(response => {
|
||||
if (response.ok) {
|
||||
return response.json();
|
||||
}
|
||||
return window.fetch(url).then((response) => {
|
||||
if (response.ok) {
|
||||
return response.json();
|
||||
}
|
||||
|
||||
throw Error({m: 'Error while fetch address suggestion', status: response.status});
|
||||
throw Error({
|
||||
m: "Error while fetch address suggestion",
|
||||
status: response.status,
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export {
|
||||
export {
|
||||
householdMove,
|
||||
fetchHouseholdSuggestionByAccompanyingPeriod,
|
||||
fetchAddressSuggestionByPerson,
|
||||
|
@@ -1,22 +1,22 @@
|
||||
<template>
|
||||
<h2 class="mt-4">
|
||||
{{ $t('household_members_editor.concerned.title') }}
|
||||
{{ $t("household_members_editor.concerned.title") }}
|
||||
</h2>
|
||||
|
||||
<div v-if="noPerson">
|
||||
<div class="alert alert-info">
|
||||
{{ $t('household_members_editor.concerned.add_at_least_onePerson') }}
|
||||
{{ $t("household_members_editor.concerned.add_at_least_onePerson") }}
|
||||
</div>
|
||||
</div>
|
||||
<div v-else>
|
||||
<p>{{ $t('household_members_editor.concerned.persons_will_be_moved') }} :</p>
|
||||
<p>
|
||||
{{
|
||||
$t("household_members_editor.concerned.persons_will_be_moved")
|
||||
}} :
|
||||
</p>
|
||||
|
||||
<ul class="list-suggest remove-items inline">
|
||||
<li
|
||||
v-for="c in concerned"
|
||||
:key="c.person.id"
|
||||
@click="removeConcerned(c)"
|
||||
>
|
||||
<li v-for="c in concerned" :key="c.person.id" @click="removeConcerned(c)">
|
||||
<span><person-text :person="c.person" /></span>
|
||||
</li>
|
||||
</ul>
|
||||
@@ -25,18 +25,22 @@
|
||||
class="alert alert-info"
|
||||
v-if="concernedPersonsWithHouseholds.length > 0"
|
||||
>
|
||||
<p>{{ $t('household_members_editor.concerned.persons_with_household') }}</p>
|
||||
<ul
|
||||
v-for="c in concernedPersonsWithHouseholds"
|
||||
:key="c.person.id"
|
||||
>
|
||||
<p>
|
||||
{{ $t("household_members_editor.concerned.persons_with_household") }}
|
||||
</p>
|
||||
<ul v-for="c in concernedPersonsWithHouseholds" :key="c.person.id">
|
||||
<li>
|
||||
{{ c.person.text }}
|
||||
{{ $t('household_members_editor.concerned.already_belongs_to_household') }}
|
||||
{{
|
||||
$t(
|
||||
"household_members_editor.concerned.already_belongs_to_household",
|
||||
)
|
||||
}}
|
||||
<a
|
||||
target="_blank"
|
||||
:href="this.makeHouseholdLink(c.person.current_household_id)"
|
||||
>{{ c.person.current_household_id }}</a>.
|
||||
>{{ c.person.current_household_id }}</a
|
||||
>.
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
@@ -59,79 +63,76 @@
|
||||
</template>
|
||||
|
||||
<style lang="scss">
|
||||
|
||||
.move_to {
|
||||
.move_hint {
|
||||
text-align: center;
|
||||
display: inline-block;
|
||||
padding: 0.400rem 0.5rem;
|
||||
padding: 0.4rem 0.5rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
import { mapState, mapGetters } from 'vuex';
|
||||
import AddPersons from 'ChillPersonAssets/vuejs/_components/AddPersons.vue';
|
||||
import PersonText from 'ChillPersonAssets/vuejs/_components/Entity/PersonText.vue';
|
||||
import { mapState, mapGetters } from "vuex";
|
||||
import AddPersons from "ChillPersonAssets/vuejs/_components/AddPersons.vue";
|
||||
import PersonText from "ChillPersonAssets/vuejs/_components/Entity/PersonText.vue";
|
||||
|
||||
export default {
|
||||
name: 'Concerned',
|
||||
name: "Concerned",
|
||||
components: {
|
||||
AddPersons,
|
||||
PersonText,
|
||||
},
|
||||
computed: {
|
||||
...mapState([
|
||||
'concerned', 'household'
|
||||
]),
|
||||
...mapGetters([
|
||||
'persons',
|
||||
]),
|
||||
noPerson () {
|
||||
...mapState(["concerned", "household"]),
|
||||
...mapGetters(["persons"]),
|
||||
noPerson() {
|
||||
return this.$store.getters.persons.length === 0;
|
||||
},
|
||||
concernedPersonsWithHouseholds () {
|
||||
concernedPersonsWithHouseholds() {
|
||||
if (this.$store.state.household) {
|
||||
return this.$store.state.concerned.filter(c =>
|
||||
c.person.current_household_id !== null && c.person.current_household_id !== this.$store.state.household.id
|
||||
)
|
||||
return this.$store.state.concerned.filter(
|
||||
(c) =>
|
||||
c.person.current_household_id !== null &&
|
||||
c.person.current_household_id !== this.$store.state.household.id,
|
||||
);
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
addPersons: {
|
||||
key: 'household_members_editor_concerned',
|
||||
key: "household_members_editor_concerned",
|
||||
options: {
|
||||
type: ['person'],
|
||||
priority: null,
|
||||
uniq: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
type: ["person"],
|
||||
priority: null,
|
||||
uniq: false,
|
||||
},
|
||||
},
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
addNewPersons({ selected, modal }) {
|
||||
selected.forEach(function(item) {
|
||||
this.$store.dispatch('addConcerned', item.result);
|
||||
selected.forEach(function (item) {
|
||||
this.$store.dispatch("addConcerned", item.result);
|
||||
}, this);
|
||||
this.$refs.addPersons.resetSearch(); // to cast child method
|
||||
modal.showModal = false;
|
||||
},
|
||||
removeConcerned(concerned) {
|
||||
console.log('removedconcerned', concerned);
|
||||
console.log("removedconcerned", concerned);
|
||||
|
||||
if (!concerned.allowRemove) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.$store.dispatch('removePerson', concerned.person);
|
||||
this.$store.dispatch("removePerson", concerned.person);
|
||||
},
|
||||
makeHouseholdLink(id) {
|
||||
return `/fr/person/household/${id}/summary`
|
||||
}
|
||||
}
|
||||
}
|
||||
return `/fr/person/household/${id}/summary`;
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
@@ -1,48 +1,36 @@
|
||||
<template>
|
||||
<div
|
||||
v-if="hasWarning"
|
||||
class="alert alert-warning"
|
||||
>
|
||||
{{ $t('household_members_editor.confirmation.there_are_warnings') }}
|
||||
<div v-if="hasWarning" class="alert alert-warning">
|
||||
{{ $t("household_members_editor.confirmation.there_are_warnings") }}
|
||||
</div>
|
||||
|
||||
<p v-if="hasWarning">
|
||||
{{ $t('household_members_editor.confirmation.check_those_items') }}
|
||||
{{ $t("household_members_editor.confirmation.check_those_items") }}
|
||||
</p>
|
||||
|
||||
<ul>
|
||||
<li
|
||||
v-for="(msg, i) in warnings"
|
||||
class="warning"
|
||||
:key="i"
|
||||
>
|
||||
<li v-for="(msg, i) in warnings" class="warning" :key="i">
|
||||
{{ $t(msg.m, msg.a) }}
|
||||
</li>
|
||||
<li
|
||||
v-for="(msg, i) in errors"
|
||||
class="error"
|
||||
:key="i"
|
||||
>
|
||||
<li v-for="(msg, i) in errors" class="error" :key="i">
|
||||
{{ msg }}
|
||||
</li>
|
||||
</ul>
|
||||
</template>
|
||||
|
||||
<style scoped lang="scss">
|
||||
</style>
|
||||
<style scoped lang="scss"></style>
|
||||
|
||||
<script>
|
||||
import { mapState } from 'vuex';
|
||||
import { mapState } from "vuex";
|
||||
|
||||
export default {
|
||||
name: 'Confirmation',
|
||||
name: "Confirmation",
|
||||
computed: {
|
||||
...mapState({
|
||||
hasWarnings: (state) => state.warnings.length > 0 || state.errors.length > 0,
|
||||
hasWarnings: (state) =>
|
||||
state.warnings.length > 0 || state.errors.length > 0,
|
||||
warnings: (state) => state.warnings,
|
||||
errors: (state) => state.errors,
|
||||
}),
|
||||
},
|
||||
}
|
||||
|
||||
};
|
||||
</script>
|
||||
|
@@ -1,16 +1,10 @@
|
||||
<template>
|
||||
<div
|
||||
class="flex-table mb-5"
|
||||
v-if="hasHousehold"
|
||||
>
|
||||
<div class="flex-table mb-5" v-if="hasHousehold">
|
||||
<div class="item-bloc">
|
||||
<household-render-box :household="fakeHouseholdWithConcerned" />
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="flex-table"
|
||||
v-if="isModeLeave"
|
||||
>
|
||||
<div class="flex-table" v-if="isModeLeave">
|
||||
<div class="item-bloc">
|
||||
<section>
|
||||
<div class="item-row">
|
||||
@@ -20,12 +14,18 @@
|
||||
<i class="fa fa-home fa-stack-1x" />
|
||||
<i class="fa fa-ban fa-stack-2x text-danger" />
|
||||
</span>
|
||||
{{ $t('household_members_editor.household.leave_without_household') }}
|
||||
{{
|
||||
$t("household_members_editor.household.leave_without_household")
|
||||
}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="item-row">
|
||||
{{ $t('household_members_editor.household.will_leave_any_household_explanation') }}
|
||||
{{
|
||||
$t(
|
||||
"household_members_editor.household.will_leave_any_household_explanation",
|
||||
)
|
||||
}}
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
@@ -33,8 +33,8 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapGetters } from 'vuex';
|
||||
import HouseholdRenderBox from 'ChillPersonAssets/vuejs/_components/Entity/HouseholdRenderBox.vue';
|
||||
import { mapGetters } from "vuex";
|
||||
import HouseholdRenderBox from "ChillPersonAssets/vuejs/_components/Entity/HouseholdRenderBox.vue";
|
||||
|
||||
export default {
|
||||
name: "CurrentHousehold",
|
||||
@@ -43,14 +43,12 @@ export default {
|
||||
},
|
||||
computed: {
|
||||
...mapGetters([
|
||||
'hasHousehold',
|
||||
'fakeHouseholdWithConcerned',
|
||||
'isModeLeave'
|
||||
])
|
||||
}
|
||||
}
|
||||
"hasHousehold",
|
||||
"fakeHouseholdWithConcerned",
|
||||
"isModeLeave",
|
||||
]),
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
</style>
|
||||
<style lang="scss" scoped></style>
|
||||
|
@@ -1,28 +1,23 @@
|
||||
<template>
|
||||
<current-household />
|
||||
|
||||
<h2>{{ $t('household_members_editor.dates.dates_title') }}</h2>
|
||||
<h2>{{ $t("household_members_editor.dates.dates_title") }}</h2>
|
||||
|
||||
<div class="mb-3 row">
|
||||
<label
|
||||
for="start_date"
|
||||
class="col-form-label col-sm-4 required"
|
||||
>
|
||||
{{ $t('household_members_editor.dates.start_date') }}
|
||||
<label for="start_date" class="col-form-label col-sm-4 required">
|
||||
{{ $t("household_members_editor.dates.start_date") }}
|
||||
</label>
|
||||
<div class="col-sm-8">
|
||||
<input
|
||||
type="date"
|
||||
v-model="startDate"
|
||||
class="form-control"
|
||||
>
|
||||
<input type="date" v-model="startDate" class="form-control" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="this.isHouseholdNew">
|
||||
<h2>{{ $t('household_members_editor.composition.composition') }}</h2>
|
||||
<h2>{{ $t("household_members_editor.composition.composition") }}</h2>
|
||||
<div class="mb-3 row">
|
||||
<label class="col-form-label col-sm-4 required">{{ $t('household_members_editor.composition.household_composition') }}</label>
|
||||
<label class="col-form-label col-sm-4 required">{{
|
||||
$t("household_members_editor.composition.household_composition")
|
||||
}}</label>
|
||||
<div class="col-sm-8">
|
||||
<select
|
||||
v-model="householdCompositionType"
|
||||
@@ -39,7 +34,9 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-3 row">
|
||||
<label class="col-form-label col-sm-4 required">{{ $t('household_members_editor.composition.number_of_children') }}</label>
|
||||
<label class="col-form-label col-sm-4 required">{{
|
||||
$t("household_members_editor.composition.number_of_children")
|
||||
}}</label>
|
||||
<div class="col-sm-8">
|
||||
<input
|
||||
type="number"
|
||||
@@ -47,25 +44,24 @@
|
||||
min="0"
|
||||
max="30"
|
||||
class="form-control"
|
||||
>
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
import CurrentHousehold from "./CurrentHousehold";
|
||||
import {mapGetters, mapState} from 'vuex';
|
||||
import { mapGetters, mapState } from "vuex";
|
||||
|
||||
export default {
|
||||
name: 'Dates',
|
||||
name: "Dates",
|
||||
components: {
|
||||
CurrentHousehold
|
||||
CurrentHousehold,
|
||||
},
|
||||
computed: {
|
||||
...mapState(['householdCompositionTypes']),
|
||||
...mapGetters(['isHouseholdNew']),
|
||||
...mapState(["householdCompositionTypes"]),
|
||||
...mapGetters(["isHouseholdNew"]),
|
||||
householdCompositionType: {
|
||||
get() {
|
||||
if (this.$store.state.householdCompositionType !== null) {
|
||||
@@ -74,7 +70,7 @@ export default {
|
||||
return null;
|
||||
},
|
||||
set(value) {
|
||||
this.$store.dispatch('setHouseholdCompositionType', value);
|
||||
this.$store.dispatch("setHouseholdCompositionType", value);
|
||||
},
|
||||
},
|
||||
numberOfChildren: {
|
||||
@@ -82,8 +78,8 @@ export default {
|
||||
return this.$store.state.numberOfChildren;
|
||||
},
|
||||
set(value) {
|
||||
this.$store.commit('setNumberOfChildren', value);
|
||||
}
|
||||
this.$store.commit("setNumberOfChildren", value);
|
||||
},
|
||||
},
|
||||
startDate: {
|
||||
get() {
|
||||
@@ -99,10 +95,9 @@ export default {
|
||||
// [year, month, day] = value.split('-'),
|
||||
// dValue = new Date(year, month-1, day);
|
||||
|
||||
this.$store.dispatch('setStartDate', value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.$store.dispatch("setStartDate", value);
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
@@ -1,35 +1,27 @@
|
||||
<template>
|
||||
<h2 class="mt-4">
|
||||
{{ $t('household_members_editor.household_part') }}
|
||||
{{ $t("household_members_editor.household_part") }}
|
||||
</h2>
|
||||
|
||||
<div
|
||||
class="alert alert-info"
|
||||
v-if="!hasHousehold"
|
||||
>
|
||||
{{ $t('household_members_editor.household.no_household_choose_one') }}
|
||||
<div class="alert alert-info" v-if="!hasHousehold">
|
||||
{{ $t("household_members_editor.household.no_household_choose_one") }}
|
||||
</div>
|
||||
<template v-else>
|
||||
<current-household />
|
||||
</template>
|
||||
|
||||
<div
|
||||
v-if="hasHouseholdSuggestion"
|
||||
class="householdSuggestions my-5"
|
||||
>
|
||||
<div v-if="hasHouseholdSuggestion" class="householdSuggestions my-5">
|
||||
<h4 class="mb-3">
|
||||
{{ $t('household_members_editor.household.household_suggested') }}
|
||||
{{ $t("household_members_editor.household.household_suggested") }}
|
||||
</h4>
|
||||
<p>{{ $t('household_members_editor.household.household_suggested_explanation') }}</p>
|
||||
<div
|
||||
class="accordion"
|
||||
id="householdSuggestions"
|
||||
>
|
||||
<p>
|
||||
{{
|
||||
$t("household_members_editor.household.household_suggested_explanation")
|
||||
}}
|
||||
</p>
|
||||
<div class="accordion" id="householdSuggestions">
|
||||
<div class="accordion-item">
|
||||
<h2
|
||||
class="accordion-header"
|
||||
id="heading_household_suggestions"
|
||||
>
|
||||
<h2 class="accordion-header" id="heading_household_suggestions">
|
||||
<button
|
||||
v-if="!showHouseholdSuggestion"
|
||||
class="accordion-button collapsed"
|
||||
@@ -38,7 +30,12 @@
|
||||
aria-expanded="false"
|
||||
@click="toggleHouseholdSuggestion"
|
||||
>
|
||||
{{ $tc('household_members_editor.show_household_suggestion', countHouseholdSuggestion) }}
|
||||
{{
|
||||
$tc(
|
||||
"household_members_editor.show_household_suggestion",
|
||||
countHouseholdSuggestion,
|
||||
)
|
||||
}}
|
||||
</button>
|
||||
<button
|
||||
v-if="showHouseholdSuggestion"
|
||||
@@ -48,7 +45,7 @@
|
||||
aria-expanded="true"
|
||||
@click="toggleHouseholdSuggestion"
|
||||
>
|
||||
{{ $t('household_members_editor.hide_household_suggestion') }}
|
||||
{{ $t("household_members_editor.hide_household_suggestion") }}
|
||||
</button>
|
||||
<!-- disabled bootstrap behaviour: data-bs-target="#collapse_household_suggestions" aria-controls="collapse_household_suggestions" -->
|
||||
</h2>
|
||||
@@ -72,7 +69,7 @@
|
||||
class="btn btn-sm btn-choose"
|
||||
@click="selectHousehold(s.household)"
|
||||
>
|
||||
{{ $t('household_members_editor.select_household') }}
|
||||
{{ $t("household_members_editor.select_household") }}
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
@@ -84,20 +81,13 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<ul class="record_actions">
|
||||
<li v-if="hasHousehold">
|
||||
<button
|
||||
@click="resetMode"
|
||||
class="btn btn-sm btn-misc"
|
||||
>
|
||||
{{ $t('household_members_editor.household.reset_mode') }}
|
||||
<button @click="resetMode" class="btn btn-sm btn-misc">
|
||||
{{ $t("household_members_editor.household.reset_mode") }}
|
||||
</button>
|
||||
</li>
|
||||
<li
|
||||
v-if="!hasHousehold"
|
||||
class="add-persons"
|
||||
>
|
||||
<li v-if="!hasHousehold" class="add-persons">
|
||||
<add-persons
|
||||
modal-title="Chercher un ménage existant"
|
||||
button-title="Chercher un ménage existant"
|
||||
@@ -110,55 +100,49 @@
|
||||
</add-persons>
|
||||
</li>
|
||||
<li v-if="!hasHousehold">
|
||||
<button
|
||||
@click="setModeNew"
|
||||
class="btn btn-sm btn-create"
|
||||
>
|
||||
{{ $t('household_members_editor.household.create_household') }}
|
||||
<button @click="setModeNew" class="btn btn-sm btn-create">
|
||||
{{ $t("household_members_editor.household.create_household") }}
|
||||
</button>
|
||||
</li>
|
||||
<li v-if="isModeLeaveAllowed && !hasHousehold">
|
||||
<button
|
||||
@click="setModeLeave"
|
||||
class="btn btn-sm btn-misc"
|
||||
>
|
||||
<button @click="setModeLeave" class="btn btn-sm btn-misc">
|
||||
<i class="fa fa-sign-out" />
|
||||
{{ $t('household_members_editor.household.leave') }}
|
||||
{{ $t("household_members_editor.household.leave") }}
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapGetters, mapState } from 'vuex';
|
||||
import HouseholdRenderBox from 'ChillPersonAssets/vuejs/_components/Entity/HouseholdRenderBox.vue';
|
||||
import CurrentHousehold from './CurrentHousehold';
|
||||
import AddPersons from 'ChillPersonAssets/vuejs/_components/AddPersons';
|
||||
import { mapGetters, mapState } from "vuex";
|
||||
import HouseholdRenderBox from "ChillPersonAssets/vuejs/_components/Entity/HouseholdRenderBox.vue";
|
||||
import CurrentHousehold from "./CurrentHousehold";
|
||||
import AddPersons from "ChillPersonAssets/vuejs/_components/AddPersons";
|
||||
|
||||
export default {
|
||||
name: 'Household',
|
||||
name: "Household",
|
||||
components: {
|
||||
AddPersons,
|
||||
CurrentHousehold,
|
||||
HouseholdRenderBox,
|
||||
},
|
||||
emits: ['readyToGo'],
|
||||
emits: ["readyToGo"],
|
||||
data() {
|
||||
return {
|
||||
addPersons: {
|
||||
key: 'household_find',
|
||||
key: "household_find",
|
||||
options: {
|
||||
type: ['household'],
|
||||
type: ["household"],
|
||||
priority: null,
|
||||
uniq: true,
|
||||
button: {
|
||||
size: 'btn-sm',
|
||||
type: 'btn-search',
|
||||
}
|
||||
}
|
||||
size: "btn-sm",
|
||||
type: "btn-search",
|
||||
},
|
||||
},
|
||||
},
|
||||
addAddress: {
|
||||
key: 'household_new',
|
||||
key: "household_new",
|
||||
options: {
|
||||
useDate: {
|
||||
validFrom: false,
|
||||
@@ -166,102 +150,106 @@ export default {
|
||||
},
|
||||
onlyButton: true,
|
||||
button: {
|
||||
text: {
|
||||
create: 'household_members_editor.household.set_address',
|
||||
edit: 'household_members_editor.household.update_address',
|
||||
}
|
||||
text: {
|
||||
create: "household_members_editor.household.set_address",
|
||||
edit: "household_members_editor.household.update_address",
|
||||
},
|
||||
},
|
||||
title: {
|
||||
create: 'household_members_editor.household.create_new_address',
|
||||
edit: 'household_members_editor.household.update_address_title',
|
||||
create: "household_members_editor.household.create_new_address",
|
||||
edit: "household_members_editor.household.update_address_title",
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
...mapGetters([
|
||||
'isModeNewAllowed',
|
||||
'isModeLeaveAllowed',
|
||||
'getSuggestions',
|
||||
'hasHousehold',
|
||||
'isHouseholdNew',
|
||||
'hasHouseholdSuggestion',
|
||||
'countHouseholdSuggestion',
|
||||
'filterHouseholdSuggestionByAccompanyingPeriod',
|
||||
'hasAddressSuggestion',
|
||||
'countAddressSuggestion',
|
||||
'filterAddressesSuggestion',
|
||||
'hasHouseholdAddress',
|
||||
'isModeLeave',
|
||||
'getAddressContext',
|
||||
"isModeNewAllowed",
|
||||
"isModeLeaveAllowed",
|
||||
"getSuggestions",
|
||||
"hasHousehold",
|
||||
"isHouseholdNew",
|
||||
"hasHouseholdSuggestion",
|
||||
"countHouseholdSuggestion",
|
||||
"filterHouseholdSuggestionByAccompanyingPeriod",
|
||||
"hasAddressSuggestion",
|
||||
"countAddressSuggestion",
|
||||
"filterAddressesSuggestion",
|
||||
"hasHouseholdAddress",
|
||||
"isModeLeave",
|
||||
"getAddressContext",
|
||||
]),
|
||||
...mapState([
|
||||
'household',
|
||||
'showHouseholdSuggestion',
|
||||
'showAddressSuggestion',
|
||||
'mode',
|
||||
"household",
|
||||
"showHouseholdSuggestion",
|
||||
"showAddressSuggestion",
|
||||
"mode",
|
||||
]),
|
||||
household() {
|
||||
return this.$store.state.household;
|
||||
},
|
||||
allowHouseholdSearch() {
|
||||
return false;
|
||||
return this.$store.state.allowHouseholdSearch && !this.$store.getters.hasHousehold;
|
||||
return (
|
||||
this.$store.state.allowHouseholdSearch &&
|
||||
!this.$store.getters.hasHousehold
|
||||
);
|
||||
},
|
||||
isHouseholdNewDesactivated() {
|
||||
return this.$store.state.mode !== null && !this.$store.getters.isHouseholdNew;
|
||||
return (
|
||||
this.$store.state.mode !== null && !this.$store.getters.isHouseholdNew
|
||||
);
|
||||
},
|
||||
isHouseholdLeaveDesactivated() {
|
||||
return this.$store.state.mode !== null && this.$store.state.mode !== "leave";
|
||||
}
|
||||
return (
|
||||
this.$store.state.mode !== null && this.$store.state.mode !== "leave"
|
||||
);
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
setModeNew() {
|
||||
this.$store.dispatch('createHousehold');
|
||||
this.$emit('readyToGo');
|
||||
this.$store.dispatch("createHousehold");
|
||||
this.$emit("readyToGo");
|
||||
},
|
||||
setModeLeave() {
|
||||
this.$store.dispatch('forceLeaveWithoutHousehold');
|
||||
this.$emit('readyToGo');
|
||||
this.$store.dispatch("forceLeaveWithoutHousehold");
|
||||
this.$emit("readyToGo");
|
||||
},
|
||||
resetMode() {
|
||||
this.$store.commit('resetMode');
|
||||
this.$store.commit("resetMode");
|
||||
},
|
||||
addressChanged(payload) {
|
||||
console.log("addressChanged", payload);
|
||||
this.$store.dispatch('setHouseholdNewAddress', payload.address);
|
||||
this.$store.dispatch("setHouseholdNewAddress", payload.address);
|
||||
},
|
||||
selectHousehold(h) {
|
||||
this.$store.dispatch('selectHousehold', h);
|
||||
this.$emit('readyToGo');
|
||||
this.$store.dispatch("selectHousehold", h);
|
||||
this.$emit("readyToGo");
|
||||
},
|
||||
pickHouseholdFound({selected, modal}) {
|
||||
selected.forEach(function(item) {
|
||||
pickHouseholdFound({ selected, modal }) {
|
||||
selected.forEach(function (item) {
|
||||
this.selectHousehold(item.result);
|
||||
}, this);
|
||||
this.$refs.pickHousehold.resetSearch(); // to cast child method
|
||||
modal.showModal = false;
|
||||
},
|
||||
removeHouseholdAddress() {
|
||||
this.$store.commit('removeHouseholdAddress');
|
||||
this.$store.commit("removeHouseholdAddress");
|
||||
},
|
||||
toggleHouseholdSuggestion() {
|
||||
this.$store.commit('toggleHouseholdSuggestion');
|
||||
this.$store.commit("toggleHouseholdSuggestion");
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
|
||||
.filtered {
|
||||
filter: grayscale(1) opacity(0.6);
|
||||
}
|
||||
|
||||
.filteredButActive {
|
||||
|
||||
filter: grayscale(1) opacity(0.6);
|
||||
&:hover {
|
||||
filter: unset;
|
||||
@@ -270,16 +258,16 @@ export default {
|
||||
|
||||
div#household_members_editor div,
|
||||
div.householdSuggestionList {
|
||||
&.flex-table {
|
||||
margin: 0;
|
||||
div.item-bloc div.item-row div.item-col {
|
||||
&:first-child {
|
||||
width: 25%;
|
||||
}
|
||||
&:last-child {
|
||||
display: initial;
|
||||
}
|
||||
&.flex-table {
|
||||
margin: 0;
|
||||
div.item-bloc div.item-row div.item-col {
|
||||
&:first-child {
|
||||
width: 25%;
|
||||
}
|
||||
}
|
||||
&:last-child {
|
||||
display: initial;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
@@ -16,20 +16,17 @@
|
||||
/>
|
||||
</li>
|
||||
<li v-if="hasHouseholdAddress">
|
||||
<button
|
||||
class="btn btn-remove"
|
||||
@click="removeHouseholdAddress"
|
||||
>
|
||||
{{ $t('household_members_editor.household_address.remove_address') }}
|
||||
<button class="btn btn-remove" @click="removeHouseholdAddress">
|
||||
{{ $t("household_members_editor.household_address.remove_address") }}
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import AddAddress from 'ChillMainAssets/vuejs/Address/components/AddAddress.vue';
|
||||
import CurrentHousehold from './CurrentHousehold';
|
||||
import { mapGetters } from 'vuex';
|
||||
import AddAddress from "ChillMainAssets/vuejs/Address/components/AddAddress.vue";
|
||||
import CurrentHousehold from "./CurrentHousehold";
|
||||
import { mapGetters } from "vuex";
|
||||
|
||||
export default {
|
||||
name: "HouseholdAddress.vue",
|
||||
@@ -40,7 +37,7 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
addAddress: {
|
||||
key: 'household_new',
|
||||
key: "household_new",
|
||||
options: {
|
||||
useDate: {
|
||||
validFrom: false,
|
||||
@@ -49,41 +46,40 @@ export default {
|
||||
onlyButton: true,
|
||||
button: {
|
||||
text: {
|
||||
create: 'household_members_editor.household_address.set_address',
|
||||
edit: 'household_members_editor.household_address.update_address',
|
||||
}
|
||||
create: "household_members_editor.household_address.set_address",
|
||||
edit: "household_members_editor.household_address.update_address",
|
||||
},
|
||||
},
|
||||
title: {
|
||||
create: 'household_members_editor.household_address.create_new_address',
|
||||
edit: 'household_members_editor.household_address.update_address_title',
|
||||
create:
|
||||
"household_members_editor.household_address.create_new_address",
|
||||
edit: "household_members_editor.household_address.update_address_title",
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
...mapGetters([
|
||||
'isHouseholdNew',
|
||||
'hasHouseholdAddress',
|
||||
'getAddressContext',
|
||||
'isHouseholdForceNoAddress'
|
||||
])
|
||||
"isHouseholdNew",
|
||||
"hasHouseholdAddress",
|
||||
"getAddressContext",
|
||||
"isHouseholdForceNoAddress",
|
||||
]),
|
||||
},
|
||||
methods: {
|
||||
addressChanged(payload) {
|
||||
console.log("addressChanged", payload);
|
||||
this.$store.dispatch('setHouseholdNewAddress', payload.address);
|
||||
this.$store.dispatch("setHouseholdNewAddress", payload.address);
|
||||
},
|
||||
markNoAddress() {
|
||||
this.$store.commit('markHouseholdNoAddress');
|
||||
this.$store.commit("markHouseholdNoAddress");
|
||||
},
|
||||
removeHouseholdAddress() {
|
||||
this.$store.commit('removeHouseholdAddress');
|
||||
this.$store.commit("removeHouseholdAddress");
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
<style scoped></style>
|
||||
|
@@ -8,15 +8,14 @@
|
||||
:options="{}"
|
||||
:person="conc.person"
|
||||
/>
|
||||
<span
|
||||
v-if="isHolder"
|
||||
class="badge bg-primary holder"
|
||||
>
|
||||
{{ $t('household_members_editor.holder') }}
|
||||
<span v-if="isHolder" class="badge bg-primary holder">
|
||||
{{ $t("household_members_editor.holder") }}
|
||||
</span>
|
||||
</div>
|
||||
<div v-if="conc.person.birthdate !== null">
|
||||
{{ $t('person.born', {'gender': conc.person.gender.genderTranslation} ) }}
|
||||
{{
|
||||
$t("person.born", { gender: conc.person.gender.genderTranslation })
|
||||
}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="item-col">
|
||||
@@ -30,33 +29,33 @@
|
||||
</div>
|
||||
|
||||
<div class="item-row comment">
|
||||
<ckeditor
|
||||
:editor="editor"
|
||||
v-model="comment"
|
||||
tag-name="textarea"
|
||||
/>
|
||||
<ckeditor :editor="editor" v-model="comment" tag-name="textarea" />
|
||||
</div>
|
||||
|
||||
<div class="item-row participation-details">
|
||||
<div
|
||||
v-if="conc.position.allowHolder"
|
||||
class="action"
|
||||
>
|
||||
<div v-if="conc.position.allowHolder" class="action">
|
||||
<button
|
||||
class="btn"
|
||||
:class="{ 'btn-primary': isHolder, 'btn-secondary': !isHolder}"
|
||||
:class="{ 'btn-primary': isHolder, 'btn-secondary': !isHolder }"
|
||||
@click="toggleHolder"
|
||||
>
|
||||
{{ $t(isHolder ? 'household_members_editor.is_holder' : 'household_members_editor.is_not_holder') }}
|
||||
{{
|
||||
$t(
|
||||
isHolder
|
||||
? "household_members_editor.is_holder"
|
||||
: "household_members_editor.is_not_holder",
|
||||
)
|
||||
}}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<button
|
||||
@click="removePosition"
|
||||
class="btn btn-outline-primary"
|
||||
>
|
||||
{{ $t('household_members_editor.remove_position', {position: conc.position.label.fr}) }}
|
||||
<button @click="removePosition" class="btn btn-outline-primary">
|
||||
{{
|
||||
$t("household_members_editor.remove_position", {
|
||||
position: conc.position.label.fr,
|
||||
})
|
||||
}}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@@ -66,7 +65,7 @@
|
||||
@click="removeConcerned"
|
||||
class="btn btn-primary"
|
||||
>
|
||||
{{ $t('household_members_editor.remove_concerned') }}
|
||||
{{ $t("household_members_editor.remove_concerned") }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -74,7 +73,6 @@
|
||||
</template>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
||||
.drag-icon {
|
||||
height: 1.1em;
|
||||
margin-right: 0.5em;
|
||||
@@ -95,59 +93,53 @@ div.participation-details {
|
||||
vertical-align: super;
|
||||
font-size: 0.6em;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<script>
|
||||
import { mapGetters } from 'vuex';
|
||||
import PersonRenderBox from 'ChillPersonAssets/vuejs/_components/Entity/PersonRenderBox.vue';
|
||||
import CKEditor from '@ckeditor/ckeditor5-vue';
|
||||
import ClassicEditor from 'ChillMainAssets/module/ckeditor5/editor_config';
|
||||
import { mapGetters } from "vuex";
|
||||
import PersonRenderBox from "ChillPersonAssets/vuejs/_components/Entity/PersonRenderBox.vue";
|
||||
import CKEditor from "@ckeditor/ckeditor5-vue";
|
||||
import ClassicEditor from "ChillMainAssets/module/ckeditor5/editor_config";
|
||||
|
||||
export default {
|
||||
name: 'MemberDetails',
|
||||
name: "MemberDetails",
|
||||
components: {
|
||||
PersonRenderBox,
|
||||
ckeditor: CKEditor.component,
|
||||
},
|
||||
props: [
|
||||
'conc'
|
||||
],
|
||||
data() {
|
||||
props: ["conc"],
|
||||
data() {
|
||||
return {
|
||||
editor: ClassicEditor,
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
...mapGetters( [
|
||||
'concByPersonId'
|
||||
]),
|
||||
isHolder() {
|
||||
return this.conc.holder;
|
||||
},
|
||||
comment: {
|
||||
},
|
||||
computed: {
|
||||
...mapGetters(["concByPersonId"]),
|
||||
isHolder() {
|
||||
return this.conc.holder;
|
||||
},
|
||||
comment: {
|
||||
get() {
|
||||
return this.conc.comment;
|
||||
},
|
||||
set(text) {
|
||||
console.log('set comment');
|
||||
console.log('comment', text);
|
||||
console.log("set comment");
|
||||
console.log("comment", text);
|
||||
|
||||
this.$store.dispatch('setComment', { conc: this.conc, comment: text });
|
||||
}
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
this.$store.dispatch("setComment", { conc: this.conc, comment: text });
|
||||
},
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
toggleHolder() {
|
||||
this.$store.dispatch('toggleHolder', this.conc);
|
||||
this.$store.dispatch("toggleHolder", this.conc);
|
||||
},
|
||||
removePosition() {
|
||||
this.$store.dispatch('removePosition', this.conc);
|
||||
this.$store.dispatch("removePosition", this.conc);
|
||||
},
|
||||
removeConcerned() {
|
||||
this.$store.dispatch('removeConcerned', this.conc);
|
||||
this.$store.dispatch("removeConcerned", this.conc);
|
||||
},
|
||||
}
|
||||
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
@@ -1,7 +1,9 @@
|
||||
<template>
|
||||
<ckeditor
|
||||
name="content"
|
||||
:placeholder="$t('household_members_editor.positioning.comment_placeholder')"
|
||||
:placeholder="
|
||||
$t('household_members_editor.positioning.comment_placeholder')
|
||||
"
|
||||
:editor="editor"
|
||||
v-model="content"
|
||||
tag-name="textarea"
|
||||
@@ -9,7 +11,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import CKEditor from '@ckeditor/ckeditor5-vue';
|
||||
import CKEditor from "@ckeditor/ckeditor5-vue";
|
||||
import ClassicEditor from "ChillMainAssets/module/ckeditor5/editor_config";
|
||||
|
||||
export default {
|
||||
@@ -17,26 +19,27 @@ export default {
|
||||
components: {
|
||||
ckeditor: CKEditor.component,
|
||||
},
|
||||
props: ['conc'],
|
||||
props: ["conc"],
|
||||
data() {
|
||||
return {
|
||||
editor: ClassicEditor,
|
||||
}
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
content: {
|
||||
get() {
|
||||
return this.$props.conc.comment || '';
|
||||
return this.$props.conc.comment || "";
|
||||
},
|
||||
set(value) {
|
||||
console.log('set content', value);
|
||||
this.$store.commit('setComment', {conc: this.$props.conc, comment: value})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
console.log("set content", value);
|
||||
this.$store.commit("setComment", {
|
||||
conc: this.$props.conc,
|
||||
comment: value,
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
<style scoped></style>
|
||||
|
@@ -1,14 +1,12 @@
|
||||
<template>
|
||||
<current-household />
|
||||
|
||||
<h2>{{ $t('household_members_editor.positioning.persons_to_positionnate') }}</h2>
|
||||
<h2>
|
||||
{{ $t("household_members_editor.positioning.persons_to_positionnate") }}
|
||||
</h2>
|
||||
|
||||
<div class="list-household-members flex-table">
|
||||
<div
|
||||
v-for="conc in concerned"
|
||||
class="item-bloc"
|
||||
:key="conc.person.id"
|
||||
>
|
||||
<div v-for="conc in concerned" class="item-bloc" :key="conc.person.id">
|
||||
<div class="pick-position item-row">
|
||||
<div class="person">
|
||||
<!-- <h3>{{ conc.person.text }}</h3> -->
|
||||
@@ -18,10 +16,13 @@
|
||||
<button
|
||||
class="btn"
|
||||
:disabled="!allowHolderForConcerned(conc)"
|
||||
:class="{'btn-outline-chill-green': !conc.holder, 'btn-chill-green': conc.holder }"
|
||||
:class="{
|
||||
'btn-outline-chill-green': !conc.holder,
|
||||
'btn-chill-green': conc.holder,
|
||||
}"
|
||||
@click="toggleHolder(conc)"
|
||||
>
|
||||
{{ $t('household_members_editor.positioning.holder') }}
|
||||
{{ $t("household_members_editor.positioning.holder") }}
|
||||
</button>
|
||||
</div>
|
||||
<div
|
||||
@@ -31,7 +32,10 @@
|
||||
>
|
||||
<button
|
||||
class="btn"
|
||||
:class="{ 'btn-primary': conc.position === position, 'btn-outline-primary': conc.position !== position }"
|
||||
:class="{
|
||||
'btn-primary': conc.position === position,
|
||||
'btn-outline-primary': conc.position !== position,
|
||||
}"
|
||||
@click="moveToPosition(conc.person.id, position.id)"
|
||||
>
|
||||
{{ position.label.fr }}
|
||||
@@ -40,7 +44,7 @@
|
||||
</div>
|
||||
<div class="item-row">
|
||||
<div>
|
||||
<h6>{{ $t('household_members_editor.positioning.comment') }}</h6>
|
||||
<h6>{{ $t("household_members_editor.positioning.comment") }}</h6>
|
||||
<person-comment :conc="conc" />
|
||||
</div>
|
||||
</div>
|
||||
@@ -49,55 +53,54 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {mapGetters, mapState} from "vuex";
|
||||
import { mapGetters, mapState } from "vuex";
|
||||
import CurrentHousehold from "./CurrentHousehold";
|
||||
import PersonComment from './PersonComment';
|
||||
import PersonText from '../../_components/Entity/PersonText.vue';
|
||||
import PersonComment from "./PersonComment";
|
||||
import PersonText from "../../_components/Entity/PersonText.vue";
|
||||
|
||||
export default {
|
||||
name: "Positioning",
|
||||
components: {
|
||||
CurrentHousehold,
|
||||
PersonComment,
|
||||
PersonText
|
||||
PersonText,
|
||||
},
|
||||
computed: {
|
||||
...mapState([
|
||||
'concerned'
|
||||
]),
|
||||
...mapState(["concerned"]),
|
||||
...mapGetters([
|
||||
'persons',
|
||||
'concUnpositionned',
|
||||
'positions',
|
||||
'concByPosition',
|
||||
"persons",
|
||||
"concUnpositionned",
|
||||
"positions",
|
||||
"concByPosition",
|
||||
]),
|
||||
allPersonsPositionnated () {
|
||||
return this.$store.getters.persons.length > 0
|
||||
&& this.$store.getters.concUnpositionned.length === 0;
|
||||
allPersonsPositionnated() {
|
||||
return (
|
||||
this.$store.getters.persons.length > 0 &&
|
||||
this.$store.getters.concUnpositionned.length === 0
|
||||
);
|
||||
},
|
||||
allowHolderForConcerned: (app) => (conc) => {
|
||||
console.log('allow holder for concerned', conc);
|
||||
console.log("allow holder for concerned", conc);
|
||||
if (conc.position === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return conc.position.allowHolder;
|
||||
}
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
moveToPosition(person_id, position_id) {
|
||||
this.$store.dispatch('markPosition', { person_id, position_id });
|
||||
this.$store.dispatch("markPosition", { person_id, position_id });
|
||||
},
|
||||
toggleHolder(conc) {
|
||||
console.log('toggle holder', conc);
|
||||
this.$store.dispatch('toggleHolder', conc);
|
||||
}
|
||||
console.log("toggle holder", conc);
|
||||
this.$store.dispatch("toggleHolder", conc);
|
||||
},
|
||||
},
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
.pick-position {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
|
@@ -1,25 +1,25 @@
|
||||
import { createApp } from 'vue';
|
||||
import { _createI18n } from 'ChillMainAssets/vuejs/_js/i18n';
|
||||
import { appMessages } from './js/i18n';
|
||||
import { store } from './store';
|
||||
import 'vue-toast-notification/dist/theme-sugar.css';
|
||||
import ToastPlugin from 'vue-toast-notification';
|
||||
import { createApp } from "vue";
|
||||
import { _createI18n } from "ChillMainAssets/vuejs/_js/i18n";
|
||||
import { appMessages } from "./js/i18n";
|
||||
import { store } from "./store";
|
||||
import "vue-toast-notification/dist/theme-sugar.css";
|
||||
import ToastPlugin from "vue-toast-notification";
|
||||
|
||||
import App from './App.vue';
|
||||
import App from "./App.vue";
|
||||
|
||||
const i18n = _createI18n(appMessages);
|
||||
|
||||
/* exported app */
|
||||
const app = createApp({
|
||||
template: `<app></app>`,
|
||||
template: `<app></app>`,
|
||||
})
|
||||
.use(store)
|
||||
.use(i18n)
|
||||
.use(ToastPlugin, {
|
||||
position: "bottom-right",
|
||||
type: "error",
|
||||
duration: 5000,
|
||||
dismissible: true
|
||||
})
|
||||
.component('app', App)
|
||||
.mount('#household_members_editor');
|
||||
.use(store)
|
||||
.use(i18n)
|
||||
.use(ToastPlugin, {
|
||||
position: "bottom-right",
|
||||
type: "error",
|
||||
duration: 5000,
|
||||
dismissible: true,
|
||||
})
|
||||
.component("app", App)
|
||||
.mount("#household_members_editor");
|
||||
|
@@ -1,23 +1,25 @@
|
||||
|
||||
import { personMessages } from 'ChillPersonAssets/vuejs/_js/i18n';
|
||||
import { ontheflyMessages } from 'ChillMainAssets/vuejs/OnTheFly/i18n';
|
||||
import { addressMessages } from 'ChillMainAssets/vuejs/Address/i18n';
|
||||
import { personMessages } from "ChillPersonAssets/vuejs/_js/i18n";
|
||||
import { ontheflyMessages } from "ChillMainAssets/vuejs/OnTheFly/i18n";
|
||||
import { addressMessages } from "ChillMainAssets/vuejs/Address/i18n";
|
||||
|
||||
const appMessages = {
|
||||
fr: {
|
||||
household_members_editor: {
|
||||
fr: {
|
||||
household_members_editor: {
|
||||
household: {
|
||||
no_household_choose_one: "Aucun ménage de destination. Choisissez un ménage.",
|
||||
// new_household: "Nouveau ménage",
|
||||
no_household_choose_one:
|
||||
"Aucun ménage de destination. Choisissez un ménage.",
|
||||
// new_household: "Nouveau ménage",
|
||||
create_household: "Créer",
|
||||
search_household: "Chercher un ménage",
|
||||
will_leave_any_household: "Les usagers ne rejoignent pas de ménage",
|
||||
leave: "Quitter sans rejoindre un ménage",
|
||||
will_leave_any_household_explanation: "Les usagers quitteront leur ménage actuel, et ne seront pas associés à un autre ménage. Par ailleurs, ils seront enregistrés comme étant sans adresse connue.",
|
||||
will_leave_any_household_explanation:
|
||||
"Les usagers quitteront leur ménage actuel, et ne seront pas associés à un autre ménage. Par ailleurs, ils seront enregistrés comme étant sans adresse connue.",
|
||||
leave_without_household: "Sans nouveau ménage",
|
||||
reset_mode: "Modifier la destination",
|
||||
household_suggested: "Suggestions de ménage",
|
||||
household_suggested_explanation: "Les ménages suivants sont connus et pourraient peut-être correspondre à des ménages recherchés."
|
||||
household_suggested_explanation:
|
||||
"Les ménages suivants sont connus et pourraient peut-être correspondre à des ménages recherchés.",
|
||||
// remove ?
|
||||
/*
|
||||
where_live_the_household: "À quelle adresse habite ce ménage ?",
|
||||
@@ -46,35 +48,39 @@ const appMessages = {
|
||||
move_to: "Déplacer vers",
|
||||
persons_leaving: "Usagers quittant leurs ménages",
|
||||
no_person_in_position: "Aucun usager ne sera ajouté à cette position",
|
||||
persons_with_household: "Les usagers suivants sont associés à ces ménages:",
|
||||
already_belongs_to_household: "est associé au ménage"
|
||||
persons_with_household:
|
||||
"Les usagers suivants sont associés à ces ménages:",
|
||||
already_belongs_to_household: "est associé au ménage",
|
||||
},
|
||||
positioning: {
|
||||
persons_to_positionnate: "Usagers à positionner",
|
||||
holder: "Titulaire",
|
||||
comment: "Commentaire",
|
||||
comment_placeholder: "Associer un commentaire",
|
||||
},
|
||||
positioning: {
|
||||
persons_to_positionnate: 'Usagers à positionner',
|
||||
holder: "Titulaire",
|
||||
comment: "Commentaire",
|
||||
comment_placeholder: "Associer un commentaire",
|
||||
},
|
||||
app: {
|
||||
next: 'Suivant',
|
||||
previous: 'Précédent',
|
||||
cancel: 'Annuler',
|
||||
save: 'Enregistrer',
|
||||
next: "Suivant",
|
||||
previous: "Précédent",
|
||||
cancel: "Annuler",
|
||||
save: "Enregistrer",
|
||||
steps: {
|
||||
concerned: 'Usagers concernés',
|
||||
household: 'Ménage de destination',
|
||||
household_address: 'Adresse du nouveau ménage',
|
||||
positioning: 'Position dans le ménage',
|
||||
confirm: 'Confirmation'
|
||||
}
|
||||
concerned: "Usagers concernés",
|
||||
household: "Ménage de destination",
|
||||
household_address: "Adresse du nouveau ménage",
|
||||
positioning: "Position dans le ménage",
|
||||
confirm: "Confirmation",
|
||||
},
|
||||
},
|
||||
drop_persons_here: "Glissez-déposez ici les usagers pour la position \"{position}\"",
|
||||
drop_persons_here:
|
||||
'Glissez-déposez ici les usagers pour la position "{position}"',
|
||||
all_positionnated: "Tous les usagers sont positionnés",
|
||||
household_part: "Destination",
|
||||
suggestions: "Suggestions",
|
||||
hide_household_suggestion: "Masquer les suggestions",
|
||||
show_household_suggestion: 'Aucune suggestion | Afficher une suggestion | Afficher {count} suggestions',
|
||||
household_for_participants_accompanying_period: "Des ménages partagent le même parcours",
|
||||
show_household_suggestion:
|
||||
"Aucune suggestion | Afficher une suggestion | Afficher {count} suggestions",
|
||||
household_for_participants_accompanying_period:
|
||||
"Des ménages partagent le même parcours",
|
||||
select_household: "Sélectionner le ménage",
|
||||
dates: {
|
||||
start_date: "Début de validité",
|
||||
@@ -91,12 +97,15 @@ const appMessages = {
|
||||
there_are_warnings: "Impossible de valider actuellement",
|
||||
check_those_items: "Veuillez corriger les éléments suivants",
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
Object.assign(appMessages.fr, personMessages.fr, addressMessages.fr, ontheflyMessages.fr);
|
||||
Object.assign(
|
||||
appMessages.fr,
|
||||
personMessages.fr,
|
||||
addressMessages.fr,
|
||||
ontheflyMessages.fr,
|
||||
);
|
||||
|
||||
export {
|
||||
appMessages
|
||||
};
|
||||
export { appMessages };
|
||||
|
@@ -1,13 +1,21 @@
|
||||
import { createStore } from 'vuex';
|
||||
import { householdMove, fetchHouseholdSuggestionByAccompanyingPeriod, fetchAddressSuggestionByPerson} from './../api.js';
|
||||
import { fetchResults } from 'ChillMainAssets/lib/api/apiMethods.ts'
|
||||
import { fetchHouseholdByAddressReference } from 'ChillPersonAssets/lib/household.js';
|
||||
import { datetimeToISO, dateToISO, ISOToDate } from 'ChillMainAssets/chill/js/date';
|
||||
import { createStore } from "vuex";
|
||||
import {
|
||||
householdMove,
|
||||
fetchHouseholdSuggestionByAccompanyingPeriod,
|
||||
fetchAddressSuggestionByPerson,
|
||||
} from "./../api.js";
|
||||
import { fetchResults } from "ChillMainAssets/lib/api/apiMethods.ts";
|
||||
import { fetchHouseholdByAddressReference } from "ChillPersonAssets/lib/household.js";
|
||||
import {
|
||||
datetimeToISO,
|
||||
dateToISO,
|
||||
ISOToDate,
|
||||
} from "ChillMainAssets/chill/js/date";
|
||||
|
||||
const debug = process.env.NODE_ENV !== 'production';
|
||||
const debug = process.env.NODE_ENV !== "production";
|
||||
//console.log('AJAJAJA', window.addaddress);
|
||||
|
||||
const concerned = window.household_members_editor_data.persons.map(p => {
|
||||
const concerned = window.household_members_editor_data.persons.map((p) => {
|
||||
return {
|
||||
person: p,
|
||||
position: null,
|
||||
@@ -23,14 +31,14 @@ const store = createStore({
|
||||
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;
|
||||
}),
|
||||
if (a.ordering < b.ordering) {
|
||||
return -1;
|
||||
}
|
||||
if (a.ordering > b.ordering) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}),
|
||||
startDate: dateToISO(new Date()),
|
||||
/**
|
||||
* Indicates if the destination is:
|
||||
@@ -40,10 +48,16 @@ const store = createStore({
|
||||
* * "leave" => leave without household
|
||||
* * null if not set
|
||||
*/
|
||||
mode: window.household_members_editor_data.household === null ? null : "existing",
|
||||
allowHouseholdCreate: window.household_members_editor_data.allowHouseholdCreate,
|
||||
allowHouseholdSearch: window.household_members_editor_data.allowHouseholdSearch,
|
||||
allowLeaveWithoutHousehold: window.household_members_editor_data.allowLeaveWithoutHousehold,
|
||||
mode:
|
||||
window.household_members_editor_data.household === null
|
||||
? null
|
||||
: "existing",
|
||||
allowHouseholdCreate:
|
||||
window.household_members_editor_data.allowHouseholdCreate,
|
||||
allowHouseholdSearch:
|
||||
window.household_members_editor_data.allowHouseholdSearch,
|
||||
allowLeaveWithoutHousehold:
|
||||
window.household_members_editor_data.allowLeaveWithoutHousehold,
|
||||
forceLeaveWithoutHousehold: false,
|
||||
/**
|
||||
* If true, the user explicitly said that no address is possible
|
||||
@@ -55,14 +69,15 @@ const store = createStore({
|
||||
* (this is not restricted to "suggestion by accompanying periods")
|
||||
*/
|
||||
householdSuggestionByAccompanyingPeriod: [], // TODO rename into householdsSuggestion
|
||||
showHouseholdSuggestion: window.household_members_editor_expand_suggestions === 1,
|
||||
showHouseholdSuggestion:
|
||||
window.household_members_editor_expand_suggestions === 1,
|
||||
householdCompositionType: null,
|
||||
numberOfChildren: 0,
|
||||
addressesSuggestion: [],
|
||||
showAddressSuggestion: true,
|
||||
householdCompositionTypes: [],
|
||||
warnings: [],
|
||||
errors: []
|
||||
errors: [],
|
||||
},
|
||||
getters: {
|
||||
/**
|
||||
@@ -94,8 +109,8 @@ const store = createStore({
|
||||
},
|
||||
getSuggestions(state) {
|
||||
let suggestions = [];
|
||||
state.householdSuggestionByAccompanyingPeriod.forEach(h => {
|
||||
suggestions.push({household: h});
|
||||
state.householdSuggestionByAccompanyingPeriod.forEach((h) => {
|
||||
suggestions.push({ household: h });
|
||||
});
|
||||
|
||||
return suggestions;
|
||||
@@ -114,10 +129,10 @@ const store = createStore({
|
||||
addressId: null,
|
||||
target: {
|
||||
name: state.household.type,
|
||||
id: state.household.id
|
||||
id: state.household.id,
|
||||
},
|
||||
defaults: window.addaddress,
|
||||
suggestions: state.addressesSuggestion
|
||||
suggestions: state.addressesSuggestion,
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
@@ -125,7 +140,7 @@ const store = createStore({
|
||||
addressId: state.household.current_address.id,
|
||||
target: {
|
||||
name: state.household.type,
|
||||
id: state.household.id
|
||||
id: state.household.id,
|
||||
},
|
||||
defaults: window.addaddress,
|
||||
};
|
||||
@@ -154,9 +169,9 @@ const store = createStore({
|
||||
return state.householdSuggestionByAccompanyingPeriod;
|
||||
}
|
||||
|
||||
return state.householdSuggestionByAccompanyingPeriod
|
||||
.filter(h => h.id !== state.household.id)
|
||||
;
|
||||
return state.householdSuggestionByAccompanyingPeriod.filter(
|
||||
(h) => h.id !== state.household.id,
|
||||
);
|
||||
},
|
||||
hasAddressSuggestion(state, getters) {
|
||||
return getters.filterAddressesSuggestion.length > 0;
|
||||
@@ -173,65 +188,61 @@ const store = createStore({
|
||||
return state.addressesSuggestion;
|
||||
}
|
||||
|
||||
return state.addressesSuggestion
|
||||
.filter(a => a.address_id !== state.household.current_address.address_id);
|
||||
return state.addressesSuggestion.filter(
|
||||
(a) => a.address_id !== state.household.current_address.address_id,
|
||||
);
|
||||
},
|
||||
hasPersonsWellPositionnated(state, getters) {
|
||||
return getters.needsPositionning === false
|
||||
|| (getters.persons.length > 0 && getters.concUnpositionned.length === 0);
|
||||
return (
|
||||
getters.needsPositionning === false ||
|
||||
(getters.persons.length > 0 && getters.concUnpositionned.length === 0)
|
||||
);
|
||||
},
|
||||
persons(state) {
|
||||
return state.concerned.map(conc => conc.person);
|
||||
return state.concerned.map((conc) => conc.person);
|
||||
},
|
||||
concUnpositionned(state) {
|
||||
return state.concerned
|
||||
.filter(conc => conc.position === null)
|
||||
;
|
||||
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
|
||||
.filter((conc) =>
|
||||
conc.position !== null ? conc.position.id === position_id : false,
|
||||
)
|
||||
.map(conc => conc.person)
|
||||
;
|
||||
.map((conc) => conc.person);
|
||||
},
|
||||
concByPosition: (state) => (position_id) => {
|
||||
return state.concerned
|
||||
.filter(conc =>
|
||||
conc.position !== null ? conc.position.id === position_id : false
|
||||
)
|
||||
;
|
||||
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)
|
||||
;
|
||||
return state.concerned.find((conc) => conc.person.id === person_id);
|
||||
},
|
||||
needsPositionning(state) {
|
||||
return state.forceLeaveWithoutHousehold === false;
|
||||
},
|
||||
fakeHouseholdWithConcerned(state, getters) {
|
||||
if (null === state.household) {
|
||||
throw Error('cannot create fake household without household');
|
||||
throw Error("cannot create fake household without household");
|
||||
}
|
||||
let h = {
|
||||
type: 'household',
|
||||
members: state.household.members,
|
||||
current_address: state.household.current_address,
|
||||
current_members_id: state.household.current_members_id,
|
||||
new_members: [],
|
||||
};
|
||||
type: "household",
|
||||
members: state.household.members,
|
||||
current_address: state.household.current_address,
|
||||
current_members_id: state.household.current_members_id,
|
||||
new_members: [],
|
||||
};
|
||||
|
||||
if (!getters.isHouseholdNew){
|
||||
if (!getters.isHouseholdNew) {
|
||||
h.id = state.household.id;
|
||||
}
|
||||
|
||||
state.concerned.forEach((c, index) => {
|
||||
if (!(h.members.map((m) => m.person.id)).includes(c.person.id)) {
|
||||
if (!h.members.map((m) => m.person.id).includes(c.person.id)) {
|
||||
let m = {
|
||||
id: index * -1,
|
||||
person: c.person,
|
||||
@@ -240,36 +251,37 @@ const store = createStore({
|
||||
};
|
||||
if (c.position === null) {
|
||||
m.position = {
|
||||
ordering: 999999
|
||||
}
|
||||
ordering: 999999,
|
||||
};
|
||||
}
|
||||
h.new_members.push(m);
|
||||
}
|
||||
});
|
||||
|
||||
})
|
||||
|
||||
console.log('fake household', h);
|
||||
console.log("fake household", h);
|
||||
return h;
|
||||
},
|
||||
buildPayload: (state, getters) => {
|
||||
let
|
||||
conc,
|
||||
let conc,
|
||||
payload_conc,
|
||||
payload = {
|
||||
concerned: [],
|
||||
destination: null,
|
||||
composition: null,
|
||||
}
|
||||
;
|
||||
|
||||
};
|
||||
if (state.forceLeaveWithoutHousehold === false) {
|
||||
payload.destination = {
|
||||
id: state.household.id,
|
||||
type: state.household.type,
|
||||
};
|
||||
id: state.household.id,
|
||||
type: state.household.type,
|
||||
};
|
||||
|
||||
if (getters.isHouseholdNew && state.household.current_address !== null) {
|
||||
payload.destination.forceAddress = { id: state.household.current_address.address_id };
|
||||
if (
|
||||
getters.isHouseholdNew &&
|
||||
state.household.current_address !== null
|
||||
) {
|
||||
payload.destination.forceAddress = {
|
||||
id: state.household.current_address.address_id,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -278,17 +290,20 @@ const store = createStore({
|
||||
payload_conc = {
|
||||
person: {
|
||||
id: conc.person.id,
|
||||
type: conc.person.type
|
||||
type: conc.person.type,
|
||||
},
|
||||
start_date: {
|
||||
datetime: state.startDate === null || state.startDate === '' ? null : datetimeToISO(ISOToDate(state.startDate))
|
||||
}
|
||||
datetime:
|
||||
state.startDate === null || state.startDate === ""
|
||||
? null
|
||||
: datetimeToISO(ISOToDate(state.startDate)),
|
||||
},
|
||||
};
|
||||
|
||||
if (state.forceLeaveWithoutHousehold === false) {
|
||||
payload_conc.position = {
|
||||
id: conc.position.id,
|
||||
type: conc.position.type
|
||||
type: conc.position.type,
|
||||
};
|
||||
payload_conc.holder = conc.holder;
|
||||
payload_conc.comment = conc.comment;
|
||||
@@ -320,7 +335,7 @@ const store = createStore({
|
||||
state.forceLeaveWithoutHousehold = false;
|
||||
},
|
||||
addConcerned(state, person) {
|
||||
let persons = state.concerned.map(conc => conc.person.id);
|
||||
let persons = state.concerned.map((conc) => conc.person.id);
|
||||
if (!persons.includes(person.id)) {
|
||||
state.concerned.push({
|
||||
person,
|
||||
@@ -333,17 +348,16 @@ const store = createStore({
|
||||
console.error("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);
|
||||
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;
|
||||
// reset position if changed:
|
||||
if (!position.allowHolder && conc.holder) {
|
||||
conc.holder = false;
|
||||
}
|
||||
},
|
||||
setComment(state, {conc, comment}) {
|
||||
setComment(state, { conc, comment }) {
|
||||
conc.comment = comment;
|
||||
},
|
||||
toggleHolder(state, conc) {
|
||||
@@ -354,16 +368,16 @@ const store = createStore({
|
||||
conc.position = null;
|
||||
},
|
||||
removePerson(state, person) {
|
||||
state.concerned = state.concerned.filter(c =>
|
||||
c.person.id !== person.id
|
||||
)
|
||||
state.concerned = state.concerned.filter(
|
||||
(c) => c.person.id !== person.id,
|
||||
);
|
||||
},
|
||||
createHousehold(state) {
|
||||
state.household = {
|
||||
type: 'household',
|
||||
type: "household",
|
||||
members: [],
|
||||
current_address: null,
|
||||
current_members_id: []
|
||||
current_members_id: [],
|
||||
};
|
||||
state.mode = "new";
|
||||
state.forceLeaveWithoutHousehold = false;
|
||||
@@ -373,7 +387,7 @@ const store = createStore({
|
||||
state.forceLeaveWithoutHousehold = false;
|
||||
},
|
||||
setHouseholdAddress(state, address) {
|
||||
console.log('setHouseholdAddress commit', address);
|
||||
console.log("setHouseholdAddress commit", address);
|
||||
if (null === state.household) {
|
||||
console.error("no household");
|
||||
throw new Error("No household");
|
||||
@@ -404,8 +418,9 @@ const store = createStore({
|
||||
state.forceLeaveWithoutHousehold = false;
|
||||
},
|
||||
addHouseholdSuggestionByAccompanyingPeriod(state, households) {
|
||||
let existingIds = state.householdSuggestionByAccompanyingPeriod
|
||||
.map(h => h.id);
|
||||
let existingIds = state.householdSuggestionByAccompanyingPeriod.map(
|
||||
(h) => h.id,
|
||||
);
|
||||
for (let i in households) {
|
||||
if (!existingIds.includes(households[i].id)) {
|
||||
state.householdSuggestionByAccompanyingPeriod.push(households[i]);
|
||||
@@ -433,14 +448,15 @@ const store = createStore({
|
||||
state.householdCompositionTypes = types;
|
||||
},
|
||||
setHouseholdCompositionType(state, id) {
|
||||
state.householdCompositionType = state.householdCompositionTypes.find(t => t.id === id);
|
||||
state.householdCompositionType = state.householdCompositionTypes.find(
|
||||
(t) => t.id === id,
|
||||
);
|
||||
},
|
||||
setNumberOfChildren(state, number) {
|
||||
state.numberOfChildren = Number.parseInt(number);
|
||||
},
|
||||
addAddressesSuggestion(state, addresses) {
|
||||
let existingIds = state.addressesSuggestion
|
||||
.map(a => a.address_id);
|
||||
let existingIds = state.addressesSuggestion.map((a) => a.address_id);
|
||||
|
||||
for (let i in addresses) {
|
||||
if (!existingIds.includes(addresses[i].address_id)) {
|
||||
@@ -451,161 +467,175 @@ const store = createStore({
|
||||
},
|
||||
actions: {
|
||||
addConcerned({ commit, dispatch }, person) {
|
||||
commit('addConcerned', person);
|
||||
dispatch('computeWarnings');
|
||||
dispatch('fetchAddressSuggestions');
|
||||
commit("addConcerned", person);
|
||||
dispatch("computeWarnings");
|
||||
dispatch("fetchAddressSuggestions");
|
||||
},
|
||||
markPosition({ commit, dispatch }, { person_id, position_id }) {
|
||||
commit('markPosition', { person_id, position_id });
|
||||
dispatch('computeWarnings');
|
||||
commit("markPosition", { person_id, position_id });
|
||||
dispatch("computeWarnings");
|
||||
},
|
||||
toggleHolder({ commit, dispatch }, conc) {
|
||||
commit('toggleHolder', conc);
|
||||
dispatch('computeWarnings');
|
||||
commit("toggleHolder", conc);
|
||||
dispatch("computeWarnings");
|
||||
},
|
||||
removePosition({ commit, dispatch }, conc) {
|
||||
commit('removePosition', conc);
|
||||
dispatch('computeWarnings');
|
||||
commit("removePosition", conc);
|
||||
dispatch("computeWarnings");
|
||||
},
|
||||
removePerson({ commit, dispatch }, person) {
|
||||
commit('removePerson', person);
|
||||
dispatch('computeWarnings');
|
||||
dispatch('fetchAddressSuggestions');
|
||||
commit("removePerson", person);
|
||||
dispatch("computeWarnings");
|
||||
dispatch("fetchAddressSuggestions");
|
||||
},
|
||||
removeHousehold({ commit, dispatch }) {
|
||||
commit('removeHousehold');
|
||||
dispatch('computeWarnings');
|
||||
commit("removeHousehold");
|
||||
dispatch("computeWarnings");
|
||||
},
|
||||
createHousehold({ commit, dispatch }) {
|
||||
commit('createHousehold');
|
||||
dispatch('computeWarnings');
|
||||
commit("createHousehold");
|
||||
dispatch("computeWarnings");
|
||||
},
|
||||
setHouseholdNewAddress({ commit }, address) {
|
||||
commit('setHouseholdAddress', address);
|
||||
commit("setHouseholdAddress", address);
|
||||
},
|
||||
forceLeaveWithoutHousehold({ commit, dispatch }) {
|
||||
commit('forceLeaveWithoutHousehold');
|
||||
dispatch('computeWarnings');
|
||||
commit("forceLeaveWithoutHousehold");
|
||||
dispatch("computeWarnings");
|
||||
},
|
||||
selectHousehold({ commit, dispatch }, h) {
|
||||
commit('selectHousehold', h);
|
||||
dispatch('computeWarnings');
|
||||
commit("selectHousehold", h);
|
||||
dispatch("computeWarnings");
|
||||
},
|
||||
setStartDate({ commit, dispatch }, date) {
|
||||
commit('setStartDate', date);
|
||||
dispatch('computeWarnings');
|
||||
commit("setStartDate", date);
|
||||
dispatch("computeWarnings");
|
||||
},
|
||||
setComment({ commit }, payload) {
|
||||
commit('setComment', payload);
|
||||
commit("setComment", payload);
|
||||
},
|
||||
setHouseholdCompositionTypes({ commit }, payload) {
|
||||
commit('setHouseholdCompositionTypes', payload);
|
||||
commit("setHouseholdCompositionTypes", payload);
|
||||
},
|
||||
setHouseholdCompositionType({ commit }, payload) {
|
||||
commit('setHouseholdCompositionType', payload);
|
||||
commit("setHouseholdCompositionType", payload);
|
||||
},
|
||||
fetchHouseholdSuggestionForConcerned({ commit }, person) {
|
||||
fetchHouseholdSuggestionByAccompanyingPeriod(person.id)
|
||||
.then(households => {
|
||||
commit('addHouseholdSuggestionByAccompanyingPeriod', households);
|
||||
});
|
||||
fetchHouseholdSuggestionByAccompanyingPeriod(person.id).then(
|
||||
(households) => {
|
||||
commit("addHouseholdSuggestionByAccompanyingPeriod", households);
|
||||
},
|
||||
);
|
||||
},
|
||||
fetchAddressSuggestions({ commit, state, dispatch }) {
|
||||
for (let i in state.concerned) {
|
||||
fetchAddressSuggestionByPerson(state.concerned[i].person.id)
|
||||
.then(addresses => {
|
||||
commit('addAddressesSuggestion', addresses);
|
||||
dispatch('fetchHouseholdSuggestionByAddresses', addresses);
|
||||
.then((addresses) => {
|
||||
commit("addAddressesSuggestion", addresses);
|
||||
dispatch("fetchHouseholdSuggestionByAddresses", addresses);
|
||||
})
|
||||
.catch(e => {
|
||||
.catch((e) => {
|
||||
console.log(e);
|
||||
});
|
||||
}
|
||||
},
|
||||
async fetchHouseholdSuggestionByAddresses({commit}, addresses) {
|
||||
console.log('fetchHouseholdSuggestionByAddresses', addresses);
|
||||
async fetchHouseholdSuggestionByAddresses({ commit }, addresses) {
|
||||
console.log("fetchHouseholdSuggestionByAddresses", addresses);
|
||||
// foreach address, find household suggestions
|
||||
addresses.forEach(async a => {
|
||||
addresses.forEach(async (a) => {
|
||||
if (a.addressReference !== null) {
|
||||
let households = await fetchHouseholdByAddressReference(a.addressReference);
|
||||
commit('addHouseholdSuggestionByAccompanyingPeriod', households);
|
||||
let households = await fetchHouseholdByAddressReference(
|
||||
a.addressReference,
|
||||
);
|
||||
commit("addHouseholdSuggestionByAccompanyingPeriod", households);
|
||||
} else {
|
||||
console.log('not an adresse reference')
|
||||
console.log("not an adresse reference");
|
||||
}
|
||||
});
|
||||
},
|
||||
computeWarnings({ commit, state, getters }) {
|
||||
let warnings = []
|
||||
let warnings = [];
|
||||
|
||||
if (!getters.hasHousehold && !state.forceLeaveWithoutHousehold) {
|
||||
warnings.push({ m: 'household_members_editor.add_destination', a: {} });
|
||||
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: {} });
|
||||
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: {} })
|
||||
if (
|
||||
getters.concUnpositionned.length > 0 &&
|
||||
!state.forceLeaveWithoutHousehold
|
||||
) {
|
||||
warnings.push({
|
||||
m: "household_members_editor.give_a_position_to_every_person",
|
||||
a: {},
|
||||
});
|
||||
}
|
||||
|
||||
commit('setWarnings', warnings);
|
||||
commit("setWarnings", warnings);
|
||||
},
|
||||
confirm({ getters, commit }) {
|
||||
let payload = getters.buildPayload,
|
||||
errors = [],
|
||||
person_id,
|
||||
household_id,
|
||||
error
|
||||
;
|
||||
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;
|
||||
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 !
|
||||
let params = new URLSearchParams(window.location.search);
|
||||
if (params.has('followAfter')) {
|
||||
window.location.replace(`/fr/person/household/${household_id}/summary`);
|
||||
} else {
|
||||
if (params.has('returnPath')) {
|
||||
window.location.replace(params.get('returnPath'));
|
||||
} else {
|
||||
window.location.replace(`/fr/person/household/${household_id}/summary`);
|
||||
}
|
||||
}
|
||||
// nothing to do anymore here, bye-bye !
|
||||
let params = new URLSearchParams(window.location.search);
|
||||
if (params.has("followAfter")) {
|
||||
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);
|
||||
if (params.has("returnPath")) {
|
||||
window.location.replace(params.get("returnPath"));
|
||||
} else {
|
||||
window.location.replace(
|
||||
`/fr/person/household/${household_id}/summary`,
|
||||
);
|
||||
}
|
||||
|
||||
commit('setErrors', errors);
|
||||
}
|
||||
} 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');
|
||||
store.dispatch("computeWarnings");
|
||||
store.dispatch("fetchAddressSuggestions");
|
||||
|
||||
if (concerned.length > 0) {
|
||||
concerned.forEach(c => {
|
||||
store.dispatch('fetchHouseholdSuggestionForConcerned', c.person);
|
||||
concerned.forEach((c) => {
|
||||
store.dispatch("fetchHouseholdSuggestionForConcerned", c.person);
|
||||
});
|
||||
}
|
||||
|
||||
fetchResults(`/api/1.0/person/houehold/composition/type.json`).then(types => {
|
||||
store.dispatch('setHouseholdCompositionTypes', types);
|
||||
})
|
||||
fetchResults(`/api/1.0/person/houehold/composition/type.json`).then((types) => {
|
||||
store.dispatch("setHouseholdCompositionTypes", types);
|
||||
});
|
||||
|
||||
export { store };
|
||||
|
Reference in New Issue
Block a user