mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-11-09 21:58:28 +00:00
Apply prettier rules
This commit is contained in:
@@ -1,60 +1,53 @@
|
||||
<template>
|
||||
<ul
|
||||
class="list-suggest add-items"
|
||||
v-if="suggested.length > 0"
|
||||
>
|
||||
<li
|
||||
v-for="(r, i) in suggested"
|
||||
@click="setReferrer(r)"
|
||||
:key="i"
|
||||
>
|
||||
<ul class="list-suggest add-items" v-if="suggested.length > 0">
|
||||
<li v-for="(r, i) in suggested" @click="setReferrer(r)" :key="i">
|
||||
<span>{{ r.text }}</span>
|
||||
</li>
|
||||
</ul>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
import { makeFetch } from 'ChillMainAssets/lib/api/apiMethods.ts';
|
||||
import { makeFetch } from "ChillMainAssets/lib/api/apiMethods.ts";
|
||||
|
||||
export default {
|
||||
name: "SetReferrer",
|
||||
props: {
|
||||
suggested: {
|
||||
suggested: {
|
||||
type: Array,
|
||||
required: false,
|
||||
//default: [],
|
||||
},
|
||||
periodId: {
|
||||
type: Number,
|
||||
required: true
|
||||
}
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
/*suggested: [
|
||||
{id: 5, text: 'Robert'}, {id: 8, text: 'Monique'},
|
||||
]*/
|
||||
}
|
||||
};
|
||||
},
|
||||
emits: ['referrerSet'],
|
||||
emits: ["referrerSet"],
|
||||
methods: {
|
||||
setReferrer: function(ref) {
|
||||
setReferrer: function (ref) {
|
||||
const url = `/api/1.0/person/accompanying-course/${this.periodId}.json`;
|
||||
const body = { type: "accompanying_period", user: { id: ref.id, type: ref.type }};
|
||||
const body = {
|
||||
type: "accompanying_period",
|
||||
user: { id: ref.id, type: ref.type },
|
||||
};
|
||||
|
||||
return makeFetch('PATCH', url, body)
|
||||
.then((response) => {
|
||||
this.$emit('referrerSet', ref);
|
||||
})
|
||||
.catch((error) => {
|
||||
throw error;
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
return makeFetch("PATCH", url, body)
|
||||
.then((response) => {
|
||||
this.$emit("referrerSet", ref);
|
||||
})
|
||||
.catch((error) => {
|
||||
throw error;
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
<style scoped></style>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
:title="$t(buttonTitle || '')"
|
||||
@click="openModal"
|
||||
>
|
||||
<span v-if="displayTextButton">{{ $t(buttonTitle || '') }}</span>
|
||||
<span v-if="displayTextButton">{{ $t(buttonTitle || "") }}</span>
|
||||
</a>
|
||||
|
||||
<teleport to="body">
|
||||
@@ -23,11 +23,8 @@
|
||||
<template #body-head>
|
||||
<div class="modal-body">
|
||||
<div class="search">
|
||||
<label
|
||||
class="col-form-label"
|
||||
style="float: right;"
|
||||
>
|
||||
{{ $tc('add_persons.suggested_counter', suggestedCounter) }}
|
||||
<label class="col-form-label" style="float: right">
|
||||
{{ $tc("add_persons.suggested_counter", suggestedCounter) }}
|
||||
</label>
|
||||
|
||||
<input
|
||||
@@ -36,7 +33,7 @@
|
||||
v-model="query"
|
||||
:placeholder="$t('add_persons.search_some_persons')"
|
||||
ref="search"
|
||||
>
|
||||
/>
|
||||
<i class="fa fa-search fa-lg" />
|
||||
<i
|
||||
class="fa fa-times"
|
||||
@@ -45,28 +42,19 @@
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="modal-body"
|
||||
v-if="checkUniq === 'checkbox'"
|
||||
>
|
||||
<div class="modal-body" v-if="checkUniq === 'checkbox'">
|
||||
<div class="count">
|
||||
<span>
|
||||
<a
|
||||
v-if="suggestedCounter > 2"
|
||||
@click="selectAll"
|
||||
>
|
||||
{{ $t('action.check_all') }}
|
||||
<a v-if="suggestedCounter > 2" @click="selectAll">
|
||||
{{ $t("action.check_all") }}
|
||||
</a>
|
||||
<a
|
||||
v-if="selectedCounter > 0"
|
||||
@click="resetSelection"
|
||||
>
|
||||
<a v-if="selectedCounter > 0" @click="resetSelection">
|
||||
<i v-if="suggestedCounter > 2"> • </i>
|
||||
{{ $t('action.reset') }}
|
||||
{{ $t("action.reset") }}
|
||||
</a>
|
||||
</span>
|
||||
<span v-if="selectedCounter > 0">
|
||||
{{ $tc('add_persons.selected_counter', selectedCounter) }}
|
||||
{{ $tc("add_persons.selected_counter", selectedCounter) }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -87,8 +75,12 @@
|
||||
|
||||
<div class="create-button">
|
||||
<on-the-fly
|
||||
v-if="queryLength >= 3 && (options.type.includes('person') || options.type.includes('thirdparty'))"
|
||||
:button-text="$t('onthefly.create.button', {q: query})"
|
||||
v-if="
|
||||
queryLength >= 3 &&
|
||||
(options.type.includes('person') ||
|
||||
options.type.includes('thirdparty'))
|
||||
"
|
||||
:button-text="$t('onthefly.create.button', { q: query })"
|
||||
:allowed-types="options.type"
|
||||
:query="query"
|
||||
action="create"
|
||||
@@ -104,7 +96,7 @@
|
||||
class="btn btn-create"
|
||||
@click.prevent="$emit('addNewPersons', { selected, modal })"
|
||||
>
|
||||
{{ $t('action.add') }}
|
||||
{{ $t("action.add") }}
|
||||
</button>
|
||||
</template>
|
||||
</modal>
|
||||
@@ -112,347 +104,372 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Modal from 'ChillMainAssets/vuejs/_components/Modal';
|
||||
import OnTheFly from 'ChillMainAssets/vuejs/OnTheFly/components/OnTheFly.vue';
|
||||
import PersonSuggestion from './AddPersons/PersonSuggestion';
|
||||
import { searchEntities } from 'ChillPersonAssets/vuejs/_api/AddPersons';
|
||||
import { makeFetch } from 'ChillMainAssets/lib/api/apiMethods';
|
||||
import Modal from "ChillMainAssets/vuejs/_components/Modal";
|
||||
import OnTheFly from "ChillMainAssets/vuejs/OnTheFly/components/OnTheFly.vue";
|
||||
import PersonSuggestion from "./AddPersons/PersonSuggestion";
|
||||
import { searchEntities } from "ChillPersonAssets/vuejs/_api/AddPersons";
|
||||
import { makeFetch } from "ChillMainAssets/lib/api/apiMethods";
|
||||
|
||||
export default {
|
||||
name: 'AddPersons',
|
||||
components: {
|
||||
Modal,
|
||||
PersonSuggestion,
|
||||
OnTheFly
|
||||
},
|
||||
props: [
|
||||
'buttonTitle',
|
||||
'modalTitle',
|
||||
'options'
|
||||
],
|
||||
emits: ['addNewPersons'],
|
||||
data() {
|
||||
return {
|
||||
modal: {
|
||||
showModal: false,
|
||||
modalDialogClass: "modal-dialog-scrollable modal-xl"
|
||||
},
|
||||
search: {
|
||||
query: "",
|
||||
previousQuery: "",
|
||||
currentSearchQueryController: null,
|
||||
suggested: [],
|
||||
selected: [],
|
||||
priorSuggestion: {}
|
||||
},
|
||||
name: "AddPersons",
|
||||
components: {
|
||||
Modal,
|
||||
PersonSuggestion,
|
||||
OnTheFly,
|
||||
},
|
||||
props: ["buttonTitle", "modalTitle", "options"],
|
||||
emits: ["addNewPersons"],
|
||||
data() {
|
||||
return {
|
||||
modal: {
|
||||
showModal: false,
|
||||
modalDialogClass: "modal-dialog-scrollable modal-xl",
|
||||
},
|
||||
search: {
|
||||
query: "",
|
||||
previousQuery: "",
|
||||
currentSearchQueryController: null,
|
||||
suggested: [],
|
||||
selected: [],
|
||||
priorSuggestion: {},
|
||||
},
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
query: {
|
||||
set(query) {
|
||||
return this.setQuery(query);
|
||||
},
|
||||
get() {
|
||||
return this.search.query;
|
||||
},
|
||||
},
|
||||
queryLength() {
|
||||
return this.search.query.length;
|
||||
},
|
||||
suggested() {
|
||||
return this.search.suggested;
|
||||
},
|
||||
suggestedCounter() {
|
||||
return this.search.suggested.length;
|
||||
},
|
||||
selected() {
|
||||
return this.search.selected;
|
||||
},
|
||||
selectedCounter() {
|
||||
return this.search.selected.length;
|
||||
},
|
||||
selectedAndSuggested() {
|
||||
this.addPriorSuggestion();
|
||||
const uniqBy = (a, key) => [
|
||||
...new Map(a.map((x) => [key(x), x])).values(),
|
||||
];
|
||||
let union = [
|
||||
...new Set([
|
||||
...this.suggested.slice().reverse(),
|
||||
...this.selected.slice().reverse(),
|
||||
]),
|
||||
];
|
||||
return uniqBy(union, (k) => k.key);
|
||||
},
|
||||
getClassButton() {
|
||||
let size =
|
||||
typeof this.options.button !== "undefined" &&
|
||||
typeof this.options.button.size !== "undefined"
|
||||
? this.options.button.size
|
||||
: "";
|
||||
let type =
|
||||
typeof this.options.button !== "undefined" &&
|
||||
typeof this.options.button.type !== "undefined"
|
||||
? this.options.button.type
|
||||
: "btn-create";
|
||||
return size ? size + " " + type : type;
|
||||
},
|
||||
displayTextButton() {
|
||||
return typeof this.options.button !== "undefined" &&
|
||||
typeof this.options.button.display !== "undefined"
|
||||
? this.options.button.display
|
||||
: true;
|
||||
},
|
||||
checkUniq() {
|
||||
if (this.options.uniq === true) {
|
||||
return "radio";
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
query: {
|
||||
set(query) {
|
||||
return this.setQuery(query);
|
||||
},
|
||||
get() {
|
||||
return this.search.query;
|
||||
}
|
||||
},
|
||||
queryLength() {
|
||||
return this.search.query.length;
|
||||
},
|
||||
suggested() {
|
||||
return this.search.suggested;
|
||||
},
|
||||
suggestedCounter() {
|
||||
return this.search.suggested.length;
|
||||
},
|
||||
selected() {
|
||||
return this.search.selected;
|
||||
},
|
||||
selectedCounter() {
|
||||
return this.search.selected.length;
|
||||
},
|
||||
selectedAndSuggested() {
|
||||
this.addPriorSuggestion();
|
||||
const uniqBy = (a, key) => [
|
||||
...new Map(
|
||||
a.map(x => [key(x), x])
|
||||
).values()
|
||||
];
|
||||
let union = [...new Set([
|
||||
...this.suggested.slice().reverse(),
|
||||
...this.selected.slice().reverse(),
|
||||
])];
|
||||
return uniqBy(union, k => k.key);
|
||||
},
|
||||
getClassButton() {
|
||||
let size = (typeof this.options.button !== 'undefined' && typeof this.options.button.size !== 'undefined') ? this.options.button.size : '';
|
||||
let type = (typeof this.options.button !== 'undefined' && typeof this.options.button.type !== 'undefined') ? this.options.button.type : 'btn-create';
|
||||
return size ? size + ' ' + type : type;
|
||||
},
|
||||
displayTextButton() {
|
||||
return (typeof this.options.button !== 'undefined' && typeof this.options.button.display !== 'undefined') ?
|
||||
this.options.button.display : true;
|
||||
},
|
||||
checkUniq() {
|
||||
if (this.options.uniq === true) {
|
||||
return 'radio';
|
||||
}
|
||||
return 'checkbox';
|
||||
},
|
||||
priorSuggestion() {
|
||||
return this.search.priorSuggestion;
|
||||
},
|
||||
hasPriorSuggestion() {
|
||||
return this.search.priorSuggestion.key ? true : false;
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
openModal() {
|
||||
this.modal.showModal = true;
|
||||
this.$nextTick(function() {
|
||||
this.$refs.search.focus();
|
||||
})
|
||||
},
|
||||
setQuery(query) {
|
||||
this.search.query = query;
|
||||
return "checkbox";
|
||||
},
|
||||
priorSuggestion() {
|
||||
return this.search.priorSuggestion;
|
||||
},
|
||||
hasPriorSuggestion() {
|
||||
return this.search.priorSuggestion.key ? true : false;
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
openModal() {
|
||||
this.modal.showModal = true;
|
||||
this.$nextTick(function () {
|
||||
this.$refs.search.focus();
|
||||
});
|
||||
},
|
||||
setQuery(query) {
|
||||
this.search.query = query;
|
||||
|
||||
setTimeout(function() {
|
||||
if (query === "") {
|
||||
this.loadSuggestions([]);
|
||||
return;
|
||||
setTimeout(
|
||||
function () {
|
||||
if (query === "") {
|
||||
this.loadSuggestions([]);
|
||||
return;
|
||||
}
|
||||
if (query === this.search.query) {
|
||||
if (this.search.currentSearchQueryController !== null) {
|
||||
this.search.currentSearchQueryController.abort();
|
||||
}
|
||||
if (query === this.search.query) {
|
||||
if (this.search.currentSearchQueryController !== null) {
|
||||
this.search.currentSearchQueryController.abort();
|
||||
}
|
||||
this.search.currentSearchQueryController = new AbortController();
|
||||
searchEntities({ query, options: this.options }, this.search.currentSearchQueryController.signal)
|
||||
.then(suggested => new Promise((resolve) => {
|
||||
this.loadSuggestions(suggested.results);
|
||||
resolve();
|
||||
}))
|
||||
.catch(error => {
|
||||
if (error instanceof DOMException) {
|
||||
if (error.name === 'AbortError') {
|
||||
console.log('request aborted due to user continue typing');
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.search.currentSearchQueryController = new AbortController();
|
||||
searchEntities(
|
||||
{ query, options: this.options },
|
||||
this.search.currentSearchQueryController.signal,
|
||||
)
|
||||
.then(
|
||||
(suggested) =>
|
||||
new Promise((resolve) => {
|
||||
this.loadSuggestions(suggested.results);
|
||||
resolve();
|
||||
}),
|
||||
)
|
||||
.catch((error) => {
|
||||
if (error instanceof DOMException) {
|
||||
if (error.name === "AbortError") {
|
||||
console.log("request aborted due to user continue typing");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
throw error;
|
||||
})
|
||||
;
|
||||
}
|
||||
}.bind(this), query.length > 3 ? 300 : 700);
|
||||
},
|
||||
loadSuggestions(suggested) {
|
||||
this.search.suggested = suggested;
|
||||
this.search.suggested.forEach(function(item) {
|
||||
item.key = this.itemKey(item);
|
||||
}, this);
|
||||
},
|
||||
updateSelected(value) {
|
||||
//console.log('value', value);
|
||||
this.search.selected = value;
|
||||
},
|
||||
resetSearch() {
|
||||
this.resetSelection();
|
||||
this.resetSuggestion();
|
||||
},
|
||||
resetSuggestion() {
|
||||
this.search.query = "";
|
||||
this.search.suggested = [];
|
||||
},
|
||||
resetSelection() {
|
||||
this.search.selected = [];
|
||||
},
|
||||
selectAll() {
|
||||
this.search.suggested.forEach(function(item) {
|
||||
this.search.selected.push(item);
|
||||
}, this);
|
||||
},
|
||||
itemKey(item) {
|
||||
return item.result.type + item.result.id;
|
||||
},
|
||||
addPriorSuggestion() {
|
||||
// console.log('prior suggestion', this.priorSuggestion);
|
||||
if (this.hasPriorSuggestion) {
|
||||
// console.log('addPriorSuggestion',);
|
||||
this.suggested.unshift(this.priorSuggestion);
|
||||
this.selected.unshift(this.priorSuggestion);
|
||||
throw error;
|
||||
});
|
||||
}
|
||||
}.bind(this),
|
||||
query.length > 3 ? 300 : 700,
|
||||
);
|
||||
},
|
||||
loadSuggestions(suggested) {
|
||||
this.search.suggested = suggested;
|
||||
this.search.suggested.forEach(function (item) {
|
||||
item.key = this.itemKey(item);
|
||||
}, this);
|
||||
},
|
||||
updateSelected(value) {
|
||||
//console.log('value', value);
|
||||
this.search.selected = value;
|
||||
},
|
||||
resetSearch() {
|
||||
this.resetSelection();
|
||||
this.resetSuggestion();
|
||||
},
|
||||
resetSuggestion() {
|
||||
this.search.query = "";
|
||||
this.search.suggested = [];
|
||||
},
|
||||
resetSelection() {
|
||||
this.search.selected = [];
|
||||
},
|
||||
selectAll() {
|
||||
this.search.suggested.forEach(function (item) {
|
||||
this.search.selected.push(item);
|
||||
}, this);
|
||||
},
|
||||
itemKey(item) {
|
||||
return item.result.type + item.result.id;
|
||||
},
|
||||
addPriorSuggestion() {
|
||||
// console.log('prior suggestion', this.priorSuggestion);
|
||||
if (this.hasPriorSuggestion) {
|
||||
// console.log('addPriorSuggestion',);
|
||||
this.suggested.unshift(this.priorSuggestion);
|
||||
this.selected.unshift(this.priorSuggestion);
|
||||
|
||||
this.newPriorSuggestion(null);
|
||||
}
|
||||
},
|
||||
newPriorSuggestion(entity) {
|
||||
// console.log('newPriorSuggestion', entity);
|
||||
if (entity !== null) {
|
||||
let suggestion = {
|
||||
key: entity.type + entity.id,
|
||||
relevance: 0.5,
|
||||
result: entity
|
||||
}
|
||||
this.search.priorSuggestion = suggestion;
|
||||
// console.log('search priorSuggestion', this.search.priorSuggestion);
|
||||
this.addPriorSuggestion(suggestion);
|
||||
} else {
|
||||
this.search.priorSuggestion = {};
|
||||
}
|
||||
},
|
||||
saveFormOnTheFly({ type, data }) {
|
||||
console.log('saveFormOnTheFly from addPersons, type', type, ', data', data);
|
||||
if (type === 'person') {
|
||||
this.newPriorSuggestion(null);
|
||||
}
|
||||
},
|
||||
newPriorSuggestion(entity) {
|
||||
// console.log('newPriorSuggestion', entity);
|
||||
if (entity !== null) {
|
||||
let suggestion = {
|
||||
key: entity.type + entity.id,
|
||||
relevance: 0.5,
|
||||
result: entity,
|
||||
};
|
||||
this.search.priorSuggestion = suggestion;
|
||||
// console.log('search priorSuggestion', this.search.priorSuggestion);
|
||||
this.addPriorSuggestion(suggestion);
|
||||
} else {
|
||||
this.search.priorSuggestion = {};
|
||||
}
|
||||
},
|
||||
saveFormOnTheFly({ type, data }) {
|
||||
console.log(
|
||||
"saveFormOnTheFly from addPersons, type",
|
||||
type,
|
||||
", data",
|
||||
data,
|
||||
);
|
||||
if (type === "person") {
|
||||
makeFetch("POST", "/api/1.0/person/person.json", data)
|
||||
.then((responsePerson) => {
|
||||
this.newPriorSuggestion(responsePerson);
|
||||
this.$refs.onTheFly.closeModal();
|
||||
|
||||
makeFetch('POST', '/api/1.0/person/person.json', data)
|
||||
.then(responsePerson => {
|
||||
|
||||
this.newPriorSuggestion(responsePerson);
|
||||
this.$refs.onTheFly.closeModal();
|
||||
|
||||
if (null !== data.addressId) {
|
||||
const household = {
|
||||
'type': 'household'
|
||||
};
|
||||
const address = {
|
||||
'id': data.addressId
|
||||
};
|
||||
makeFetch('POST', '/api/1.0/person/household.json', household)
|
||||
.then(responseHousehold => {
|
||||
const member = {
|
||||
'concerned': [
|
||||
{
|
||||
'person': {
|
||||
'type': 'person',
|
||||
'id': responsePerson.id
|
||||
},
|
||||
'start_date': {
|
||||
// TODO: use date.ts methods (low priority)
|
||||
'datetime': `${new Date().toISOString().split('T')[0]}T00:00:00+02:00`
|
||||
},
|
||||
'holder': false,
|
||||
'comment': null
|
||||
}
|
||||
],
|
||||
'destination': {
|
||||
'type': 'household',
|
||||
'id': responseHousehold.id
|
||||
},
|
||||
'composition': null
|
||||
};
|
||||
return makeFetch('POST', '/api/1.0/person/household/members/move.json', member)
|
||||
.then(_response => {
|
||||
makeFetch('POST', `/api/1.0/person/household/${responseHousehold.id}/address.json`, address)
|
||||
.then(_response => {console.log(_response)})
|
||||
.catch((error) => {
|
||||
if (error.name === 'ValidationException') {
|
||||
for (let v of error.violations) {
|
||||
this.$toast.open({message: v });
|
||||
}
|
||||
} else {
|
||||
this.$toast.open({message: 'An error occurred'});
|
||||
}
|
||||
});
|
||||
})
|
||||
.catch((error) => {
|
||||
if (error.name === 'ValidationException') {
|
||||
for (let v of error.violations) {
|
||||
this.$toast.open({message: v });
|
||||
}
|
||||
} else {
|
||||
this.$toast.open({message: 'An error occurred'});
|
||||
}
|
||||
});
|
||||
if (null !== data.addressId) {
|
||||
const household = {
|
||||
type: "household",
|
||||
};
|
||||
const address = {
|
||||
id: data.addressId,
|
||||
};
|
||||
makeFetch("POST", "/api/1.0/person/household.json", household)
|
||||
.then((responseHousehold) => {
|
||||
const member = {
|
||||
concerned: [
|
||||
{
|
||||
person: {
|
||||
type: "person",
|
||||
id: responsePerson.id,
|
||||
},
|
||||
start_date: {
|
||||
// TODO: use date.ts methods (low priority)
|
||||
datetime: `${new Date().toISOString().split("T")[0]}T00:00:00+02:00`,
|
||||
},
|
||||
holder: false,
|
||||
comment: null,
|
||||
},
|
||||
],
|
||||
destination: {
|
||||
type: "household",
|
||||
id: responseHousehold.id,
|
||||
},
|
||||
composition: null,
|
||||
};
|
||||
return makeFetch(
|
||||
"POST",
|
||||
"/api/1.0/person/household/members/move.json",
|
||||
member,
|
||||
)
|
||||
.then((_response) => {
|
||||
makeFetch(
|
||||
"POST",
|
||||
`/api/1.0/person/household/${responseHousehold.id}/address.json`,
|
||||
address,
|
||||
)
|
||||
.then((_response) => {
|
||||
console.log(_response);
|
||||
})
|
||||
.catch((error) => {
|
||||
if (error.name === 'ValidationException') {
|
||||
for (let v of error.violations) {
|
||||
this.$toast.open({message: v });
|
||||
}
|
||||
} else {
|
||||
this.$toast.open({message: 'An error occurred'});
|
||||
}
|
||||
if (error.name === "ValidationException") {
|
||||
for (let v of error.violations) {
|
||||
this.$toast.open({ message: v });
|
||||
}
|
||||
} else {
|
||||
this.$toast.open({ message: "An error occurred" });
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
if (error.name === 'ValidationException') {
|
||||
for (let v of error.violations) {
|
||||
this.$toast.open({message: v });
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
if (error.name === "ValidationException") {
|
||||
for (let v of error.violations) {
|
||||
this.$toast.open({ message: v });
|
||||
}
|
||||
} else {
|
||||
this.$toast.open({ message: "An error occurred" });
|
||||
}
|
||||
});
|
||||
})
|
||||
.catch((error) => {
|
||||
if (error.name === "ValidationException") {
|
||||
for (let v of error.violations) {
|
||||
this.$toast.open({ message: v });
|
||||
}
|
||||
} else {
|
||||
this.$toast.open({message: 'An error occurred'});
|
||||
this.$toast.open({ message: "An error occurred" });
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
else if (type === 'thirdparty') {
|
||||
makeFetch('POST', '/api/1.0/thirdparty/thirdparty.json', data)
|
||||
.then(response => {
|
||||
this.newPriorSuggestion(response);
|
||||
this.$refs.onTheFly.closeModal();
|
||||
})
|
||||
.catch((error) => {
|
||||
if (error.name === 'ValidationException') {
|
||||
for (let v of error.violations) {
|
||||
this.$toast.open({message: v });
|
||||
}
|
||||
} else {
|
||||
this.$toast.open({message: 'An error occurred'});
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
if (error.name === "ValidationException") {
|
||||
for (let v of error.violations) {
|
||||
this.$toast.open({ message: v });
|
||||
}
|
||||
} else {
|
||||
this.$toast.open({ message: "An error occurred" });
|
||||
}
|
||||
});
|
||||
} else if (type === "thirdparty") {
|
||||
makeFetch("POST", "/api/1.0/thirdparty/thirdparty.json", data)
|
||||
.then((response) => {
|
||||
this.newPriorSuggestion(response);
|
||||
this.$refs.onTheFly.closeModal();
|
||||
})
|
||||
.catch((error) => {
|
||||
if (error.name === "ValidationException") {
|
||||
for (let v of error.violations) {
|
||||
this.$toast.open({ message: v });
|
||||
}
|
||||
} else {
|
||||
this.$toast.open({ message: "An error occurred" });
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
li.add-persons {
|
||||
a {
|
||||
cursor: pointer;
|
||||
li.add-persons {
|
||||
a {
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
div.body-head {
|
||||
overflow-y: unset;
|
||||
div.modal-body:first-child {
|
||||
margin: auto 4em;
|
||||
div.search {
|
||||
position: relative;
|
||||
input {
|
||||
width: 100%;
|
||||
padding: 1.2em 1.5em 1.2em 2.5em;
|
||||
//margin: 1em 0;
|
||||
}
|
||||
}
|
||||
div.body-head {
|
||||
overflow-y: unset;
|
||||
div.modal-body:first-child {
|
||||
margin: auto 4em;
|
||||
div.search {
|
||||
position: relative;
|
||||
input {
|
||||
width: 100%;
|
||||
padding: 1.2em 1.5em 1.2em 2.5em;
|
||||
//margin: 1em 0;
|
||||
}
|
||||
i {
|
||||
position: absolute;
|
||||
opacity: 0.5;
|
||||
padding: 0.65em 0;
|
||||
top: 50%;
|
||||
}
|
||||
i.fa-search {
|
||||
left: 0.5em;
|
||||
}
|
||||
i.fa-times {
|
||||
right: 1em;
|
||||
padding: 0.75em 0;
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
i {
|
||||
position: absolute;
|
||||
opacity: 0.5;
|
||||
padding: 0.65em 0;
|
||||
top: 50%;
|
||||
}
|
||||
div.modal-body:last-child {
|
||||
padding-bottom: 0;
|
||||
i.fa-search {
|
||||
left: 0.5em;
|
||||
}
|
||||
div.count {
|
||||
margin: -0.5em 0 0.7em;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
a {
|
||||
cursor: pointer;
|
||||
}
|
||||
i.fa-times {
|
||||
right: 1em;
|
||||
padding: 0.75em 0;
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
.create-button > a {
|
||||
margin-top: 0.5em;
|
||||
margin-left: 2.6em;
|
||||
}
|
||||
}
|
||||
}
|
||||
div.modal-body:last-child {
|
||||
padding-bottom: 0;
|
||||
}
|
||||
div.count {
|
||||
margin: -0.5em 0 0.7em;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
a {
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
}
|
||||
.create-button > a {
|
||||
margin-top: 0.5em;
|
||||
margin-left: 2.6em;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
<template>
|
||||
<div
|
||||
class="list-item"
|
||||
:class="{ checked: isChecked }"
|
||||
>
|
||||
<div class="list-item" :class="{ checked: isChecked }">
|
||||
<label>
|
||||
<div>
|
||||
<input
|
||||
@@ -11,13 +8,10 @@
|
||||
name="item"
|
||||
:id="item"
|
||||
:value="setValueByType(item, type)"
|
||||
>
|
||||
/>
|
||||
</div>
|
||||
|
||||
<suggestion-person
|
||||
v-if="item.result.type === 'person'"
|
||||
:item="item"
|
||||
/>
|
||||
<suggestion-person v-if="item.result.type === 'person'" :item="item" />
|
||||
|
||||
<suggestion-third-party
|
||||
v-if="item.result.type === 'thirdparty'"
|
||||
@@ -25,10 +19,7 @@
|
||||
:item="item"
|
||||
/>
|
||||
|
||||
<suggestion-user
|
||||
v-if="item.result.type === 'user'"
|
||||
:item="item"
|
||||
/>
|
||||
<suggestion-user v-if="item.result.type === 'user'" :item="item" />
|
||||
|
||||
<suggestion-household
|
||||
v-if="item.result.type === 'household'"
|
||||
@@ -39,90 +30,86 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import SuggestionPerson from './TypePerson';
|
||||
import SuggestionThirdParty from './TypeThirdParty';
|
||||
import SuggestionUser from './TypeUser';
|
||||
import SuggestionHousehold from './TypeHousehold';
|
||||
import SuggestionPerson from "./TypePerson";
|
||||
import SuggestionThirdParty from "./TypeThirdParty";
|
||||
import SuggestionUser from "./TypeUser";
|
||||
import SuggestionHousehold from "./TypeHousehold";
|
||||
|
||||
export default {
|
||||
name: 'PersonSuggestion',
|
||||
components: {
|
||||
SuggestionPerson,
|
||||
SuggestionThirdParty,
|
||||
SuggestionUser,
|
||||
SuggestionHousehold,
|
||||
},
|
||||
props: [
|
||||
'item',
|
||||
'search',
|
||||
'type'
|
||||
],
|
||||
emits: ['updateSelected', 'newPriorSuggestion'],
|
||||
computed: {
|
||||
selected: {
|
||||
set(value) {
|
||||
//console.log('value', value);
|
||||
this.$emit('updateSelected', value);
|
||||
},
|
||||
get() {
|
||||
return this.search.selected;
|
||||
}
|
||||
name: "PersonSuggestion",
|
||||
components: {
|
||||
SuggestionPerson,
|
||||
SuggestionThirdParty,
|
||||
SuggestionUser,
|
||||
SuggestionHousehold,
|
||||
},
|
||||
props: ["item", "search", "type"],
|
||||
emits: ["updateSelected", "newPriorSuggestion"],
|
||||
computed: {
|
||||
selected: {
|
||||
set(value) {
|
||||
//console.log('value', value);
|
||||
this.$emit("updateSelected", value);
|
||||
},
|
||||
isChecked() {
|
||||
return (this.search.selected.indexOf(this.item) === -1) ? false : true;
|
||||
get() {
|
||||
return this.search.selected;
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
setValueByType(value, type) {
|
||||
return (type === 'radio')? [value] : value;
|
||||
},
|
||||
newPriorSuggestion(response) {
|
||||
this.$emit('newPriorSuggestion', response)
|
||||
}
|
||||
}
|
||||
},
|
||||
isChecked() {
|
||||
return this.search.selected.indexOf(this.item) === -1 ? false : true;
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
setValueByType(value, type) {
|
||||
return type === "radio" ? [value] : value;
|
||||
},
|
||||
newPriorSuggestion(response) {
|
||||
this.$emit("newPriorSuggestion", response);
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
div.results {
|
||||
div.list-item {
|
||||
padding: 0.4em 0.8em;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
&.checked {
|
||||
background-color: #ececec;
|
||||
border-bottom: 1px dotted #8b8b8b;
|
||||
}
|
||||
label {
|
||||
display: inline-flex;
|
||||
width: 100%;
|
||||
div.container:not(.household) {
|
||||
& > input {
|
||||
margin-right: 0.8em;
|
||||
}
|
||||
> span:not(.name) {
|
||||
margin-left: 0.5em;
|
||||
opacity: 0.5;
|
||||
font-size: 90%;
|
||||
font-style: italic;
|
||||
}
|
||||
}
|
||||
div.right_actions {
|
||||
margin: 0 0 0 auto;
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
& > * {
|
||||
margin-left: 0.5em;
|
||||
align-self: baseline;
|
||||
}
|
||||
|
||||
a.btn {
|
||||
border: 1px solid lightgrey;
|
||||
font-size: 70%;
|
||||
padding: 4px;
|
||||
}
|
||||
}
|
||||
}
|
||||
div.results {
|
||||
div.list-item {
|
||||
padding: 0.4em 0.8em;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
&.checked {
|
||||
background-color: #ececec;
|
||||
border-bottom: 1px dotted #8b8b8b;
|
||||
}
|
||||
label {
|
||||
display: inline-flex;
|
||||
width: 100%;
|
||||
div.container:not(.household) {
|
||||
& > input {
|
||||
margin-right: 0.8em;
|
||||
}
|
||||
> span:not(.name) {
|
||||
margin-left: 0.5em;
|
||||
opacity: 0.5;
|
||||
font-size: 90%;
|
||||
font-style: italic;
|
||||
}
|
||||
}
|
||||
}
|
||||
div.right_actions {
|
||||
margin: 0 0 0 auto;
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
& > * {
|
||||
margin-left: 0.5em;
|
||||
align-self: baseline;
|
||||
}
|
||||
|
||||
a.btn {
|
||||
border: 1px solid lightgrey;
|
||||
font-size: 70%;
|
||||
padding: 4px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -7,24 +7,20 @@
|
||||
</div>
|
||||
|
||||
<div class="right_actions">
|
||||
<badge-entity
|
||||
:entity="item.result"
|
||||
:options="{ displayLong: true }"
|
||||
/>
|
||||
<badge-entity :entity="item.result" :options="{ displayLong: true }" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
import BadgeEntity from 'ChillMainAssets/vuejs/_components/BadgeEntity.vue';
|
||||
import HouseholdRenderBox from 'ChillPersonAssets/vuejs/_components/Entity/HouseholdRenderBox.vue';
|
||||
import BadgeEntity from "ChillMainAssets/vuejs/_components/BadgeEntity.vue";
|
||||
import HouseholdRenderBox from "ChillPersonAssets/vuejs/_components/Entity/HouseholdRenderBox.vue";
|
||||
|
||||
export default {
|
||||
name: 'SuggestionHousehold',
|
||||
components: {
|
||||
BadgeEntity,
|
||||
HouseholdRenderBox,
|
||||
},
|
||||
props: ['item'],
|
||||
}
|
||||
name: "SuggestionHousehold",
|
||||
components: {
|
||||
BadgeEntity,
|
||||
HouseholdRenderBox,
|
||||
},
|
||||
props: ["item"],
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -3,54 +3,41 @@
|
||||
<span class="name">
|
||||
<person-text :person="item.result" />
|
||||
</span>
|
||||
<span
|
||||
class="birthday"
|
||||
v-if="hasBirthdate"
|
||||
>
|
||||
{{ $d(item.result.birthdate.datetime, 'short') }}
|
||||
<span class="birthday" v-if="hasBirthdate">
|
||||
{{ $d(item.result.birthdate.datetime, "short") }}
|
||||
</span>
|
||||
<span
|
||||
class="location"
|
||||
v-if="hasAddress"
|
||||
>
|
||||
<span class="location" v-if="hasAddress">
|
||||
{{ item.result.current_household_address.text }} -
|
||||
{{ item.result.current_household_address.postcode.name }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="right_actions">
|
||||
<badge-entity
|
||||
:entity="item.result"
|
||||
:options="{ displayLong: true }"
|
||||
/>
|
||||
<on-the-fly
|
||||
type="person"
|
||||
:id="item.result.id"
|
||||
action="show"
|
||||
/>
|
||||
<badge-entity :entity="item.result" :options="{ displayLong: true }" />
|
||||
<on-the-fly type="person" :id="item.result.id" action="show" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import OnTheFly from 'ChillMainAssets/vuejs/OnTheFly/components/OnTheFly.vue';
|
||||
import BadgeEntity from 'ChillMainAssets/vuejs/_components/BadgeEntity.vue';
|
||||
import PersonText from 'ChillPersonAssets/vuejs/_components/Entity/PersonText.vue';
|
||||
import OnTheFly from "ChillMainAssets/vuejs/OnTheFly/components/OnTheFly.vue";
|
||||
import BadgeEntity from "ChillMainAssets/vuejs/_components/BadgeEntity.vue";
|
||||
import PersonText from "ChillPersonAssets/vuejs/_components/Entity/PersonText.vue";
|
||||
|
||||
export default {
|
||||
name: 'SuggestionPerson',
|
||||
components: {
|
||||
OnTheFly,
|
||||
BadgeEntity,
|
||||
PersonText,
|
||||
},
|
||||
props: ['item'],
|
||||
computed: {
|
||||
hasBirthdate() {
|
||||
return this.item.result.birthdate !== null;
|
||||
},
|
||||
hasAddress() {
|
||||
return this.item.result.current_household_address !== null;
|
||||
}
|
||||
}
|
||||
}
|
||||
name: "SuggestionPerson",
|
||||
components: {
|
||||
OnTheFly,
|
||||
BadgeEntity,
|
||||
PersonText,
|
||||
},
|
||||
props: ["item"],
|
||||
computed: {
|
||||
hasBirthdate() {
|
||||
return this.item.result.birthdate !== null;
|
||||
},
|
||||
hasAddress() {
|
||||
return this.item.result.current_household_address !== null;
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
<template>
|
||||
<div class="container tpartycontainer">
|
||||
<div class="tparty-identification">
|
||||
<span
|
||||
v-if="item.result.profession"
|
||||
class="profession"
|
||||
>{{ item.result.profession }}</span>
|
||||
<span class="name">
|
||||
{{ item.result.text }}
|
||||
</span>
|
||||
<span v-if="item.result.profession" class="profession">{{
|
||||
item.result.profession
|
||||
}}</span>
|
||||
<span class="name"> {{ item.result.text }} </span>
|
||||
<span class="location">
|
||||
<template v-if="hasAddress">
|
||||
{{ getAddress.text }} -
|
||||
@@ -15,21 +12,13 @@
|
||||
</template>
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="tpartyparent"
|
||||
v-if="hasParent"
|
||||
>
|
||||
<span class="name">
|
||||
> {{ item.result.parent.text }}
|
||||
</span>
|
||||
<div class="tpartyparent" v-if="hasParent">
|
||||
<span class="name"> > {{ item.result.parent.text }} </span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="right_actions">
|
||||
<badge-entity
|
||||
:entity="item.result"
|
||||
:options="{ displayLong: true }"
|
||||
/>
|
||||
<badge-entity :entity="item.result" :options="{ displayLong: true }" />
|
||||
<on-the-fly
|
||||
v-if="item.result.kind === 'company'"
|
||||
:parent="item.result"
|
||||
@@ -37,18 +26,14 @@
|
||||
action="addContact"
|
||||
ref="onTheFly"
|
||||
/>
|
||||
<on-the-fly
|
||||
type="thirdparty"
|
||||
:id="item.result.id"
|
||||
action="show"
|
||||
/>
|
||||
<on-the-fly type="thirdparty" :id="item.result.id" action="show" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import OnTheFly from 'ChillMainAssets/vuejs/OnTheFly/components/OnTheFly.vue';
|
||||
import BadgeEntity from 'ChillMainAssets/vuejs/_components/BadgeEntity.vue';
|
||||
import { makeFetch } from 'ChillMainAssets/lib/api/apiMethods';
|
||||
import OnTheFly from "ChillMainAssets/vuejs/OnTheFly/components/OnTheFly.vue";
|
||||
import BadgeEntity from "ChillMainAssets/vuejs/_components/BadgeEntity.vue";
|
||||
import { makeFetch } from "ChillMainAssets/lib/api/apiMethods";
|
||||
|
||||
const i18n = {
|
||||
messages: {
|
||||
@@ -56,20 +41,20 @@ const i18n = {
|
||||
thirdparty: {
|
||||
contact: "Personne physique",
|
||||
company: "Personne morale",
|
||||
child: "Personne de contact"
|
||||
}
|
||||
}
|
||||
}
|
||||
child: "Personne de contact",
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default {
|
||||
name: 'SuggestionThirdParty',
|
||||
name: "SuggestionThirdParty",
|
||||
components: {
|
||||
OnTheFly,
|
||||
BadgeEntity
|
||||
BadgeEntity,
|
||||
},
|
||||
props: ['item'],
|
||||
emits: ['newPriorSuggestion'],
|
||||
props: ["item"],
|
||||
emits: ["newPriorSuggestion"],
|
||||
i18n,
|
||||
computed: {
|
||||
hasAddress() {
|
||||
@@ -79,7 +64,7 @@ export default {
|
||||
if (this.$props.item.result.parent !== null) {
|
||||
return this.$props.item.result.parent.address !== null;
|
||||
}
|
||||
return false
|
||||
return false;
|
||||
},
|
||||
hasParent() {
|
||||
return this.$props.item.result.parent !== null;
|
||||
@@ -93,37 +78,36 @@ export default {
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
saveFormOnTheFly({data}) {
|
||||
makeFetch('POST', '/api/1.0/thirdparty/thirdparty.json', data)
|
||||
.then(response => {
|
||||
this.$emit('newPriorSuggestion', response);
|
||||
this.$refs.onTheFly.closeModal();
|
||||
saveFormOnTheFly({ data }) {
|
||||
makeFetch("POST", "/api/1.0/thirdparty/thirdparty.json", data)
|
||||
.then((response) => {
|
||||
this.$emit("newPriorSuggestion", response);
|
||||
this.$refs.onTheFly.closeModal();
|
||||
})
|
||||
.catch((error) => {
|
||||
if (error.name === 'ValidationException') {
|
||||
for (let v of error.violations) {
|
||||
this.$toast.open({message: v });
|
||||
}
|
||||
} else {
|
||||
this.$toast.open({message: 'An error occurred'});
|
||||
if (error.name === "ValidationException") {
|
||||
for (let v of error.violations) {
|
||||
this.$toast.open({ message: v });
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.$toast.open({ message: "An error occurred" });
|
||||
}
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.tpartycontainer {
|
||||
.tpartyparent {
|
||||
.name {
|
||||
font-weight: bold;
|
||||
font-variant: all-small-caps;
|
||||
}
|
||||
.name {
|
||||
font-weight: bold;
|
||||
font-variant: all-small-caps;
|
||||
}
|
||||
}
|
||||
.tparty-identification {
|
||||
span:not(.name) {
|
||||
|
||||
@@ -5,39 +5,36 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="right_actions">
|
||||
<badge-entity
|
||||
:entity="item.result"
|
||||
:options="{ displayLong: true }"
|
||||
/>
|
||||
<badge-entity :entity="item.result" :options="{ displayLong: true }" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import BadgeEntity from 'ChillMainAssets/vuejs/_components/BadgeEntity.vue';
|
||||
import UserRenderBoxBadge from 'ChillMainAssets/vuejs/_components/Entity/UserRenderBoxBadge.vue';
|
||||
import BadgeEntity from "ChillMainAssets/vuejs/_components/BadgeEntity.vue";
|
||||
import UserRenderBoxBadge from "ChillMainAssets/vuejs/_components/Entity/UserRenderBoxBadge.vue";
|
||||
|
||||
export default {
|
||||
name: 'SuggestionUser',
|
||||
components: {
|
||||
UserRenderBoxBadge,
|
||||
BadgeEntity
|
||||
},
|
||||
props: ['item'],
|
||||
computed: {
|
||||
hasParent() {
|
||||
return this.$props.item.result.parent !== null;
|
||||
},
|
||||
}
|
||||
}
|
||||
name: "SuggestionUser",
|
||||
components: {
|
||||
UserRenderBoxBadge,
|
||||
BadgeEntity,
|
||||
},
|
||||
props: ["item"],
|
||||
computed: {
|
||||
hasParent() {
|
||||
return this.$props.item.result.parent !== null;
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.usercontainer {
|
||||
.userparent {
|
||||
.userparent {
|
||||
.name {
|
||||
font-weight: bold;
|
||||
font-variant: all-small-caps;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -3,19 +3,13 @@
|
||||
<div class="item-row">
|
||||
<div class="item-col">
|
||||
<!-- identifier -->
|
||||
<div
|
||||
v-if="isHouseholdNew()"
|
||||
class="h4"
|
||||
>
|
||||
<div v-if="isHouseholdNew()" class="h4">
|
||||
<i class="fa fa-home" />
|
||||
{{ $t('new_household') }}
|
||||
{{ $t("new_household") }}
|
||||
</div>
|
||||
<div
|
||||
v-else
|
||||
class="h4"
|
||||
>
|
||||
<div v-else class="h4">
|
||||
<i class="fa fa-home" />
|
||||
{{ $t('household_number', { number: household.id } ) }}
|
||||
{{ $t("household_number", { number: household.id }) }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="item-col">
|
||||
@@ -30,32 +24,27 @@
|
||||
v-for="m in currentMembers()"
|
||||
:key="m.id"
|
||||
class="m"
|
||||
:class="{ is_new: m.is_new === true}"
|
||||
:class="{ is_new: m.is_new === true }"
|
||||
>
|
||||
<person-render-box
|
||||
render="badge"
|
||||
:person="m.person"
|
||||
:options="{
|
||||
isHolder: m.holder,
|
||||
addLink: true
|
||||
addLink: true,
|
||||
}"
|
||||
>
|
||||
<template
|
||||
#post-badge
|
||||
v-if="m.is_new === true"
|
||||
>
|
||||
<span class="post-badge is_new"><i class="fa fa-sign-in" /></span>
|
||||
<template #post-badge v-if="m.is_new === true">
|
||||
<span class="post-badge is_new"
|
||||
><i class="fa fa-sign-in"
|
||||
/></span>
|
||||
</template>
|
||||
</person-render-box>
|
||||
</span>
|
||||
</li>
|
||||
<li
|
||||
v-else
|
||||
class="members"
|
||||
:title="$t('current_members')"
|
||||
>
|
||||
<li v-else class="members" :title="$t('current_members')">
|
||||
<p class="chill-no-data-statement">
|
||||
{{ $t('no_members_yet') }}
|
||||
{{ $t("no_members_yet") }}
|
||||
</p>
|
||||
</li>
|
||||
|
||||
@@ -67,7 +56,9 @@
|
||||
/>
|
||||
</li>
|
||||
<li v-else>
|
||||
<span class="chill-no-data-statement">{{ $t('no_current_address') }}</span>
|
||||
<span class="chill-no-data-statement">{{
|
||||
$t("no_current_address")
|
||||
}}</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
@@ -76,43 +67,45 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import PersonRenderBox from 'ChillPersonAssets/vuejs/_components/Entity/PersonRenderBox.vue';
|
||||
import AddressRenderBox from 'ChillMainAssets/vuejs/_components/Entity/AddressRenderBox.vue';
|
||||
import PersonRenderBox from "ChillPersonAssets/vuejs/_components/Entity/PersonRenderBox.vue";
|
||||
import AddressRenderBox from "ChillMainAssets/vuejs/_components/Entity/AddressRenderBox.vue";
|
||||
|
||||
const i18n = {
|
||||
"messages": {
|
||||
"fr": {
|
||||
"household_number": "Ménage n°{number}",
|
||||
"current_members": "Membres actuels",
|
||||
"no_current_address": "Sans adresse actuellement",
|
||||
"new_household": "Nouveau ménage",
|
||||
"no_members_yet": "Aucun membre actuellement",
|
||||
"holder": "titulaire",
|
||||
}
|
||||
}
|
||||
messages: {
|
||||
fr: {
|
||||
household_number: "Ménage n°{number}",
|
||||
current_members: "Membres actuels",
|
||||
no_current_address: "Sans adresse actuellement",
|
||||
new_household: "Nouveau ménage",
|
||||
no_members_yet: "Aucun membre actuellement",
|
||||
holder: "titulaire",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default {
|
||||
name: 'HouseholdRenderBox',
|
||||
props: ['household', 'isAddressMultiline'],
|
||||
name: "HouseholdRenderBox",
|
||||
props: ["household", "isAddressMultiline"],
|
||||
components: {
|
||||
PersonRenderBox,
|
||||
AddressRenderBox,
|
||||
},
|
||||
i18n,
|
||||
computed: {
|
||||
isMultiline() {
|
||||
return (typeof this.isAddressMultiline !== 'undefined') ? this.isAddressMultiline : false;
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
isMultiline() {
|
||||
return typeof this.isAddressMultiline !== "undefined"
|
||||
? this.isAddressMultiline
|
||||
: false;
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
hasCurrentMembers() {
|
||||
return this.household.current_members_id.length > 0;
|
||||
},
|
||||
currentMembers() {
|
||||
let members = this.household.members.filter(m => this.household.current_members_id.includes(m.id))
|
||||
let members = this.household.members
|
||||
.filter((m) => this.household.current_members_id.includes(m.id))
|
||||
.sort((a, b) => {
|
||||
|
||||
const orderA = a.position ? a.position.ordering : 0;
|
||||
const orderB = b.position ? b.position.ordering : 0;
|
||||
|
||||
@@ -132,12 +125,14 @@ export default {
|
||||
});
|
||||
|
||||
if (this.household.new_members !== undefined) {
|
||||
this.household.new_members.map(m => {
|
||||
m.is_new = true;
|
||||
return m;
|
||||
}).forEach(m => {
|
||||
members.push(m);
|
||||
});
|
||||
this.household.new_members
|
||||
.map((m) => {
|
||||
m.is_new = true;
|
||||
return m;
|
||||
})
|
||||
.forEach((m) => {
|
||||
members.push(m);
|
||||
});
|
||||
}
|
||||
|
||||
return members;
|
||||
@@ -150,27 +145,24 @@ export default {
|
||||
},
|
||||
hasAddress() {
|
||||
return this.household.current_address !== null;
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
|
||||
section.chill-entity {
|
||||
&.entity-household {
|
||||
&.entity-household {
|
||||
ul.list-content li::marker {
|
||||
content: "";
|
||||
}
|
||||
|
||||
ul.list-content li::marker {
|
||||
content: '';
|
||||
.members {
|
||||
.post-badge.is_new {
|
||||
margin-left: 0.5rem;
|
||||
color: var(--bs-chill-green);
|
||||
}
|
||||
|
||||
.members {
|
||||
.post-badge.is_new {
|
||||
margin-left: 0.5rem;
|
||||
color: var(--bs-chill-green);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,55 +1,49 @@
|
||||
<template>
|
||||
<div
|
||||
v-if="render === 'bloc'"
|
||||
class="item-bloc"
|
||||
>
|
||||
<div v-if="render === 'bloc'" class="item-bloc">
|
||||
<section class="chill-entity entity-person">
|
||||
<div class="item-row entity-bloc">
|
||||
<div class="item-col">
|
||||
<div class="entity-label">
|
||||
<div :class="'denomination h' + options.hLevel">
|
||||
<a
|
||||
v-if="options.addLink === true"
|
||||
:href="getUrl"
|
||||
>
|
||||
<a v-if="options.addLink === true" :href="getUrl">
|
||||
<!-- use person-text here to avoid code duplication ? TODO -->
|
||||
<span class="firstname">{{ person.firstName }}</span>
|
||||
<span class="lastname">{{ person.lastName }}</span>
|
||||
<span
|
||||
v-if="person.suffixText"
|
||||
class="suffixtext"
|
||||
> {{ person.suffixText }}</span>
|
||||
<span v-if="person.suffixText" class="suffixtext"
|
||||
> {{ person.suffixText }}</span
|
||||
>
|
||||
<span
|
||||
v-if="person.altNames && options.addAltNames == true"
|
||||
class="altnames"
|
||||
>
|
||||
<span :class="'altname altname-' + altNameKey">{{ altNameLabel }}</span>
|
||||
<span :class="'altname altname-' + altNameKey">{{
|
||||
altNameLabel
|
||||
}}</span>
|
||||
</span>
|
||||
</a>
|
||||
|
||||
<!-- use person-text here to avoid code duplication ? TODO -->
|
||||
<span class="firstname">{{ person.firstName }}</span>
|
||||
<span class="lastname">{{ person.lastName }}</span>
|
||||
<span
|
||||
v-if="person.suffixText"
|
||||
class="suffixtext"
|
||||
> {{ person.suffixText }}</span>
|
||||
<span
|
||||
v-if="person.deathdate"
|
||||
class="deathdate"
|
||||
> (‡)</span>
|
||||
<span v-if="person.suffixText" class="suffixtext"
|
||||
> {{ person.suffixText }}</span
|
||||
>
|
||||
<span v-if="person.deathdate" class="deathdate"> (‡)</span>
|
||||
<span
|
||||
v-if="person.altNames && options.addAltNames == true"
|
||||
class="altnames"
|
||||
>
|
||||
<span :class="'altname altname-' + altNameKey">{{ altNameLabel }}</span>
|
||||
<span :class="'altname altname-' + altNameKey">{{
|
||||
altNameLabel
|
||||
}}</span>
|
||||
</span>
|
||||
|
||||
<span
|
||||
v-if="options.addId == true"
|
||||
class="id-number"
|
||||
:title="'n° ' + person.id"
|
||||
>{{ person.id }}</span>
|
||||
>{{ person.id }}</span
|
||||
>
|
||||
|
||||
<badge-entity
|
||||
v-if="options.addEntity === true"
|
||||
@@ -58,10 +52,7 @@
|
||||
/>
|
||||
</div>
|
||||
|
||||
<p
|
||||
v-if="options.addInfo === true"
|
||||
class="moreinfo"
|
||||
>
|
||||
<p v-if="options.addInfo === true" class="moreinfo">
|
||||
<gender-icon-render-box
|
||||
v-if="person.gender"
|
||||
:gender="person.gender"
|
||||
@@ -71,7 +62,15 @@
|
||||
:datetime="person.birthdate"
|
||||
:title="birthdate"
|
||||
>
|
||||
{{ $t(person.gender ? `renderbox.birthday.${person.gender.genderTranslation}` : 'renderbox.birthday.neutral') + ' ' + $d(birthdate, 'text') }}
|
||||
{{
|
||||
$t(
|
||||
person.gender
|
||||
? `renderbox.birthday.${person.gender.genderTranslation}`
|
||||
: "renderbox.birthday.neutral",
|
||||
) +
|
||||
" " +
|
||||
$d(birthdate, "text")
|
||||
}}
|
||||
</time>
|
||||
|
||||
<time
|
||||
@@ -87,14 +86,11 @@
|
||||
:datetime="person.deathdate"
|
||||
:title="person.deathdate"
|
||||
>
|
||||
{{ $t('renderbox.deathdate') + ' ' + deathdate }}
|
||||
{{ $t("renderbox.deathdate") + " " + deathdate }}
|
||||
</time>
|
||||
|
||||
<span
|
||||
v-if="options.addAge && person.birthdate"
|
||||
class="age"
|
||||
>{{
|
||||
$tc('renderbox.years_old', person.age)
|
||||
<span v-if="options.addAge && person.birthdate" class="age">{{
|
||||
$tc("renderbox.years_old", person.age)
|
||||
}}</span>
|
||||
</p>
|
||||
</div>
|
||||
@@ -114,48 +110,56 @@
|
||||
:address="person.current_household_address"
|
||||
:is-multiline="isMultiline"
|
||||
/>
|
||||
<p
|
||||
v-else
|
||||
class="chill-no-data-statement"
|
||||
>
|
||||
{{ $t('renderbox.household_without_address') }}
|
||||
<p v-else class="chill-no-data-statement">
|
||||
{{ $t("renderbox.household_without_address") }}
|
||||
</p>
|
||||
<a
|
||||
v-if="options.addHouseholdLink === true"
|
||||
:href="getCurrentHouseholdUrl"
|
||||
:title="$t('persons_associated.show_household_number', {id: person.current_household_id})"
|
||||
:title="
|
||||
$t('persons_associated.show_household_number', {
|
||||
id: person.current_household_id,
|
||||
})
|
||||
"
|
||||
>
|
||||
<span class="badge rounded-pill bg-chill-beige">
|
||||
<i class="fa fa-fw fa-home" /><!--{{ $t('persons_associated.show_household') }}-->
|
||||
<i
|
||||
class="fa fa-fw fa-home"
|
||||
/><!--{{ $t('persons_associated.show_household') }}-->
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
<li v-else-if="options.addNoData">
|
||||
<i class="fa fa-li fa-map-marker" /><p class="chill-no-data-statement">
|
||||
{{ $t('renderbox.no_data') }}
|
||||
<i class="fa fa-li fa-map-marker" />
|
||||
<p class="chill-no-data-statement">
|
||||
{{ $t("renderbox.no_data") }}
|
||||
</p>
|
||||
</li>
|
||||
|
||||
<template v-if="this.showResidentialAddresses && (person.current_residential_addresses || []).length > 0">
|
||||
<template
|
||||
v-if="
|
||||
this.showResidentialAddresses &&
|
||||
(person.current_residential_addresses || []).length > 0
|
||||
"
|
||||
>
|
||||
<li
|
||||
v-for="(addr, i) in person.current_residential_addresses"
|
||||
:key="i"
|
||||
>
|
||||
<i class="fa fa-li fa-map-marker" />
|
||||
<div v-if="addr.address">
|
||||
<span class="item-key">{{ $t('renderbox.residential_address') }}:</span>
|
||||
<div style="margin-top: -1em;">
|
||||
<span class="item-key"
|
||||
>{{ $t("renderbox.residential_address") }}:</span
|
||||
>
|
||||
<div style="margin-top: -1em">
|
||||
<address-render-box
|
||||
:address="addr.address"
|
||||
:is-multiline="isMultiline"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-else-if="addr.hostPerson"
|
||||
class="mt-3"
|
||||
>
|
||||
<p>{{ $t('renderbox.located_at') }}:</p>
|
||||
<div v-else-if="addr.hostPerson" class="mt-3">
|
||||
<p>{{ $t("renderbox.located_at") }}:</p>
|
||||
<span class="chill-entity entity-person badge-person">
|
||||
<person-text
|
||||
v-if="addr.hostPerson"
|
||||
@@ -168,11 +172,8 @@
|
||||
:is-multiline="isMultiline"
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
v-else-if="addr.hostThirdParty"
|
||||
class="mt-3"
|
||||
>
|
||||
<p>{{ $t('renderbox.located_at') }}:</p>
|
||||
<div v-else-if="addr.hostThirdParty" class="mt-3">
|
||||
<p>{{ $t("renderbox.located_at") }}:</p>
|
||||
<span class="chill-entity entity-person badge-thirdparty">
|
||||
<third-party-text
|
||||
v-if="addr.hostThirdParty"
|
||||
@@ -195,32 +196,42 @@
|
||||
<li v-else-if="options.addNoData">
|
||||
<i class="fa fa-li fa-envelope-o" />
|
||||
<p class="chill-no-data-statement">
|
||||
{{ $t('renderbox.no_data') }}
|
||||
{{ $t("renderbox.no_data") }}
|
||||
</p>
|
||||
</li>
|
||||
|
||||
<li v-if="person.mobilenumber">
|
||||
<i class="fa fa-li fa-mobile" />
|
||||
<a :href="'tel: ' + person.mobilenumber">{{ person.mobilenumber }}</a>
|
||||
<a :href="'tel: ' + person.mobilenumber">{{
|
||||
person.mobilenumber
|
||||
}}</a>
|
||||
</li>
|
||||
<li v-else-if="options.addNoData">
|
||||
<i class="fa fa-li fa-mobile" />
|
||||
<p class="chill-no-data-statement">
|
||||
{{ $t('renderbox.no_data') }}
|
||||
{{ $t("renderbox.no_data") }}
|
||||
</p>
|
||||
</li>
|
||||
<li v-if="person.phonenumber">
|
||||
<i class="fa fa-li fa-phone" />
|
||||
<a :href="'tel: ' + person.phonenumber">{{ person.phonenumber }}</a>
|
||||
<a :href="'tel: ' + person.phonenumber">{{
|
||||
person.phonenumber
|
||||
}}</a>
|
||||
</li>
|
||||
<li v-else-if="options.addNoData">
|
||||
<i class="fa fa-li fa-phone" />
|
||||
<p class="chill-no-data-statement">
|
||||
{{ $t('renderbox.no_data') }}
|
||||
{{ $t("renderbox.no_data") }}
|
||||
</p>
|
||||
</li>
|
||||
|
||||
<li v-if="person.centers !== undefined && person.centers.length > 0 && options.addCenter">
|
||||
<li
|
||||
v-if="
|
||||
person.centers !== undefined &&
|
||||
person.centers.length > 0 &&
|
||||
options.addCenter
|
||||
"
|
||||
>
|
||||
<i class="fa fa-li fa-long-arrow-right" />
|
||||
<template v-for="c in person.centers">
|
||||
{{ c.name }}
|
||||
@@ -229,7 +240,7 @@
|
||||
<li v-else-if="options.addNoData">
|
||||
<i class="fa fa-li fa-long-arrow-right" />
|
||||
<p class="chill-no-data-statement">
|
||||
{{ $t('renderbox.no_data') }}
|
||||
{{ $t("renderbox.no_data") }}
|
||||
</p>
|
||||
</li>
|
||||
<slot name="custom-zone" />
|
||||
@@ -247,10 +258,7 @@
|
||||
v-if="render === 'badge'"
|
||||
class="chill-entity entity-person badge-person"
|
||||
>
|
||||
<a
|
||||
v-if="options.addLink === true"
|
||||
:href="getUrl"
|
||||
>
|
||||
<a v-if="options.addLink === true" :href="getUrl">
|
||||
<span
|
||||
v-if="options.isHolder"
|
||||
class="fa-stack fa-holder"
|
||||
@@ -278,12 +286,12 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {ISOToDate} from 'ChillMainAssets/chill/js/date';
|
||||
import AddressRenderBox from 'ChillMainAssets/vuejs/_components/Entity/AddressRenderBox.vue';
|
||||
import GenderIconRenderBox from 'ChillMainAssets/vuejs/_components/Entity/GenderIconRenderBox.vue'
|
||||
import BadgeEntity from 'ChillMainAssets/vuejs/_components/BadgeEntity.vue';
|
||||
import PersonText from 'ChillPersonAssets/vuejs/_components/Entity/PersonText.vue';
|
||||
import ThirdPartyText from 'ChillThirdPartyAssets/vuejs/_components/Entity/ThirdPartyText.vue';
|
||||
import { ISOToDate } from "ChillMainAssets/chill/js/date";
|
||||
import AddressRenderBox from "ChillMainAssets/vuejs/_components/Entity/AddressRenderBox.vue";
|
||||
import GenderIconRenderBox from "ChillMainAssets/vuejs/_components/Entity/GenderIconRenderBox.vue";
|
||||
import BadgeEntity from "ChillMainAssets/vuejs/_components/BadgeEntity.vue";
|
||||
import PersonText from "ChillPersonAssets/vuejs/_components/Entity/PersonText.vue";
|
||||
import ThirdPartyText from "ChillThirdPartyAssets/vuejs/_components/Entity/ThirdPartyText.vue";
|
||||
|
||||
export default {
|
||||
name: "PersonRenderBox",
|
||||
@@ -292,7 +300,7 @@ export default {
|
||||
GenderIconRenderBox,
|
||||
BadgeEntity,
|
||||
PersonText,
|
||||
ThirdPartyText
|
||||
ThirdPartyText,
|
||||
},
|
||||
props: {
|
||||
person: {
|
||||
@@ -311,55 +319,62 @@ export default {
|
||||
showResidentialAddresses: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
}
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
isMultiline: function () {
|
||||
if (this.options.isMultiline) {
|
||||
return this.options.isMultiline
|
||||
return this.options.isMultiline;
|
||||
} else {
|
||||
return false
|
||||
return false;
|
||||
}
|
||||
},
|
||||
birthdate: function () {
|
||||
if (this.person.birthdate !== null || this.person.birthdate === "undefined") {
|
||||
if (
|
||||
this.person.birthdate !== null ||
|
||||
this.person.birthdate === "undefined"
|
||||
) {
|
||||
return ISOToDate(this.person.birthdate.datetime);
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
},
|
||||
deathdate: function () {
|
||||
if (this.person.deathdate !== null || this.person.birthdate === "undefined") {
|
||||
if (
|
||||
this.person.deathdate !== null ||
|
||||
this.person.birthdate === "undefined"
|
||||
) {
|
||||
return new Date(this.person.deathdate.datetime);
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
},
|
||||
altNameLabel: function () {
|
||||
let altNameLabel = ''
|
||||
this.person.altNames.forEach(altName => altNameLabel += altName.label)
|
||||
return altNameLabel
|
||||
let altNameLabel = "";
|
||||
this.person.altNames.forEach(
|
||||
(altName) => (altNameLabel += altName.label),
|
||||
);
|
||||
return altNameLabel;
|
||||
},
|
||||
altNameKey: function () {
|
||||
let altNameKey = ''
|
||||
this.person.altNames.forEach(altName => altNameKey += altName.key)
|
||||
return altNameKey
|
||||
let altNameKey = "";
|
||||
this.person.altNames.forEach((altName) => (altNameKey += altName.key));
|
||||
return altNameKey;
|
||||
},
|
||||
getUrl: function () {
|
||||
return `/fr/person/${this.person.id}/general`;
|
||||
},
|
||||
getCurrentHouseholdUrl: function () {
|
||||
let returnPath = this.returnPath ? `?returnPath=${this.returnPath}` : ``;
|
||||
return `/fr/person/household/${this.person.current_household_id}/summary${returnPath}`
|
||||
}
|
||||
}
|
||||
}
|
||||
return `/fr/person/household/${this.person.current_household_id}/summary${returnPath}`;
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang='scss'>
|
||||
|
||||
<style lang="scss">
|
||||
.lastname:before {
|
||||
content: " "
|
||||
content: " ";
|
||||
}
|
||||
|
||||
div.flex-table {
|
||||
@@ -371,7 +386,6 @@ div.flex-table {
|
||||
|
||||
div.item-col:last-child {
|
||||
justify-content: flex-start;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -381,13 +395,11 @@ div.flex-table {
|
||||
margin-left: 0.5em;
|
||||
|
||||
&:before {
|
||||
content: '(';
|
||||
content: "(";
|
||||
}
|
||||
|
||||
&:after {
|
||||
content: ')';
|
||||
content: ")";
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
|
||||
@@ -1,63 +1,62 @@
|
||||
<template>
|
||||
<span v-if="isCut">{{ cutText }}</span>
|
||||
<span
|
||||
v-else
|
||||
class="person-text"
|
||||
>
|
||||
<span v-else class="person-text">
|
||||
<span class="firstname">{{ person.firstName }}</span>
|
||||
<span class="lastname">{{ person.lastName }}</span>
|
||||
<span
|
||||
v-if="person.altNames && person.altNames.length > 0"
|
||||
class="altnames"
|
||||
>
|
||||
<span :class="'altname altname-' + altNameKey"> ({{ altNameLabel }})</span>
|
||||
<span v-if="person.altNames && person.altNames.length > 0" class="altnames">
|
||||
<span :class="'altname altname-' + altNameKey">
|
||||
({{ altNameLabel }})</span
|
||||
>
|
||||
</span>
|
||||
<span
|
||||
v-if="person.suffixText"
|
||||
class="suffixtext"
|
||||
> {{ person.suffixText }}</span>
|
||||
<span v-if="person.suffixText" class="suffixtext"
|
||||
> {{ person.suffixText }}</span
|
||||
>
|
||||
<span
|
||||
class="age"
|
||||
v-if="this.addAge && person.birthdate !== null && person.deathdate === null"
|
||||
>{{ $tc('renderbox.years_old', person.age) }}</span>
|
||||
v-if="
|
||||
this.addAge && person.birthdate !== null && person.deathdate === null
|
||||
"
|
||||
>{{ $tc("renderbox.years_old", person.age) }}</span
|
||||
>
|
||||
<span v-else-if="this.addAge && person.deathdate !== null"> (‡)</span>
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
export default {
|
||||
name: "PersonText",
|
||||
props: {
|
||||
person: {
|
||||
required: true,
|
||||
},
|
||||
isCut: {
|
||||
type: Boolean,
|
||||
required: false,
|
||||
default: false
|
||||
},
|
||||
addAge: {
|
||||
type: Boolean,
|
||||
required: false,
|
||||
default: true,
|
||||
}
|
||||
name: "PersonText",
|
||||
props: {
|
||||
person: {
|
||||
required: true,
|
||||
},
|
||||
computed: {
|
||||
altNameLabel: function() {
|
||||
let altNameLabel = ''
|
||||
this.person.altNames.forEach(altName => altNameLabel += altName.label)
|
||||
return altNameLabel
|
||||
},
|
||||
altNameKey: function() {
|
||||
let altNameKey = ''
|
||||
this.person.altNames.forEach(altName => altNameKey += altName.key)
|
||||
return altNameKey
|
||||
},
|
||||
cutText: function() {
|
||||
let more = (this.person.text.length > 15) ?'…' : '';
|
||||
return this.person.text.slice(0,15) + more;
|
||||
}
|
||||
}
|
||||
}
|
||||
isCut: {
|
||||
type: Boolean,
|
||||
required: false,
|
||||
default: false,
|
||||
},
|
||||
addAge: {
|
||||
type: Boolean,
|
||||
required: false,
|
||||
default: true,
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
altNameLabel: function () {
|
||||
let altNameLabel = "";
|
||||
this.person.altNames.forEach(
|
||||
(altName) => (altNameLabel += altName.label),
|
||||
);
|
||||
return altNameLabel;
|
||||
},
|
||||
altNameKey: function () {
|
||||
let altNameKey = "";
|
||||
this.person.altNames.forEach((altName) => (altNameKey += altName.key));
|
||||
return altNameKey;
|
||||
},
|
||||
cutText: function () {
|
||||
let more = this.person.text.length > 15 ? "…" : "";
|
||||
return this.person.text.slice(0, 15) + more;
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
hLevel: 3,
|
||||
addCenter: true,
|
||||
addNoData: true,
|
||||
isMultiline: true
|
||||
isMultiline: true,
|
||||
}"
|
||||
:show-residential-addresses="true"
|
||||
/>
|
||||
@@ -29,8 +29,8 @@
|
||||
v-model="lastName"
|
||||
:placeholder="$t('person.lastname')"
|
||||
@change="checkErrors"
|
||||
>
|
||||
<label for="lastname">{{ $t('person.lastname') }}</label>
|
||||
/>
|
||||
<label for="lastname">{{ $t("person.lastname") }}</label>
|
||||
</div>
|
||||
|
||||
<div v-if="queryItems">
|
||||
@@ -52,8 +52,8 @@
|
||||
v-model="firstName"
|
||||
:placeholder="$t('person.firstname')"
|
||||
@change="checkErrors"
|
||||
>
|
||||
<label for="firstname">{{ $t('person.firstname') }}</label>
|
||||
/>
|
||||
<label for="firstname">{{ $t("person.firstname") }}</label>
|
||||
</div>
|
||||
|
||||
<div v-if="queryItems">
|
||||
@@ -78,59 +78,37 @@
|
||||
:id="a.key"
|
||||
:value="personAltNamesLabels[i]"
|
||||
@input="onAltNameInput"
|
||||
>
|
||||
/>
|
||||
<label :for="a.key">{{ a.labels.fr }}</label>
|
||||
</div>
|
||||
|
||||
<!-- TODO fix placeholder if undefined
|
||||
-->
|
||||
<div class="form-floating mb-3">
|
||||
<select
|
||||
class="form-select form-select-lg"
|
||||
id="gender"
|
||||
v-model="gender"
|
||||
>
|
||||
<option
|
||||
selected
|
||||
disabled
|
||||
>
|
||||
{{ $t('person.gender.placeholder') }}
|
||||
<select class="form-select form-select-lg" id="gender" v-model="gender">
|
||||
<option selected disabled>
|
||||
{{ $t("person.gender.placeholder") }}
|
||||
</option>
|
||||
<option
|
||||
v-for="g in config.genders"
|
||||
:value="g.id"
|
||||
:key="g.id"
|
||||
>
|
||||
<option v-for="g in config.genders" :value="g.id" :key="g.id">
|
||||
{{ g.label.fr }}
|
||||
</option>
|
||||
</select>
|
||||
<label>{{ $t('person.gender.title') }}</label>
|
||||
<label>{{ $t("person.gender.title") }}</label>
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="form-floating mb-3"
|
||||
v-if="showCenters && config.centers.length > 1"
|
||||
>
|
||||
<select
|
||||
class="form-select form-select-lg"
|
||||
id="center"
|
||||
v-model="center"
|
||||
>
|
||||
<option
|
||||
selected
|
||||
disabled
|
||||
>
|
||||
{{ $t('person.center.placeholder') }}
|
||||
<select class="form-select form-select-lg" id="center" v-model="center">
|
||||
<option selected disabled>
|
||||
{{ $t("person.center.placeholder") }}
|
||||
</option>
|
||||
<option
|
||||
v-for="c in config.centers"
|
||||
:value="c"
|
||||
:key="c.id"
|
||||
>
|
||||
<option v-for="c in config.centers" :value="c" :key="c.id">
|
||||
{{ c.name }}
|
||||
</option>
|
||||
</select>
|
||||
<label>{{ $t('person.center.title') }}</label>
|
||||
<label>{{ $t("person.center.title") }}</label>
|
||||
</div>
|
||||
|
||||
<div class="form-floating mb-3">
|
||||
@@ -139,28 +117,20 @@
|
||||
id="civility"
|
||||
v-model="civility"
|
||||
>
|
||||
<option
|
||||
selected
|
||||
disabled
|
||||
>
|
||||
{{ $t('person.civility.placeholder') }}
|
||||
<option selected disabled>
|
||||
{{ $t("person.civility.placeholder") }}
|
||||
</option>
|
||||
<option
|
||||
v-for="c in config.civilities"
|
||||
:value="c.id"
|
||||
:key="c.id"
|
||||
>
|
||||
<option v-for="c in config.civilities" :value="c.id" :key="c.id">
|
||||
{{ c.name.fr }}
|
||||
</option>
|
||||
</select>
|
||||
<label>{{ $t('person.civility.title') }}</label>
|
||||
<label>{{ $t("person.civility.title") }}</label>
|
||||
</div>
|
||||
|
||||
<div class="input-group mb-3">
|
||||
<span
|
||||
class="input-group-text"
|
||||
id="birthdate"
|
||||
><i class="fa fa-fw fa-birthday-cake" /></span>
|
||||
<span class="input-group-text" id="birthdate"
|
||||
><i class="fa fa-fw fa-birthday-cake"
|
||||
/></span>
|
||||
<input
|
||||
type="date"
|
||||
class="form-control form-control-lg"
|
||||
@@ -168,68 +138,64 @@
|
||||
name="chill_personbundle_person[birthdate]"
|
||||
v-model="birthDate"
|
||||
aria-describedby="birthdate"
|
||||
>
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="input-group mb-3">
|
||||
<span
|
||||
class="input-group-text"
|
||||
id="phonenumber"
|
||||
><i class="fa fa-fw fa-phone" /></span>
|
||||
<span class="input-group-text" id="phonenumber"
|
||||
><i class="fa fa-fw fa-phone"
|
||||
/></span>
|
||||
<input
|
||||
class="form-control form-control-lg"
|
||||
v-model="phonenumber"
|
||||
:placeholder="$t('person.phonenumber')"
|
||||
:aria-label="$t('person.phonenumber')"
|
||||
aria-describedby="phonenumber"
|
||||
>
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="input-group mb-3">
|
||||
<span
|
||||
class="input-group-text"
|
||||
id="mobilenumber"
|
||||
><i class="fa fa-fw fa-mobile" /></span>
|
||||
<span class="input-group-text" id="mobilenumber"
|
||||
><i class="fa fa-fw fa-mobile"
|
||||
/></span>
|
||||
<input
|
||||
class="form-control form-control-lg"
|
||||
v-model="mobilenumber"
|
||||
:placeholder="$t('person.mobilenumber')"
|
||||
:aria-label="$t('person.mobilenumber')"
|
||||
aria-describedby="mobilenumber"
|
||||
>
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="input-group mb-3">
|
||||
<span
|
||||
class="input-group-text"
|
||||
id="email"
|
||||
><i class="fa fa-fw fa-at" /></span>
|
||||
<span class="input-group-text" id="email"
|
||||
><i class="fa fa-fw fa-at"
|
||||
/></span>
|
||||
<input
|
||||
class="form-control form-control-lg"
|
||||
v-model="email"
|
||||
:placeholder="$t('person.email')"
|
||||
:aria-label="$t('person.email')"
|
||||
aria-describedby="email"
|
||||
>
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="action === 'create'"
|
||||
class="input-group mb-3 form-check"
|
||||
>
|
||||
<div v-if="action === 'create'" class="input-group mb-3 form-check">
|
||||
<input
|
||||
class="form-check-input"
|
||||
type="checkbox"
|
||||
v-model="showAddressForm"
|
||||
name="showAddressForm"
|
||||
>
|
||||
<label class="form-check-label">{{ $t('person.address.show_address_form') }}</label>
|
||||
/>
|
||||
<label class="form-check-label">{{
|
||||
$t("person.address.show_address_form")
|
||||
}}</label>
|
||||
</div>
|
||||
<div
|
||||
v-if="action === 'create' && showAddressFormValue"
|
||||
class="form-floating mb-3"
|
||||
>
|
||||
<p>{{ $t('person.address.warning') }}</p>
|
||||
<p>{{ $t("person.address.warning") }}</p>
|
||||
<add-address
|
||||
:context="addAddress.context"
|
||||
:options="addAddress.options"
|
||||
@@ -238,16 +204,9 @@
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
||||
<div
|
||||
class="alert alert-warning"
|
||||
v-if="errors.length"
|
||||
>
|
||||
<div class="alert alert-warning" v-if="errors.length">
|
||||
<ul>
|
||||
<li
|
||||
v-for="(e, i) in errors"
|
||||
:key="i"
|
||||
>
|
||||
<li v-for="(e, i) in errors" :key="i">
|
||||
{{ e }}
|
||||
</li>
|
||||
</ul>
|
||||
@@ -256,253 +215,293 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getCentersForPersonCreation, getCivilities, getGenders, getPerson, getPersonAltNames } from '../../_api/OnTheFly';
|
||||
import PersonRenderBox from '../Entity/PersonRenderBox.vue';
|
||||
import {
|
||||
getCentersForPersonCreation,
|
||||
getCivilities,
|
||||
getGenders,
|
||||
getPerson,
|
||||
getPersonAltNames,
|
||||
} from "../../_api/OnTheFly";
|
||||
import PersonRenderBox from "../Entity/PersonRenderBox.vue";
|
||||
import AddAddress from "ChillMainAssets/vuejs/Address/components/AddAddress.vue";
|
||||
|
||||
export default {
|
||||
name: "OnTheFlyPerson",
|
||||
props: ['id', 'type', 'action', 'query'],
|
||||
//emits: ['createAction'],
|
||||
components: {
|
||||
PersonRenderBox,
|
||||
AddAddress
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
person: {
|
||||
type: 'person',
|
||||
lastName: '',
|
||||
firstName: '',
|
||||
altNames: [],
|
||||
addressId: null,
|
||||
center: null,
|
||||
},
|
||||
config: {
|
||||
altNames: [],
|
||||
civilities: [],
|
||||
centers: [],
|
||||
genders: []
|
||||
},
|
||||
showCenters: false, // NOTE: must remains false if the form is not in create mode
|
||||
showAddressFormValue: false,
|
||||
addAddress: {
|
||||
options: {
|
||||
button: {
|
||||
text: { create: 'person.address.create_address' },
|
||||
size: 'btn-sm'
|
||||
},
|
||||
title: { create: 'person.address.create_address' },
|
||||
},
|
||||
context: {
|
||||
target: {}, // boilerplate for getting the address id
|
||||
edit: false,
|
||||
addressId: null,
|
||||
defaults: window.addaddress
|
||||
}
|
||||
},
|
||||
errors: []
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
firstName: {
|
||||
set(value) {
|
||||
this.person.firstName = value;
|
||||
},
|
||||
get() { return this.person.firstName; }
|
||||
name: "OnTheFlyPerson",
|
||||
props: ["id", "type", "action", "query"],
|
||||
//emits: ['createAction'],
|
||||
components: {
|
||||
PersonRenderBox,
|
||||
AddAddress,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
person: {
|
||||
type: "person",
|
||||
lastName: "",
|
||||
firstName: "",
|
||||
altNames: [],
|
||||
addressId: null,
|
||||
center: null,
|
||||
},
|
||||
lastName: {
|
||||
set(value) { this.person.lastName = value; },
|
||||
get() { return this.person.lastName; }
|
||||
config: {
|
||||
altNames: [],
|
||||
civilities: [],
|
||||
centers: [],
|
||||
genders: [],
|
||||
},
|
||||
gender: {
|
||||
set(value) { this.person.gender = {id: value, type: 'chill_main_gender'}; },
|
||||
get() { return this.person.gender ? this.person.gender.id : null; }
|
||||
showCenters: false, // NOTE: must remains false if the form is not in create mode
|
||||
showAddressFormValue: false,
|
||||
addAddress: {
|
||||
options: {
|
||||
button: {
|
||||
text: { create: "person.address.create_address" },
|
||||
size: "btn-sm",
|
||||
},
|
||||
title: { create: "person.address.create_address" },
|
||||
},
|
||||
context: {
|
||||
target: {}, // boilerplate for getting the address id
|
||||
edit: false,
|
||||
addressId: null,
|
||||
defaults: window.addaddress,
|
||||
},
|
||||
},
|
||||
civility: {
|
||||
set(value) { this.person.civility = {id: value, type: 'chill_main_civility'}; },
|
||||
get() { return this.person.civility ? this.person.civility.id : null; }
|
||||
errors: [],
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
firstName: {
|
||||
set(value) {
|
||||
this.person.firstName = value;
|
||||
},
|
||||
birthDate: {
|
||||
set(value) {
|
||||
if (this.person.birthdate) {
|
||||
this.person.birthdate.datetime = value + "T00:00:00+0100";
|
||||
} else {
|
||||
this.person.birthdate = { datetime: value + "T00:00:00+0100"};
|
||||
}
|
||||
},
|
||||
get() {
|
||||
return (this.person.birthdate) ? this.person.birthdate.datetime.split('T')[0] : '';
|
||||
}
|
||||
get() {
|
||||
return this.person.firstName;
|
||||
},
|
||||
phonenumber: {
|
||||
set(value) { this.person.phonenumber = value; },
|
||||
get() { return this.person.phonenumber; }
|
||||
},
|
||||
lastName: {
|
||||
set(value) {
|
||||
this.person.lastName = value;
|
||||
},
|
||||
mobilenumber: {
|
||||
set(value) { this.person.mobilenumber = value; },
|
||||
get() { return this.person.mobilenumber; }
|
||||
get() {
|
||||
return this.person.lastName;
|
||||
},
|
||||
email: {
|
||||
set(value) { this.person.email = value; },
|
||||
get() { return this.person.email; }
|
||||
},
|
||||
gender: {
|
||||
set(value) {
|
||||
this.person.gender = { id: value, type: "chill_main_gender" };
|
||||
},
|
||||
showAddressForm: {
|
||||
set(value) { this.showAddressFormValue = value; },
|
||||
get() { return this.showAddressFormValue; }
|
||||
get() {
|
||||
return this.person.gender ? this.person.gender.id : null;
|
||||
},
|
||||
center: {
|
||||
set(value) {
|
||||
console.log('will set center', value);
|
||||
this.person.center = {id: value.id, type: value.type};
|
||||
},
|
||||
get() {
|
||||
const center = this.config.centers.find(c => this.person.center !== null && this.person.center.id === c.id);
|
||||
},
|
||||
civility: {
|
||||
set(value) {
|
||||
this.person.civility = { id: value, type: "chill_main_civility" };
|
||||
},
|
||||
get() {
|
||||
return this.person.civility ? this.person.civility.id : null;
|
||||
},
|
||||
},
|
||||
birthDate: {
|
||||
set(value) {
|
||||
if (this.person.birthdate) {
|
||||
this.person.birthdate.datetime = value + "T00:00:00+0100";
|
||||
} else {
|
||||
this.person.birthdate = { datetime: value + "T00:00:00+0100" };
|
||||
}
|
||||
},
|
||||
get() {
|
||||
return this.person.birthdate
|
||||
? this.person.birthdate.datetime.split("T")[0]
|
||||
: "";
|
||||
},
|
||||
},
|
||||
phonenumber: {
|
||||
set(value) {
|
||||
this.person.phonenumber = value;
|
||||
},
|
||||
get() {
|
||||
return this.person.phonenumber;
|
||||
},
|
||||
},
|
||||
mobilenumber: {
|
||||
set(value) {
|
||||
this.person.mobilenumber = value;
|
||||
},
|
||||
get() {
|
||||
return this.person.mobilenumber;
|
||||
},
|
||||
},
|
||||
email: {
|
||||
set(value) {
|
||||
this.person.email = value;
|
||||
},
|
||||
get() {
|
||||
return this.person.email;
|
||||
},
|
||||
},
|
||||
showAddressForm: {
|
||||
set(value) {
|
||||
this.showAddressFormValue = value;
|
||||
},
|
||||
get() {
|
||||
return this.showAddressFormValue;
|
||||
},
|
||||
},
|
||||
center: {
|
||||
set(value) {
|
||||
console.log("will set center", value);
|
||||
this.person.center = { id: value.id, type: value.type };
|
||||
},
|
||||
get() {
|
||||
const center = this.config.centers.find(
|
||||
(c) => this.person.center !== null && this.person.center.id === c.id,
|
||||
);
|
||||
|
||||
console.log('center get', center);
|
||||
console.log("center get", center);
|
||||
|
||||
return typeof center === 'undefined' ? null : center;
|
||||
},
|
||||
return typeof center === "undefined" ? null : center;
|
||||
},
|
||||
genderClass() {
|
||||
switch (this.person.gender) {
|
||||
case 'woman':
|
||||
return 'fa-venus';
|
||||
case 'man':
|
||||
return 'fa-mars';
|
||||
case 'both':
|
||||
return 'fa-neuter';
|
||||
case 'unknown':
|
||||
return 'fa-genderless';
|
||||
default:
|
||||
return 'fa-genderless';
|
||||
}
|
||||
},
|
||||
genderTranslation() {
|
||||
switch (this.person.gender.genderTranslation) {
|
||||
case 'woman':
|
||||
return 'person.gender.woman';
|
||||
case 'man':
|
||||
return 'person.gender.man';
|
||||
case 'neutral':
|
||||
return 'person.gender.neutral';
|
||||
case 'unknown':
|
||||
return 'person.gender.unknown';
|
||||
default:
|
||||
return 'person.gender.unknown';
|
||||
}
|
||||
},
|
||||
feminized() {
|
||||
return (this.person.gender === 'woman')? 'e' : '';
|
||||
},
|
||||
personAltNamesLabels() {
|
||||
return this.person.altNames.map(a => a ? a.label : '');
|
||||
},
|
||||
queryItems() {
|
||||
return this.query ? this.query.split(' ') : null;
|
||||
},
|
||||
genderClass() {
|
||||
switch (this.person.gender) {
|
||||
case "woman":
|
||||
return "fa-venus";
|
||||
case "man":
|
||||
return "fa-mars";
|
||||
case "both":
|
||||
return "fa-neuter";
|
||||
case "unknown":
|
||||
return "fa-genderless";
|
||||
default:
|
||||
return "fa-genderless";
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
getPersonAltNames()
|
||||
.then(altNames => {
|
||||
this.config.altNames = altNames;
|
||||
});
|
||||
getCivilities()
|
||||
.then(civilities => {
|
||||
if ('results' in civilities) {
|
||||
this.config.civilities = civilities.results;
|
||||
}
|
||||
});
|
||||
getGenders()
|
||||
.then(genders => {
|
||||
if ('results' in genders) {
|
||||
this.config.genders = genders.results;
|
||||
}
|
||||
});
|
||||
if (this.action !== 'create') {
|
||||
this.loadData();
|
||||
} else {
|
||||
// console.log('show centers', this.showCenters);
|
||||
getCentersForPersonCreation()
|
||||
.then(params => {
|
||||
this.config.centers = params.centers.filter(c => c.isActive);
|
||||
this.showCenters = params.showCenters;
|
||||
// console.log('centers', this.config.centers)
|
||||
// console.log('show centers inside', this.showCenters);
|
||||
if (this.showCenters && this.config.centers.length === 1) {
|
||||
this.person.center = this.config.centers[0];
|
||||
}
|
||||
});
|
||||
},
|
||||
genderTranslation() {
|
||||
switch (this.person.gender.genderTranslation) {
|
||||
case "woman":
|
||||
return "person.gender.woman";
|
||||
case "man":
|
||||
return "person.gender.man";
|
||||
case "neutral":
|
||||
return "person.gender.neutral";
|
||||
case "unknown":
|
||||
return "person.gender.unknown";
|
||||
default:
|
||||
return "person.gender.unknown";
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
checkErrors() {
|
||||
this.errors = [];
|
||||
if (this.person.lastName === "") {
|
||||
this.errors.push("Le nom ne doit pas être vide.");
|
||||
}
|
||||
if (this.person.firstName === "") {
|
||||
this.errors.push("Le prénom ne doit pas être vide.");
|
||||
}
|
||||
if (!this.person.gender) {
|
||||
this.errors.push("Le genre doit être renseigné");
|
||||
}
|
||||
if (this.showCenters && this.person.center === null) {
|
||||
this.errors.push("Le centre doit être renseigné");
|
||||
}
|
||||
},
|
||||
loadData() {
|
||||
getPerson(this.id)
|
||||
.then(person => new Promise((resolve) => {
|
||||
this.person = person;
|
||||
//console.log('get person', this.person);
|
||||
resolve();
|
||||
}));
|
||||
},
|
||||
onAltNameInput(event) {
|
||||
const key = event.target.id;
|
||||
const label = event.target.value;
|
||||
let updateAltNames = this.person.altNames.filter((a) => a.key !== key);
|
||||
updateAltNames.push(
|
||||
{'key': key, 'label': label}
|
||||
)
|
||||
this.person.altNames = updateAltNames;
|
||||
},
|
||||
addQueryItem(field, queryItem) {
|
||||
switch (field) {
|
||||
case 'lastName':
|
||||
this.person.lastName = this.person.lastName ? this.person.lastName += ` ${queryItem}` : queryItem;
|
||||
break;
|
||||
case 'firstName':
|
||||
this.person.firstName = this.person.firstName ? this.person.firstName += ` ${queryItem}` : queryItem;
|
||||
break;
|
||||
}
|
||||
},
|
||||
submitNewAddress(payload) {
|
||||
this.person.addressId = payload.addressId;
|
||||
},
|
||||
feminized() {
|
||||
return this.person.gender === "woman" ? "e" : "";
|
||||
},
|
||||
personAltNamesLabels() {
|
||||
return this.person.altNames.map((a) => (a ? a.label : ""));
|
||||
},
|
||||
queryItems() {
|
||||
return this.query ? this.query.split(" ") : null;
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
getPersonAltNames().then((altNames) => {
|
||||
this.config.altNames = altNames;
|
||||
});
|
||||
getCivilities().then((civilities) => {
|
||||
if ("results" in civilities) {
|
||||
this.config.civilities = civilities.results;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
getGenders().then((genders) => {
|
||||
if ("results" in genders) {
|
||||
this.config.genders = genders.results;
|
||||
}
|
||||
});
|
||||
if (this.action !== "create") {
|
||||
this.loadData();
|
||||
} else {
|
||||
// console.log('show centers', this.showCenters);
|
||||
getCentersForPersonCreation().then((params) => {
|
||||
this.config.centers = params.centers.filter((c) => c.isActive);
|
||||
this.showCenters = params.showCenters;
|
||||
// console.log('centers', this.config.centers)
|
||||
// console.log('show centers inside', this.showCenters);
|
||||
if (this.showCenters && this.config.centers.length === 1) {
|
||||
this.person.center = this.config.centers[0];
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
checkErrors() {
|
||||
this.errors = [];
|
||||
if (this.person.lastName === "") {
|
||||
this.errors.push("Le nom ne doit pas être vide.");
|
||||
}
|
||||
if (this.person.firstName === "") {
|
||||
this.errors.push("Le prénom ne doit pas être vide.");
|
||||
}
|
||||
if (!this.person.gender) {
|
||||
this.errors.push("Le genre doit être renseigné");
|
||||
}
|
||||
if (this.showCenters && this.person.center === null) {
|
||||
this.errors.push("Le centre doit être renseigné");
|
||||
}
|
||||
},
|
||||
loadData() {
|
||||
getPerson(this.id).then(
|
||||
(person) =>
|
||||
new Promise((resolve) => {
|
||||
this.person = person;
|
||||
//console.log('get person', this.person);
|
||||
resolve();
|
||||
}),
|
||||
);
|
||||
},
|
||||
onAltNameInput(event) {
|
||||
const key = event.target.id;
|
||||
const label = event.target.value;
|
||||
let updateAltNames = this.person.altNames.filter((a) => a.key !== key);
|
||||
updateAltNames.push({ key: key, label: label });
|
||||
this.person.altNames = updateAltNames;
|
||||
},
|
||||
addQueryItem(field, queryItem) {
|
||||
switch (field) {
|
||||
case "lastName":
|
||||
this.person.lastName = this.person.lastName
|
||||
? (this.person.lastName += ` ${queryItem}`)
|
||||
: queryItem;
|
||||
break;
|
||||
case "firstName":
|
||||
this.person.firstName = this.person.firstName
|
||||
? (this.person.firstName += ` ${queryItem}`)
|
||||
: queryItem;
|
||||
break;
|
||||
}
|
||||
},
|
||||
submitNewAddress(payload) {
|
||||
this.person.addressId = payload.addressId;
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
div.flex-table {
|
||||
div.item-bloc {
|
||||
div.item-row {
|
||||
div.item-col:last-child {
|
||||
justify-content: flex-start;
|
||||
}
|
||||
div.item-bloc {
|
||||
div.item-row {
|
||||
div.item-col:last-child {
|
||||
justify-content: flex-start;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
dl {
|
||||
dd {
|
||||
margin-left: 1em;
|
||||
}
|
||||
dd {
|
||||
margin-left: 1em;
|
||||
}
|
||||
}
|
||||
div.form-check {
|
||||
label {
|
||||
margin-left: 0.5em!important;
|
||||
}
|
||||
label {
|
||||
margin-left: 0.5em !important;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user