Merge branch '1405-refactor-to-get-thirdparty' into 'ticket-app-master'

Refactor third-party type imports and update related components

See merge request Chill-Projet/chill-bundles!851
This commit is contained in:
Julien Fastré 2025-07-07 14:56:35 +00:00
commit 2a54d1b909
15 changed files with 1337 additions and 1397 deletions

4
.prettierrc Normal file
View File

@ -0,0 +1,4 @@
{
"tabWidth": 2,
"useTabs": false
}

View File

@ -53,24 +53,6 @@ export interface User {
label: string; label: string;
// todo: mainCenter; mainJob; etc.. // todo: mainCenter; mainJob; etc..
} }
export interface ThirdParty {
type: "thirdparty";
id: number;
text: string;
firstname: string;
name: string;
email: string;
telephone: string;
telephone2: string;
address: {
address_id: number;
text: string;
postcode: {
name: string;
};
id: number;
};
}
export interface UserGroup { export interface UserGroup {
type: "user_group"; type: "user_group";

View File

@ -296,15 +296,11 @@ function saveAction() {
id: data.civility.id, id: data.civility.id,
} }
: null; : null;
data.profession = data.profession = data.profession !== "" ? data.profession : "";
data.profession !== "" ? data.profession : "";
} else { } else {
type = castNew.value.radioType; type = castNew.value.radioType;
data = castNew.value.castDataByType(); data = castNew.value.castDataByType();
if ( if (typeof data.civility !== "undefined" && null !== data.civility) {
typeof data.civility !== "undefined" &&
null !== data.civility
) {
data.civility = data.civility =
data.civility !== null data.civility !== null
? { ? {
@ -317,8 +313,7 @@ function saveAction() {
typeof data.profession !== "undefined" && typeof data.profession !== "undefined" &&
"" !== data.profession "" !== data.profession
) { ) {
data.profession = data.profession = data.profession !== "" ? data.profession : "";
data.profession !== "" ? data.profession : "";
} }
} }
} else { } else {

View File

@ -1,11 +1,7 @@
<template> <template>
<div class="grey-card"> <div class="grey-card">
<ul :class="listClasses" v-if="picked.length && displayPicked"> <ul :class="listClasses" v-if="picked.length && displayPicked">
<li <li v-for="p in picked" @click="removeEntity(p)" :key="p.type + p.id">
v-for="p in picked"
@click="removeEntity(p)"
:key="p.type + p.id"
>
<span <span
:class="getBadgeClass(p)" :class="getBadgeClass(p)"
class="chill_denomination" class="chill_denomination"
@ -104,7 +100,7 @@ const translatedListOfTypes = computed(() => {
return trans(PICK_ENTITY_PERSON, { return trans(PICK_ENTITY_PERSON, {
count: props.multiple ? 2 : 1, count: props.multiple ? 2 : 1,
}); });
case "third_party": case "thirdparty":
return trans(PICK_ENTITY_THIRDPARTY, { return trans(PICK_ENTITY_THIRDPARTY, {
count: props.multiple ? 2 : 1, count: props.multiple ? 2 : 1,
}); });

View File

@ -7,7 +7,6 @@ import {
User, User,
UserGroup, UserGroup,
Household, Household,
ThirdParty,
WorkflowAvailable, WorkflowAvailable,
Scope, Scope,
Job, Job,
@ -16,6 +15,11 @@ import {
import { Thirdparty } from "../../../ChillThirdPartyBundle/Resources/public/types"; import { Thirdparty } from "../../../ChillThirdPartyBundle/Resources/public/types";
import { Calendar } from "../../../ChillCalendarBundle/Resources/public/types"; import { Calendar } from "../../../ChillCalendarBundle/Resources/public/types";
export interface AltName {
label: string;
key: string;
}
export interface Person { export interface Person {
id: number; id: number;
type: "person"; type: "person";
@ -23,6 +27,8 @@ export interface Person {
textAge: string; textAge: string;
firstName: string; firstName: string;
lastName: string; lastName: string;
altNames: AltName[];
suffixText: string;
current_household_address: Address | null; current_household_address: Address | null;
birthdate: DateTime | null; birthdate: DateTime | null;
deathdate: DateTime | null; deathdate: DateTime | null;
@ -247,10 +253,10 @@ export type EntityType =
| "user_group" | "user_group"
| "user" | "user"
| "person" | "person"
| "third_party" | "thirdparty"
| "household"; | "household";
export type Entities = (UserGroup | User | Person | ThirdParty | Household) & { export type Entities = (UserGroup | User | Person | Thirdparty | Household) & {
address?: Address | null; address?: Address | null;
kind?: string; kind?: string;
text?: string; text?: string;

View File

@ -23,6 +23,7 @@ import { computed, defineProps } from "vue";
import OnTheFly from "ChillMainAssets/vuejs/OnTheFly/components/OnTheFly.vue"; import OnTheFly from "ChillMainAssets/vuejs/OnTheFly/components/OnTheFly.vue";
import BadgeEntity from "ChillMainAssets/vuejs/_components/BadgeEntity.vue"; import BadgeEntity from "ChillMainAssets/vuejs/_components/BadgeEntity.vue";
import PersonText from "ChillPersonAssets/vuejs/_components/Entity/PersonText.vue"; import PersonText from "ChillPersonAssets/vuejs/_components/Entity/PersonText.vue";
import { Person } from "ChillPersonAssets/types";
function formatDate(dateString: string | undefined, format: string) { function formatDate(dateString: string | undefined, format: string) {
if (!dateString) return ""; if (!dateString) return "";
@ -36,15 +37,7 @@ function formatDate(dateString: string | undefined, format: string) {
const props = defineProps<{ const props = defineProps<{
item: { item: {
result: { result: Person; // add other fields as needed
id: number | string;
birthdate: { datetime: string } | null;
current_household_address: {
text: string;
postcode: { name: string };
} | null;
// add other fields as needed
};
}; };
}>(); }>();

View File

@ -36,8 +36,8 @@ import OnTheFly from "ChillMainAssets/vuejs/OnTheFly/components/OnTheFly.vue";
import BadgeEntity from "ChillMainAssets/vuejs/_components/BadgeEntity.vue"; import BadgeEntity from "ChillMainAssets/vuejs/_components/BadgeEntity.vue";
import { makeFetch } from "ChillMainAssets/lib/api/apiMethods"; import { makeFetch } from "ChillMainAssets/lib/api/apiMethods";
import { useToast } from "vue-toast-notification"; import { useToast } from "vue-toast-notification";
import { ThirdParty } from "ChillMainAssets/types";
import { Result, Suggestion } from "ChillPersonAssets/types"; import { Result, Suggestion } from "ChillPersonAssets/types";
import { Thirdparty } from "src/Bundle/ChillThirdPartyBundle/Resources/public/types";
interface TypeThirdPartyProps { interface TypeThirdPartyProps {
item: Suggestion; item: Suggestion;
@ -76,7 +76,7 @@ const getAddress = computed(() => {
return null; return null;
}); });
function saveFormOnTheFly({ data }: { data: ThirdParty }) { function saveFormOnTheFly({ data }: { data: Thirdparty }) {
makeFetch("POST", "/api/1.0/thirdparty/thirdparty.json", data) makeFetch("POST", "/api/1.0/thirdparty/thirdparty.json", data)
.then((response: unknown) => { .then((response: unknown) => {
const result = response as Result; const result = response as Result;

View File

@ -23,22 +23,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import { computed, toRefs } from "vue"; import { computed, toRefs } from "vue";
import { trans, RENDERBOX_YEARS_OLD } from "translator"; import { trans, RENDERBOX_YEARS_OLD } from "translator";
import { AltName, Person } from "ChillPersonAssets/types";
interface AltName {
label: string;
key: string;
}
interface Person {
firstName: string;
lastName: string;
altNames: AltName[];
suffixText?: string;
birthdate: string | null;
deathdate: string | null;
age: number;
text: string;
}
const props = defineProps<{ const props = defineProps<{
person: Person; person: Person;

View File

@ -7,6 +7,8 @@ import {
} from "ChillMainAssets/types"; } from "ChillMainAssets/types";
export interface Thirdparty { export interface Thirdparty {
type: "thirdparty";
text: string;
acronym: string | null; acronym: string | null;
active: boolean; active: boolean;
address: Address | null; address: Address | null;

View File

@ -77,7 +77,7 @@ export interface PersonsState {
persons: Person[]; persons: Person[];
} }
export interface CallerState { export interface CallerState {
new_caller: Person | null; new_caller: Person | Thirdparty | null;
} }
export interface StateChange { export interface StateChange {
@ -122,7 +122,11 @@ export type TicketHistoryLine =
| EmergencyStateEvent | EmergencyStateEvent
| CallerStateEvent; | CallerStateEvent;
interface BaseTicket<T extends "ticket_ticket:simple"|"ticket_ticket:extended" = "ticket_ticket:simple"> { interface BaseTicket<
T extends
| "ticket_ticket:simple"
| "ticket_ticket:extended" = "ticket_ticket:simple",
> {
type_extended: T; type_extended: T;
type: "ticket_ticket"; type: "ticket_ticket";
id: number; id: number;
@ -135,9 +139,6 @@ interface BaseTicket<T extends "ticket_ticket:simple"|"ticket_ticket:extended" =
caller: Person | Thirdparty | null; caller: Person | Thirdparty | null;
} }
export interface SimpleTicket extends BaseTicket<"ticket_ticket:simple"> {
}
export interface TicketSimple extends BaseTicket<"ticket_ticket:simple"> { export interface TicketSimple extends BaseTicket<"ticket_ticket:simple"> {
type_extended: "ticket_ticket:simple"; type_extended: "ticket_ticket:simple";
} }

View File

@ -3,7 +3,7 @@
<div class="col-12"> <div class="col-12">
<pick-entity <pick-entity
uniqid="ticket-addressee-selector" uniqid="ticket-addressee-selector"
:types="['user', 'user_group', 'third_party']" :types="['user', 'user_group', 'thirdparty']"
:picked="selectedEntities" :picked="selectedEntities"
:suggested="suggestedValues" :suggested="suggestedValues"
:multiple="true" :multiple="true"
@ -46,33 +46,26 @@ watch(
() => { () => {
const modelValue = props.modelValue ?? []; const modelValue = props.modelValue ?? [];
suggestedValues.value = props.suggested.filter( suggestedValues.value = props.suggested.filter((suggested: Entities) => {
(suggested: Entities) => {
return !modelValue.some((selected: Entities) => { return !modelValue.some((selected: Entities) => {
if ( if (suggested.type == "user_group" && selected.type == "user_group") {
suggested.type == "user_group" &&
selected.type == "user_group"
) {
switch (selected.excludeKey) { switch (selected.excludeKey) {
case "level": case "level":
return suggested.excludeKey === "level"; return suggested.excludeKey === "level";
case "": case "":
return ( return (
suggested.excludeKey === "" && suggested.excludeKey === "" && suggested.id === selected.id
suggested.id === selected.id
); );
default: default:
return false; return false;
} }
} else { } else {
return ( return (
suggested.type === selected.type && suggested.type === selected.type && suggested.id === selected.id
suggested.id === selected.id
); );
} }
}); });
}, });
);
}, },
{ immediate: true, deep: true }, { immediate: true, deep: true },
); );

View File

@ -10,11 +10,7 @@
{{ trans(CHILL_TICKET_TICKET_BANNER_NO_MOTIVE) }} {{ trans(CHILL_TICKET_TICKET_BANNER_NO_MOTIVE) }}
</p> </p>
<h2 v-if="ticket.currentPersons.length"> <h2 v-if="ticket.currentPersons.length">
{{ {{ ticket.currentPersons.map((person) => person.text).join(", ") }}
ticket.currentPersons
.map((person) => person.text)
.join(", ")
}}
</h2> </h2>
</div> </div>
@ -53,9 +49,7 @@
<Teleport to="#header-ticket-details"> <Teleport to="#header-ticket-details">
<div class="container-xxl"> <div class="container-xxl">
<div class="row justify-content-between"> <div class="row justify-content-between">
<div <div class="col-md-4 col-sm-12 d-flex flex-column align-items-start">
class="col-md-4 col-sm-12 d-flex flex-column align-items-start"
>
<h3 class="text-primary"> <h3 class="text-primary">
{{ trans(CHILL_TICKET_TICKET_BANNER_CALLER) }} {{ trans(CHILL_TICKET_TICKET_BANNER_CALLER) }}
</h3> </h3>
@ -64,14 +58,12 @@
:key="ticket.caller.id" :key="ticket.caller.id"
:type="ticket.caller.type" :type="ticket.caller.type"
:id="ticket.caller.id" :id="ticket.caller.id"
:buttonText="ticket.caller.textAge" :buttonText="ticket.caller.text"
:displayBadge="'true' === 'true'" :displayBadge="'true' === 'true'"
action="show" action="show"
></on-the-fly> ></on-the-fly>
</div> </div>
<div <div class="col-md-4 col-sm-12 d-flex flex-column align-items-start">
class="col-md-4 col-sm-12 d-flex flex-column align-items-start"
>
<h3 class="text-primary"> <h3 class="text-primary">
{{ trans(CHILL_TICKET_TICKET_BANNER_CONCERNED_USAGER) }} {{ trans(CHILL_TICKET_TICKET_BANNER_CONCERNED_USAGER) }}
</h3> </h3>
@ -85,15 +77,11 @@
action="show" action="show"
></on-the-fly> ></on-the-fly>
</div> </div>
<div <div class="col-md-4 col-sm-12 d-flex flex-column align-items-start">
class="col-md-4 col-sm-12 d-flex flex-column align-items-start"
>
<h3 class="text-primary"> <h3 class="text-primary">
{{ trans(CHILL_TICKET_TICKET_BANNER_SPEAKER) }} {{ trans(CHILL_TICKET_TICKET_BANNER_SPEAKER) }}
</h3> </h3>
<addressee-component <addressee-component :addressees="ticket.currentAddressees" />
:addressees="ticket.currentAddressees"
/>
</div> </div>
</div> </div>
</div> </div>
@ -165,9 +153,7 @@ const since = computed(() => {
const timeDiff = Math.abs(today.value.getTime() - date.getTime()); const timeDiff = Math.abs(today.value.getTime() - date.getTime());
const daysDiff = Math.floor(timeDiff / (1000 * 3600 * 24)); const daysDiff = Math.floor(timeDiff / (1000 * 3600 * 24));
const hoursDiff = Math.floor( const hoursDiff = Math.floor((timeDiff % (1000 * 3600 * 24)) / (1000 * 3600));
(timeDiff % (1000 * 3600 * 24)) / (1000 * 3600),
);
const minutesDiff = Math.floor((timeDiff % (1000 * 3600)) / (1000 * 60)); const minutesDiff = Math.floor((timeDiff % (1000 * 3600)) / (1000 * 60));
const secondsDiff = Math.floor((timeDiff % (1000 * 60)) / 1000); const secondsDiff = Math.floor((timeDiff % (1000 * 60)) / 1000);
@ -177,9 +163,7 @@ const since = computed(() => {
parts.push(trans(CHILL_TICKET_TICKET_BANNER_DAYS, { count: daysDiff })); parts.push(trans(CHILL_TICKET_TICKET_BANNER_DAYS, { count: daysDiff }));
} }
if (hoursDiff > 0 || daysDiff > 0) { if (hoursDiff > 0 || daysDiff > 0) {
parts.push( parts.push(trans(CHILL_TICKET_TICKET_BANNER_HOURS, { count: hoursDiff }));
trans(CHILL_TICKET_TICKET_BANNER_HOURS, { count: hoursDiff }),
);
} }
if (minutesDiff > 0 || hoursDiff > 0 || daysDiff > 0) { if (minutesDiff > 0 || hoursDiff > 0 || daysDiff > 0) {
parts.push( parts.push(

View File

@ -1,7 +1,7 @@
<template> <template>
<pick-entity <pick-entity
uniqid="ticket-person-selector" uniqid="ticket-person-selector"
:types="['person', 'third_party']" :types="['person', 'thirdparty']"
:picked="selectedEntity ? [selectedEntity] : []" :picked="selectedEntity ? [selectedEntity] : []"
:suggested="suggestedValues" :suggested="suggestedValues"
:multiple="false" :multiple="false"

View File

@ -11,9 +11,7 @@
class="history-header d-flex align-items-center justify-content-between" class="history-header d-flex align-items-center justify-content-between"
> >
<div class="d-flex align-items-center fw-bold"> <div class="d-flex align-items-center fw-bold">
<i <i :class="`${actionIcons[history_line.event_type]} me-1`"></i>
:class="`${actionIcons[history_line.event_type]} me-1`"
></i>
<span>{{ explainSentence(history_line) }}</span> <span>{{ explainSentence(history_line) }}</span>
<TicketHistoryStateComponent <TicketHistoryStateComponent
:new_state="history_line.data.new_state" :new_state="history_line.data.new_state"
@ -39,19 +37,17 @@
<div <div
class="card-body row" class="card-body row"
v-if=" v-if="
!['state_change', 'emergency_change'].includes( !['state_change', 'emergency_change'].includes(history_line.event_type)
history_line.event_type,
)
" "
> >
<ticket-history-person-component <ticket-history-person-component
:persons="history_line.data.persons" :entities="history_line.data.persons"
v-if="history_line.event_type == 'persons_state'" v-if="history_line.event_type == 'persons_state'"
/> />
<ticket-history-person-component <ticket-history-person-component
:persons=" :entities="
history_line.data.new_caller history_line.data.new_caller
? [history_line.data.new_caller] ? ([history_line.data.new_caller] as Person[] | Thirdparty[])
: [] : []
" "
v-if="history_line.event_type == 'set_caller'" v-if="history_line.event_type == 'set_caller'"
@ -82,6 +78,8 @@ import { useStore } from "vuex";
// Types // Types
import { DateTime } from "../../../../../../../ChillMainBundle/Resources/public/types"; import { DateTime } from "../../../../../../../ChillMainBundle/Resources/public/types";
import { TicketHistoryLine } from "../../../types"; import { TicketHistoryLine } from "../../../types";
import { Person } from "ChillPersonAssets/types";
import { Thirdparty } from "src/Bundle/ChillThirdPartyBundle/Resources/public/types";
// Components // Components
import TicketHistoryPersonComponent from "./TicketHistoryPersonComponent.vue"; import TicketHistoryPersonComponent from "./TicketHistoryPersonComponent.vue";

View File

@ -1,11 +1,11 @@
<template> <template>
<div class="col-12"> <div class="col-12">
<ul class="persons-list" v-if="persons.length > 0"> <ul class="persons-list" v-if="entities.length > 0">
<li v-for="person in persons" :key="person.id"> <li v-for="entity in entities" :key="entity.text">
<on-the-fly <on-the-fly
:type="person.type" :type="entity.type"
:id="person.id" :id="entity.id"
:buttonText="person.textAge" :buttonText="entity.text"
:displayBadge="true" :displayBadge="true"
action="show" action="show"
></on-the-fly> ></on-the-fly>
@ -20,8 +20,9 @@ import OnTheFly from "ChillMainAssets/vuejs/OnTheFly/components/OnTheFly.vue";
// Types // Types
import { Person } from "ChillPersonAssets/types"; import { Person } from "ChillPersonAssets/types";
import { Thirdparty } from "src/Bundle/ChillThirdPartyBundle/Resources/public/types";
defineProps<{ persons: Person[] }>(); defineProps<{ entities: Person[] | Thirdparty[] }>();
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>