Apply prettier rules

This commit is contained in:
2024-11-14 18:47:38 +01:00
parent 610227815a
commit aa0785fc71
291 changed files with 23646 additions and 22071 deletions

View File

@@ -1 +1 @@
require('./chillthirdparty.scss');
require("./chillthirdparty.scss");

View File

@@ -1,55 +1,52 @@
/*
* GET a thirdparty by id
*/
* GET a thirdparty by id
*/
const getThirdparty = (id) => {
const url = `/api/1.0/thirdparty/thirdparty/${id}.json`;
return fetch(url)
.then(response => {
if (response.ok) {
return response.json();
}
throw Error('Error with request resource response');
});
const url = `/api/1.0/thirdparty/thirdparty/${id}.json`;
return fetch(url).then((response) => {
if (response.ok) {
return response.json();
}
throw Error("Error with request resource response");
});
};
/*
* POST a new thirdparty
*/
* POST a new thirdparty
*/
const postThirdparty = (body) => {
const url = `/api/1.0/thirdparty/thirdparty.json`;
return fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json;charset=utf-8'
},
body: JSON.stringify(body)
})
.then(response => {
if (response.ok) { return response.json(); }
throw Error('Error with request resource response');
});
const url = `/api/1.0/thirdparty/thirdparty.json`;
return fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json;charset=utf-8",
},
body: JSON.stringify(body),
}).then((response) => {
if (response.ok) {
return response.json();
}
throw Error("Error with request resource response");
});
};
/*
* PATCH an existing thirdparty
*/
* PATCH an existing thirdparty
*/
const patchThirdparty = (id, body) => {
const url = `/api/1.0/thirdparty/thirdparty/${id}.json`;
return fetch(url, {
method: 'PATCH',
headers: {
'Content-Type': 'application/json;charset=utf-8'
},
body: JSON.stringify(body)
})
.then(response => {
if (response.ok) { return response.json(); }
throw Error('Error with request resource response');
});
const url = `/api/1.0/thirdparty/thirdparty/${id}.json`;
return fetch(url, {
method: "PATCH",
headers: {
"Content-Type": "application/json;charset=utf-8",
},
body: JSON.stringify(body),
}).then((response) => {
if (response.ok) {
return response.json();
}
throw Error("Error with request resource response");
});
};
export {
getThirdparty,
postThirdparty,
patchThirdparty
};
export { getThirdparty, postThirdparty, patchThirdparty };

View File

@@ -1,200 +1,225 @@
<template>
<div class="item-bloc col">
<section class="chill-entity entity-thirdparty">
<div class="item-row entity-bloc">
<div class="item-col">
<div class="entity-label">
<div :class="'denomination h' + options.hLevel">
<a
v-if="this.options.addLink === true"
href="#"
>
<span class="name">{{ thirdparty.text }}</span>
</a>
<span
class="name"
v-else
>{{ thirdparty.text }}</span>
<div class="item-bloc col">
<section class="chill-entity entity-thirdparty">
<div class="item-row entity-bloc">
<div class="item-col">
<div class="entity-label">
<div :class="'denomination h' + options.hLevel">
<a v-if="this.options.addLink === true" href="#">
<span class="name">{{ thirdparty.text }}</span>
</a>
<span class="name" v-else>{{
thirdparty.text
}}</span>
<span
v-if="options.addId === true"
class="id-number"
:title="'n° ' + thirdparty.id"
>
{{ thirdparty.id }}
</span>
<span
v-if="options.addId === true"
class="id-number"
:title="'n° ' + thirdparty.id"
>
{{ thirdparty.id }}
</span>
<badge-entity
v-if="options.addEntity === true"
:entity="thirdparty"
:options="{ displayLong: options.entityDisplayLong }"
/>
</div>
<badge-entity
v-if="options.addEntity === true"
:entity="thirdparty"
:options="{
displayLong: options.entityDisplayLong,
}"
/>
</div>
<p
v-if="this.options.addInfo === true"
class="moreinfo"
/>
</div>
</div>
<p
v-if="this.options.addInfo === true"
class="moreinfo"
/>
</div>
</div>
<div class="item-col">
<div class="float-button bottom">
<div class="box">
<div class="action">
<slot name="record-actions" />
</div>
<ul class="list-content fa-ul">
<li v-if="getProfession.length > 0">
<i class="fa fa-li fa-id-card" />
<p><span>{{ getProfession[0] }}</span></p>
</li>
<li v-if="hasParent">
<i class="fa fa-li fa-hand-o-right" />
<b class="me-2">{{ $t('child_of') }}</b>
<on-the-fly
:type="thirdparty.parent.type"
:id="thirdparty.parent.id"
:button-text="thirdparty.parent.text"
:display-badge="'true' === 'true'"
action="show"
/>
</li>
<!-- TODO hasChildren
<div class="item-col">
<div class="float-button bottom">
<div class="box">
<div class="action">
<slot name="record-actions" />
</div>
<ul class="list-content fa-ul">
<li v-if="getProfession.length > 0">
<i class="fa fa-li fa-id-card" />
<p>
<span>{{ getProfession[0] }}</span>
</p>
</li>
<li v-if="hasParent">
<i class="fa fa-li fa-hand-o-right" />
<b class="me-2">{{ $t("child_of") }}</b>
<on-the-fly
:type="thirdparty.parent.type"
:id="thirdparty.parent.id"
:button-text="thirdparty.parent.text"
:display-badge="'true' === 'true'"
action="show"
/>
</li>
<!-- TODO hasChildren
NB: we cannot call on-the-fly from RenderBox. See error message in previous version of this file.
-->
</ul>
<div v-if="thirdparty.contactDataAnonymous">
<confidential :position-btn-far="false">
<template #confidential-content>
<ul class="list-content fa-ul">
<li v-if="thirdparty.address">
<i class="fa fa-li fa-map-marker" />
<address-render-box
:address="thirdparty.address"
:is-multiline="isMultiline"
/>
</li>
<li v-if="thirdparty.telephone">
<i class="fa fa-li fa-mobile" />
<a :href="'tel: ' + thirdparty.telephone">{{ thirdparty.telephone }}</a>
</li>
<li v-if="thirdparty.email">
<i class="fa fa-li fa-envelope-o" />
<a :href="'mailto: ' + thirdparty.email">{{ thirdparty.email }}</a>
</li>
</ul>
</template>
</confidential>
</div>
<ul
v-else
class="list-content fa-ul"
>
<li v-if="thirdparty.address">
<i class="fa fa-li fa-map-marker" />
<address-render-box
:address="thirdparty.address"
:is-multiline="isMultiline"
/>
</li>
<li v-if="thirdparty.telephone">
<i class="fa fa-li fa-mobile" />
<a :href="'tel: ' + thirdparty.telephone">{{ thirdparty.telephone }}</a>
</li>
<li v-if="thirdparty.email">
<i class="fa fa-li fa-envelope-o" />
<a :href="'mailto: ' + thirdparty.email">{{ thirdparty.email }}</a>
</li>
</ul>
</ul>
<div v-if="thirdparty.contactDataAnonymous">
<confidential :position-btn-far="false">
<template #confidential-content>
<ul class="list-content fa-ul">
<li v-if="thirdparty.address">
<i
class="fa fa-li fa-map-marker"
/>
<address-render-box
:address="
thirdparty.address
"
:is-multiline="isMultiline"
/>
</li>
<li v-if="thirdparty.telephone">
<i class="fa fa-li fa-mobile" />
<a
:href="
'tel: ' +
thirdparty.telephone
"
>{{
thirdparty.telephone
}}</a
>
</li>
<li v-if="thirdparty.email">
<i
class="fa fa-li fa-envelope-o"
/>
<a
:href="
'mailto: ' +
thirdparty.email
"
>{{ thirdparty.email }}</a
>
</li>
</ul>
</template>
</confidential>
</div>
<ul v-else class="list-content fa-ul">
<li v-if="thirdparty.address">
<i class="fa fa-li fa-map-marker" />
<address-render-box
:address="thirdparty.address"
:is-multiline="isMultiline"
/>
</li>
<li v-if="thirdparty.telephone">
<i class="fa fa-li fa-mobile" />
<a :href="'tel: ' + thirdparty.telephone">{{
thirdparty.telephone
}}</a>
</li>
<li v-if="thirdparty.email">
<i class="fa fa-li fa-envelope-o" />
<a :href="'mailto: ' + thirdparty.email">{{
thirdparty.email
}}</a>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<slot name="end-bloc" />
</section>
</div>
<slot name="end-bloc" />
</section>
</div>
</template>
<script>
import AddressRenderBox from 'ChillMainAssets/vuejs/_components/Entity/AddressRenderBox.vue';
import Confidential from 'ChillMainAssets/vuejs/_components/Confidential.vue';
import BadgeEntity from 'ChillMainAssets/vuejs/_components/BadgeEntity.vue';
import AddressRenderBox from "ChillMainAssets/vuejs/_components/Entity/AddressRenderBox.vue";
import Confidential from "ChillMainAssets/vuejs/_components/Confidential.vue";
import BadgeEntity from "ChillMainAssets/vuejs/_components/BadgeEntity.vue";
export default {
name: "ThirdPartyRenderBox",
components: {
AddressRenderBox,
Confidential,
BadgeEntity,
},
// To avoid components recursively invoking eachother resolve OnTheFly component here
beforeCreate() {
this.$options.components.OnTheFly = require('ChillMainAssets/vuejs/OnTheFly/components/OnTheFly').default;
},
i18n: {
messages: {
fr: {
children: "Personnes de contact: ",
child_of: "Contact de: ",
}
}
},
props: ['thirdparty', 'options'],
computed: {
isMultiline: function () {
if (this.options.isMultiline) {
return this.options.isMultiline
} else {
return false
}
name: "ThirdPartyRenderBox",
components: {
AddressRenderBox,
Confidential,
BadgeEntity,
},
hasParent() {
return !(this.thirdparty.parent === null || this.thirdparty.parent === undefined);
// To avoid components recursively invoking eachother resolve OnTheFly component here
beforeCreate() {
this.$options.components.OnTheFly =
require("ChillMainAssets/vuejs/OnTheFly/components/OnTheFly").default;
},
getProfession() {
let profession = []
if (this.hasParent && this.thirdparty.profession) {
profession.push(this.thirdparty.profession)
return profession;
}
i18n: {
messages: {
fr: {
children: "Personnes de contact: ",
child_of: "Contact de: ",
},
},
},
props: ["thirdparty", "options"],
computed: {
isMultiline: function () {
if (this.options.isMultiline) {
return this.options.isMultiline;
} else {
return false;
}
},
hasParent() {
return !(
this.thirdparty.parent === null ||
this.thirdparty.parent === undefined
);
},
getProfession() {
let profession = [];
if (this.hasParent && this.thirdparty.profession) {
profession.push(this.thirdparty.profession);
return profession;
}
if (!this.hasParent && this.thirdparty.category) {
profession = this.thirdparty.category.map((category) => category.text);
}
if (!this.hasParent && this.thirdparty.category) {
profession = this.thirdparty.category.map(
(category) => category.text,
);
}
return profession;
}
/* TODO need backend normalizer to serve children without circular reference
return profession;
},
/* TODO need backend normalizer to serve children without circular reference
hasChildren() {
//console.log(this.thirdparty.activeChildren.length > 0)
return false
} */
}
}
},
};
</script>
<style lang="scss">
.name {
&:before {
content: " "
}
&:before {
content: " ";
}
&.tparty-parent {
font-weight: bold;
font-variant: all-small-caps;
}
&.tparty-parent {
font-weight: bold;
font-variant: all-small-caps;
}
}
.list-professions {
&::after {
content: " | ";
}
&::after {
content: " | ";
}
&:last-child::after {
content: ""
}
&:last-child::after {
content: "";
}
}
</style>

View File

@@ -1,32 +1,28 @@
<template>
<span v-if="isCut">{{ cutText }}</span>
<span
v-else
class="thirdparty-text"
>
<span class="firstname">{{ thirdparty.text }}</span>
</span>
<span v-if="isCut">{{ cutText }}</span>
<span v-else class="thirdparty-text">
<span class="firstname">{{ thirdparty.text }}</span>
</span>
</template>
<script>
export default {
name: "ThirdPartyText",
props: {
thirdparty: {
required: true,
},
isCut: {
type: Boolean,
required: false,
default: false
},
thirdparty: {
required: true,
},
isCut: {
type: Boolean,
required: false,
default: false,
},
},
computed: {
cutText: function() {
let more = (this.thirdparty.text.length > 15) ?'…' : '';
return this.thirdparty.text.slice(0,15) + more;
}
}
}
cutText: function () {
let more = this.thirdparty.text.length > 15 ? "…" : "";
return this.thirdparty.text.slice(0, 15) + more;
},
},
};
</script>

View File

@@ -1,426 +1,431 @@
<template>
<div v-if="action === 'show'">
<div class="flex-table">
<third-party-render-box
:thirdparty="thirdparty"
:options="{
addInfo: true,
addEntity: true,
entityDisplayLong: true,
addAltNames: true,
addId: true,
addLink: false,
addAge: false,
hLevel: 3,
addCenter: true,
addNoData: true,
isMultiline: true
}"
/>
</div>
</div>
<div v-else-if="action === 'edit' || action === 'create' || action === 'addContact'">
<div v-if="parent">
<div class="parent-info">
<i class="fa fa-li fa-hand-o-right" />
<b class="me-2">{{ $t('child_of') }}</b>
<span class="chill-entity badge-thirdparty">{{ parent.text }}</span>
</div>
<div v-if="action === 'show'">
<div class="flex-table">
<third-party-render-box
:thirdparty="thirdparty"
:options="{
addInfo: true,
addEntity: true,
entityDisplayLong: true,
addAltNames: true,
addId: true,
addLink: false,
addAge: false,
hLevel: 3,
addCenter: true,
addNoData: true,
isMultiline: true,
}"
/>
</div>
</div>
<div
class="form-floating mb-3"
v-else-if="kind !== 'child'"
v-else-if="
action === 'edit' || action === 'create' || action === 'addContact'
"
>
<div class="form-check">
<input
class="form-check-input mt-0"
type="radio"
v-model="kind"
value="company"
id="tpartyKindInstitution"
>
<label
for="tpartyKindInstitution"
class="required"
>
<badge-entity
:entity="{ type: 'thirdparty', kind: 'company' }"
:options="{ displayLong: true }"
/>
</label>
</div>
<div class="form-check">
<input
class="form-check-input mt-0"
type="radio"
v-model="kind"
value="contact"
id="tpartyKindContact"
>
<label
for="tpartyKindContact"
class="required"
>
<badge-entity
:entity="{ type: 'thirdparty', kind: 'contact' }"
:options="{ displayLong: true }"
/>
</label>
</div>
</div>
<div v-else>
<p>Contact de&nbsp;:</p>
<third-party-render-box
:thirdparty="thirdparty.parent"
:options="{
addInfo: true,
addEntity: false,
addAltNames: true,
addId: false,
addLink: false,
addAge: false,
hLevel: 4,
addCenter: false,
addNoData: true,
isMultiline: false
}"
/>
</div>
<div v-if="parent">
<div class="parent-info">
<i class="fa fa-li fa-hand-o-right" />
<b class="me-2">{{ $t("child_of") }}</b>
<span class="chill-entity badge-thirdparty">{{
parent.text
}}</span>
</div>
</div>
<div class="form-floating mb-3" v-else-if="kind !== 'child'">
<div class="form-check">
<input
class="form-check-input mt-0"
type="radio"
v-model="kind"
value="company"
id="tpartyKindInstitution"
/>
<label for="tpartyKindInstitution" class="required">
<badge-entity
:entity="{ type: 'thirdparty', kind: 'company' }"
:options="{ displayLong: true }"
/>
</label>
</div>
<div class="form-check">
<input
class="form-check-input mt-0"
type="radio"
v-model="kind"
value="contact"
id="tpartyKindContact"
/>
<label for="tpartyKindContact" class="required">
<badge-entity
:entity="{ type: 'thirdparty', kind: 'contact' }"
:options="{ displayLong: true }"
/>
</label>
</div>
</div>
<div v-else>
<p>Contact de&nbsp;:</p>
<third-party-render-box
:thirdparty="thirdparty.parent"
:options="{
addInfo: true,
addEntity: false,
addAltNames: true,
addId: false,
addLink: false,
addAge: false,
hLevel: 4,
addCenter: false,
addNoData: true,
isMultiline: false,
}"
/>
</div>
<div v-if="thirdparty.kind === 'child' || thirdparty.kind === 'contact'">
<div class="child-info">
<div class="input-group mb-3 input-section">
<select
class="form-select form-select-lg"
id="civility"
v-model="thirdparty.civility"
>
<option
selected
disabled
:value="null"
>
{{ $t('thirdparty.civility') }}
</option>
<option
v-for="civility in civilities"
:key="civility.id"
:value="civility"
>
{{ civility.name.fr }}
</option>
</select>
<div
v-if="thirdparty.kind === 'child' || thirdparty.kind === 'contact'"
>
<div class="child-info">
<div class="input-group mb-3 input-section">
<select
class="form-select form-select-lg"
id="civility"
v-model="thirdparty.civility"
>
<option selected disabled :value="null">
{{ $t("thirdparty.civility") }}
</option>
<option
v-for="civility in civilities"
:key="civility.id"
:value="civility"
>
{{ civility.name.fr }}
</option>
</select>
</div>
<div class="input-group mb-3 input-section">
<input
class="form-control form-control-lg"
v-model="thirdparty.profession"
:placeholder="$t('thirdparty.profession')"
:aria-label="$t('thirdparty.profession')"
aria-describedby="profession"
/>
</div>
</div>
<div class="child-info">
<div class="input-section">
<div class="form-floating mb-3">
<input
class="form-control form-control-lg"
id="firstname"
v-model="thirdparty.firstname"
:placeholder="$t('thirdparty.firstname')"
/>
<label for="firstname">{{
$t("thirdparty.firstname")
}}</label>
</div>
<div v-if="queryItems">
<ul class="list-suggest add-items inline">
<li
v-for="(qi, i) in queryItems"
:key="i"
@click="addQueryItem('firstName', qi)"
>
<span class="person-text">{{ qi }}</span>
</li>
</ul>
</div>
</div>
<div class="input-section">
<div class="form-floating mb-3">
<input
class="form-control form-control-lg"
id="name"
v-model="thirdparty.name"
:placeholder="$t('thirdparty.lastname')"
/>
<label for="name">{{
$t("thirdparty.lastname")
}}</label>
</div>
<div v-if="queryItems">
<ul class="list-suggest add-items inline">
<li
v-for="(qi, i) in queryItems"
:key="i"
@click="addQueryItem('name', qi)"
>
<span class="person-text">{{ qi }}</span>
</li>
</ul>
</div>
</div>
</div>
</div>
<div class="input-group mb-3 input-section">
<input
class="form-control form-control-lg"
v-model="thirdparty.profession"
:placeholder="$t('thirdparty.profession')"
:aria-label="$t('thirdparty.profession')"
aria-describedby="profession"
>
<div v-if="thirdparty.kind === 'company'">
<div class="form-floating mb-3">
<input
class="form-control form-control-lg"
id="name"
v-model="thirdparty.name"
:placeholder="$t('thirdparty.name')"
/>
<label for="name">{{ $t("thirdparty.name") }}</label>
</div>
<div v-if="query">
<ul class="list-suggest add-items inline">
<li @click="addQuery(query)">
<span class="person-text">{{ query }}</span>
</li>
</ul>
</div>
</div>
</div>
<div class="child-info">
<div class="input-section">
<div class="form-floating mb-3">
<template v-if="thirdparty.kind !== 'child'">
<add-address
key="thirdparty"
:context="context"
:options="addAddress.options"
:address-changed-callback="submitAddress"
ref="addAddress"
/>
</template>
<div class="input-group mb-3">
<span class="input-group-text" id="email"
><i class="fa fa-fw fa-envelope"
/></span>
<input
class="form-control form-control-lg"
id="firstname"
v-model="thirdparty.firstname"
:placeholder="$t('thirdparty.firstname')"
>
<label for="firstname">{{ $t('thirdparty.firstname') }}</label>
</div>
<div v-if="queryItems">
<ul class="list-suggest add-items inline">
<li
v-for="(qi, i) in queryItems"
:key="i"
@click="addQueryItem('firstName', qi)"
>
<span class="person-text">{{ qi }}</span>
</li>
</ul>
</div>
class="form-control form-control-lg"
v-model="thirdparty.email"
:placeholder="$t('thirdparty.email')"
:aria-label="$t('thirdparty.email')"
aria-describedby="email"
/>
</div>
<div class="input-section">
<div class="form-floating mb-3">
<div class="input-group mb-3">
<span class="input-group-text" id="phonenumber"
><i class="fa fa-fw fa-phone"
/></span>
<input
class="form-control form-control-lg"
id="name"
v-model="thirdparty.name"
:placeholder="$t('thirdparty.lastname')"
>
<label for="name">{{ $t('thirdparty.lastname') }}</label>
</div>
<div v-if="queryItems">
<ul class="list-suggest add-items inline">
<li
v-for="(qi, i) in queryItems"
:key="i"
@click="addQueryItem('name', qi)"
>
<span class="person-text">{{ qi }}</span>
</li>
</ul>
</div>
class="form-control form-control-lg"
v-model="thirdparty.telephone"
:placeholder="$t('thirdparty.phonenumber')"
:aria-label="$t('thirdparty.phonenumber')"
aria-describedby="phonenumber"
/>
</div>
</div>
</div>
<div v-if="thirdparty.kind === 'company'">
<div class="form-floating mb-3">
<input
class="form-control form-control-lg"
id="name"
v-model="thirdparty.name"
:placeholder="$t('thirdparty.name')"
>
<label for="name">{{ $t('thirdparty.name') }}</label>
</div>
<div v-if="query">
<ul class="list-suggest add-items inline">
<li @click="addQuery(query)">
<span class="person-text">{{ query }}</span>
</li>
</ul>
</div>
<div v-if="parent">
<div class="input-group mb-3">
<span class="input-group-text" id="comment"
><i class="fa fa-fw fa-pencil"
/></span>
<textarea
class="form-control form-control-lg"
:placeholder="$t('thirdparty.comment')"
v-model="thirdparty.comment"
/>
</div>
</div>
</div>
<template
v-if="thirdparty.kind !== 'child'"
>
<add-address
key="thirdparty"
:context="context"
:options="addAddress.options"
:address-changed-callback="submitAddress"
ref="addAddress"
/>
</template>
<div class="input-group mb-3">
<span
class="input-group-text"
id="email"
><i class="fa fa-fw fa-envelope" /></span>
<input
class="form-control form-control-lg"
v-model="thirdparty.email"
:placeholder="$t('thirdparty.email')"
:aria-label="$t('thirdparty.email')"
aria-describedby="email"
>
</div>
<div class="input-group mb-3">
<span
class="input-group-text"
id="phonenumber"
><i class="fa fa-fw fa-phone" /></span>
<input
class="form-control form-control-lg"
v-model="thirdparty.telephone"
:placeholder="$t('thirdparty.phonenumber')"
:aria-label="$t('thirdparty.phonenumber')"
aria-describedby="phonenumber"
>
</div>
<div v-if="parent">
<div class="input-group mb-3">
<span
class="input-group-text"
id="comment"
><i class="fa fa-fw fa-pencil" /></span>
<textarea
class="form-control form-control-lg"
:placeholder="$t('thirdparty.comment')"
v-model="thirdparty.comment"
/>
</div>
</div>
</div>
</template>
<script>
import ThirdPartyRenderBox from '../Entity/ThirdPartyRenderBox.vue';
import AddAddress from 'ChillMainAssets/vuejs/Address/components/AddAddress';
import { getThirdparty } from '../../_api/OnTheFly';
import BadgeEntity from 'ChillMainAssets/vuejs/_components/BadgeEntity.vue';
import { makeFetch } from 'ChillMainAssets/lib/api/apiMethods';
import ThirdPartyRenderBox from "../Entity/ThirdPartyRenderBox.vue";
import AddAddress from "ChillMainAssets/vuejs/Address/components/AddAddress";
import { getThirdparty } from "../../_api/OnTheFly";
import BadgeEntity from "ChillMainAssets/vuejs/_components/BadgeEntity.vue";
import { makeFetch } from "ChillMainAssets/lib/api/apiMethods";
export default {
name: "OnTheFlyThirdParty",
props: ['id', 'type', 'action', 'query', 'parent'],
components: {
ThirdPartyRenderBox,
AddAddress,
BadgeEntity
},
data() {
return {
//context: {}, <--
thirdparty: {
type: 'thirdparty',
address: null,
kind: 'company',
firstname: '',
name: '',
telephone: '',
civility: null,
profession: '',
},
civilities: [],
addAddress: {
options: {
openPanesInModal: true,
onlyButton: false,
button: {
size: 'btn-sm'
},
title: {
create: 'add_an_address_title',
edit: 'edit_address'
}
}
}
}
},
computed: {
kind: {
get() {
// note: there are also default to 'institution' set in the "mounted" method
if (this.$data.thirdparty.kind !== undefined) {
return this.$data.thirdparty.kind;
} else {
return 'company';
}
},
set(v) {
this.$data.thirdparty.kind = v;
}
},
context() {
let context = {
target: {
name: this.type,
id: this.id
name: "OnTheFlyThirdParty",
props: ["id", "type", "action", "query", "parent"],
components: {
ThirdPartyRenderBox,
AddAddress,
BadgeEntity,
},
data() {
return {
//context: {}, <--
thirdparty: {
type: "thirdparty",
address: null,
kind: "company",
firstname: "",
name: "",
telephone: "",
civility: null,
profession: "",
},
edit: false,
addressId: null,
defaults: window.addaddress
};
if ( !(this.thirdparty.address === undefined || this.thirdparty.address === null)
&& this.thirdparty.address.address_id !== null
) { // to complete
context.addressId = this.thirdparty.address.address_id;
context.edit = true;
}
//this.context = context; <--
return context;
},
queryItems() {
return this.query ? this.query.split(' ') : null;
},
},
methods: {
loadData(){
return getThirdparty(this.id).then(thirdparty => new Promise((resolve) => {
this.thirdparty = thirdparty;
this.thirdparty.kind = thirdparty.kind;
if (this.action !== 'show') {
if (thirdparty.address !== null) {
// bof! we force getInitialAddress because addressId not available when mounted
this.$refs.addAddress.getInitialAddress(thirdparty.address.address_id);
}
civilities: [],
addAddress: {
options: {
openPanesInModal: true,
onlyButton: false,
button: {
size: "btn-sm",
},
title: {
create: "add_an_address_title",
edit: "edit_address",
},
},
},
};
},
computed: {
kind: {
get() {
// note: there are also default to 'institution' set in the "mounted" method
if (this.$data.thirdparty.kind !== undefined) {
return this.$data.thirdparty.kind;
} else {
return "company";
}
},
set(v) {
this.$data.thirdparty.kind = v;
},
},
context() {
let context = {
target: {
name: this.type,
id: this.id,
},
edit: false,
addressId: null,
defaults: window.addaddress,
};
if (
!(
this.thirdparty.address === undefined ||
this.thirdparty.address === null
) &&
this.thirdparty.address.address_id !== null
) {
// to complete
context.addressId = this.thirdparty.address.address_id;
context.edit = true;
}
resolve();
}));
},
loadCivilities() {
const url = `/api/1.0/main/civility.json`;
return makeFetch('GET', url)
.then(response => {
this.$data.civilities = response.results;
return Promise.resolve();
})
.catch((error) => {
console.log(error)
this.$toast.open({message: error.body})
})
},
submitAddress(payload) {
console.log('submitAddress', payload);
if (typeof payload.addressId !== 'undefined') { // <--
this.context.edit = true;
this.context.addressId = payload.addressId; // bof! use legacy and not legacy in payload
this.thirdparty.address = payload.address; // <--
console.log('switch address to edit mode', this.context);
}
},
addQueryItem(field, queryItem) {
switch (field) {
case 'name':
this.thirdparty.name ? this.thirdparty.name += ` ${queryItem}` : this.thirdparty.name = queryItem;
break;
case 'firstName':
this.thirdparty.firstname = queryItem;
break;
}
},
addQuery(query) {
this.thirdparty.name = query;
},
},
mounted() {
let dependencies = [];
dependencies.push(this.loadCivilities());
if (this.action !== 'create') {
if (this.id) {
dependencies.push(this.loadData());
// here we can do something when all promises are resolve, with
// Promise.all(dependencies).then(() => { /* do something */ });
}
if (this.action === 'addContact') {
this.$data.thirdparty.kind = 'child'
// this.$data.thirdparty.parent = this.parent.id
this.$data.thirdparty.address = null
}
} else {
this.thirdparty.kind = 'company';
}
},
}
//this.context = context; <--
return context;
},
queryItems() {
return this.query ? this.query.split(" ") : null;
},
},
methods: {
loadData() {
return getThirdparty(this.id).then(
(thirdparty) =>
new Promise((resolve) => {
this.thirdparty = thirdparty;
this.thirdparty.kind = thirdparty.kind;
if (this.action !== "show") {
if (thirdparty.address !== null) {
// bof! we force getInitialAddress because addressId not available when mounted
this.$refs.addAddress.getInitialAddress(
thirdparty.address.address_id,
);
}
}
resolve();
}),
);
},
loadCivilities() {
const url = `/api/1.0/main/civility.json`;
return makeFetch("GET", url)
.then((response) => {
this.$data.civilities = response.results;
return Promise.resolve();
})
.catch((error) => {
console.log(error);
this.$toast.open({ message: error.body });
});
},
submitAddress(payload) {
console.log("submitAddress", payload);
if (typeof payload.addressId !== "undefined") {
// <--
this.context.edit = true;
this.context.addressId = payload.addressId; // bof! use legacy and not legacy in payload
this.thirdparty.address = payload.address; // <--
console.log("switch address to edit mode", this.context);
}
},
addQueryItem(field, queryItem) {
switch (field) {
case "name":
this.thirdparty.name
? (this.thirdparty.name += ` ${queryItem}`)
: (this.thirdparty.name = queryItem);
break;
case "firstName":
this.thirdparty.firstname = queryItem;
break;
}
},
addQuery(query) {
this.thirdparty.name = query;
},
},
mounted() {
let dependencies = [];
dependencies.push(this.loadCivilities());
if (this.action !== "create") {
if (this.id) {
dependencies.push(this.loadData());
// here we can do something when all promises are resolve, with
// Promise.all(dependencies).then(() => { /* do something */ });
}
if (this.action === "addContact") {
this.$data.thirdparty.kind = "child";
// this.$data.thirdparty.parent = this.parent.id
this.$data.thirdparty.address = null;
}
} else {
this.thirdparty.kind = "company";
}
},
};
</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;
}
}
.parent-info {
margin-bottom: 1rem;
margin-bottom: 1rem;
}
.child-info {
display: flex;
justify-content: space-between;
.input-section {
width: 49%;
}
display: flex;
justify-content: space-between;
.input-section {
width: 49%;
}
}
</style>

View File

@@ -1,18 +1,18 @@
const thirdpartyMessages = {
fr: {
thirdparty: {
firstname: "Prénom",
lastname: "Nom",
name: "Dénomination",
email: "Courriel",
phonenumber: "Téléphone",
comment: "Commentaire",
profession: "Qualité",
civility: "Civilité"
},
child_of: "Contact de: ",
children: "Personnes de contact: ",
}
fr: {
thirdparty: {
firstname: "Prénom",
lastname: "Nom",
name: "Dénomination",
email: "Courriel",
phonenumber: "Téléphone",
comment: "Commentaire",
profession: "Qualité",
civility: "Civilité",
},
child_of: "Contact de: ",
children: "Personnes de contact: ",
},
};
export { thirdpartyMessages };

View File

@@ -1,9 +1,8 @@
module.exports = function(encore, entries)
{
// Aliases are used when webpack is trying to resolve modules path
encore.addAliases({
ChillThirdPartyAssets: __dirname + '/Resources/public'
});
module.exports = function (encore, entries) {
// Aliases are used when webpack is trying to resolve modules path
encore.addAliases({
ChillThirdPartyAssets: __dirname + "/Resources/public",
});
entries.push(__dirname + '/Resources/public/chill/index.js');
entries.push(__dirname + "/Resources/public/chill/index.js");
};