mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-07-08 18:06:14 +00:00
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:
commit
2a54d1b909
4
.prettierrc
Normal file
4
.prettierrc
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"tabWidth": 2,
|
||||
"useTabs": false
|
||||
}
|
@ -53,24 +53,6 @@ export interface User {
|
||||
label: string;
|
||||
// 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 {
|
||||
type: "user_group";
|
||||
|
@ -296,15 +296,11 @@ function saveAction() {
|
||||
id: data.civility.id,
|
||||
}
|
||||
: null;
|
||||
data.profession =
|
||||
data.profession !== "" ? data.profession : "";
|
||||
data.profession = data.profession !== "" ? data.profession : "";
|
||||
} else {
|
||||
type = castNew.value.radioType;
|
||||
data = castNew.value.castDataByType();
|
||||
if (
|
||||
typeof data.civility !== "undefined" &&
|
||||
null !== data.civility
|
||||
) {
|
||||
if (typeof data.civility !== "undefined" && null !== data.civility) {
|
||||
data.civility =
|
||||
data.civility !== null
|
||||
? {
|
||||
@ -317,8 +313,7 @@ function saveAction() {
|
||||
typeof data.profession !== "undefined" &&
|
||||
"" !== data.profession
|
||||
) {
|
||||
data.profession =
|
||||
data.profession !== "" ? data.profession : "";
|
||||
data.profession = data.profession !== "" ? data.profession : "";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -1,11 +1,7 @@
|
||||
<template>
|
||||
<div class="grey-card">
|
||||
<ul :class="listClasses" v-if="picked.length && displayPicked">
|
||||
<li
|
||||
v-for="p in picked"
|
||||
@click="removeEntity(p)"
|
||||
:key="p.type + p.id"
|
||||
>
|
||||
<li v-for="p in picked" @click="removeEntity(p)" :key="p.type + p.id">
|
||||
<span
|
||||
:class="getBadgeClass(p)"
|
||||
class="chill_denomination"
|
||||
@ -104,7 +100,7 @@ const translatedListOfTypes = computed(() => {
|
||||
return trans(PICK_ENTITY_PERSON, {
|
||||
count: props.multiple ? 2 : 1,
|
||||
});
|
||||
case "third_party":
|
||||
case "thirdparty":
|
||||
return trans(PICK_ENTITY_THIRDPARTY, {
|
||||
count: props.multiple ? 2 : 1,
|
||||
});
|
||||
|
@ -7,7 +7,6 @@ import {
|
||||
User,
|
||||
UserGroup,
|
||||
Household,
|
||||
ThirdParty,
|
||||
WorkflowAvailable,
|
||||
Scope,
|
||||
Job,
|
||||
@ -16,6 +15,11 @@ import {
|
||||
import { Thirdparty } from "../../../ChillThirdPartyBundle/Resources/public/types";
|
||||
import { Calendar } from "../../../ChillCalendarBundle/Resources/public/types";
|
||||
|
||||
export interface AltName {
|
||||
label: string;
|
||||
key: string;
|
||||
}
|
||||
|
||||
export interface Person {
|
||||
id: number;
|
||||
type: "person";
|
||||
@ -23,6 +27,8 @@ export interface Person {
|
||||
textAge: string;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
altNames: AltName[];
|
||||
suffixText: string;
|
||||
current_household_address: Address | null;
|
||||
birthdate: DateTime | null;
|
||||
deathdate: DateTime | null;
|
||||
@ -247,10 +253,10 @@ export type EntityType =
|
||||
| "user_group"
|
||||
| "user"
|
||||
| "person"
|
||||
| "third_party"
|
||||
| "thirdparty"
|
||||
| "household";
|
||||
|
||||
export type Entities = (UserGroup | User | Person | ThirdParty | Household) & {
|
||||
export type Entities = (UserGroup | User | Person | Thirdparty | Household) & {
|
||||
address?: Address | null;
|
||||
kind?: string;
|
||||
text?: string;
|
||||
|
@ -23,6 +23,7 @@ import { computed, defineProps } from "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";
|
||||
import { Person } from "ChillPersonAssets/types";
|
||||
|
||||
function formatDate(dateString: string | undefined, format: string) {
|
||||
if (!dateString) return "";
|
||||
@ -36,15 +37,7 @@ function formatDate(dateString: string | undefined, format: string) {
|
||||
|
||||
const props = defineProps<{
|
||||
item: {
|
||||
result: {
|
||||
id: number | string;
|
||||
birthdate: { datetime: string } | null;
|
||||
current_household_address: {
|
||||
text: string;
|
||||
postcode: { name: string };
|
||||
} | null;
|
||||
// add other fields as needed
|
||||
};
|
||||
result: Person; // add other fields as needed
|
||||
};
|
||||
}>();
|
||||
|
||||
|
@ -36,8 +36,8 @@ 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 { useToast } from "vue-toast-notification";
|
||||
import { ThirdParty } from "ChillMainAssets/types";
|
||||
import { Result, Suggestion } from "ChillPersonAssets/types";
|
||||
import { Thirdparty } from "src/Bundle/ChillThirdPartyBundle/Resources/public/types";
|
||||
|
||||
interface TypeThirdPartyProps {
|
||||
item: Suggestion;
|
||||
@ -76,7 +76,7 @@ const getAddress = computed(() => {
|
||||
return null;
|
||||
});
|
||||
|
||||
function saveFormOnTheFly({ data }: { data: ThirdParty }) {
|
||||
function saveFormOnTheFly({ data }: { data: Thirdparty }) {
|
||||
makeFetch("POST", "/api/1.0/thirdparty/thirdparty.json", data)
|
||||
.then((response: unknown) => {
|
||||
const result = response as Result;
|
||||
|
@ -23,22 +23,7 @@
|
||||
<script lang="ts" setup>
|
||||
import { computed, toRefs } from "vue";
|
||||
import { trans, RENDERBOX_YEARS_OLD } from "translator";
|
||||
|
||||
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;
|
||||
}
|
||||
import { AltName, Person } from "ChillPersonAssets/types";
|
||||
|
||||
const props = defineProps<{
|
||||
person: Person;
|
||||
|
@ -7,6 +7,8 @@ import {
|
||||
} from "ChillMainAssets/types";
|
||||
|
||||
export interface Thirdparty {
|
||||
type: "thirdparty";
|
||||
text: string;
|
||||
acronym: string | null;
|
||||
active: boolean;
|
||||
address: Address | null;
|
||||
|
@ -77,7 +77,7 @@ export interface PersonsState {
|
||||
persons: Person[];
|
||||
}
|
||||
export interface CallerState {
|
||||
new_caller: Person | null;
|
||||
new_caller: Person | Thirdparty | null;
|
||||
}
|
||||
|
||||
export interface StateChange {
|
||||
@ -122,7 +122,11 @@ export type TicketHistoryLine =
|
||||
| EmergencyStateEvent
|
||||
| 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: "ticket_ticket";
|
||||
id: number;
|
||||
@ -135,9 +139,6 @@ interface BaseTicket<T extends "ticket_ticket:simple"|"ticket_ticket:extended" =
|
||||
caller: Person | Thirdparty | null;
|
||||
}
|
||||
|
||||
export interface SimpleTicket extends BaseTicket<"ticket_ticket:simple"> {
|
||||
}
|
||||
|
||||
export interface TicketSimple extends BaseTicket<"ticket_ticket:simple"> {
|
||||
type_extended: "ticket_ticket:simple";
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
<div class="col-12">
|
||||
<pick-entity
|
||||
uniqid="ticket-addressee-selector"
|
||||
:types="['user', 'user_group', 'third_party']"
|
||||
:types="['user', 'user_group', 'thirdparty']"
|
||||
:picked="selectedEntities"
|
||||
:suggested="suggestedValues"
|
||||
:multiple="true"
|
||||
@ -46,33 +46,26 @@ watch(
|
||||
() => {
|
||||
const modelValue = props.modelValue ?? [];
|
||||
|
||||
suggestedValues.value = props.suggested.filter(
|
||||
(suggested: Entities) => {
|
||||
suggestedValues.value = props.suggested.filter((suggested: Entities) => {
|
||||
return !modelValue.some((selected: Entities) => {
|
||||
if (
|
||||
suggested.type == "user_group" &&
|
||||
selected.type == "user_group"
|
||||
) {
|
||||
if (suggested.type == "user_group" && selected.type == "user_group") {
|
||||
switch (selected.excludeKey) {
|
||||
case "level":
|
||||
return suggested.excludeKey === "level";
|
||||
case "":
|
||||
return (
|
||||
suggested.excludeKey === "" &&
|
||||
suggested.id === selected.id
|
||||
suggested.excludeKey === "" && suggested.id === selected.id
|
||||
);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return (
|
||||
suggested.type === selected.type &&
|
||||
suggested.id === selected.id
|
||||
suggested.type === selected.type && suggested.id === selected.id
|
||||
);
|
||||
}
|
||||
});
|
||||
},
|
||||
);
|
||||
});
|
||||
},
|
||||
{ immediate: true, deep: true },
|
||||
);
|
||||
|
@ -10,11 +10,7 @@
|
||||
{{ trans(CHILL_TICKET_TICKET_BANNER_NO_MOTIVE) }}
|
||||
</p>
|
||||
<h2 v-if="ticket.currentPersons.length">
|
||||
{{
|
||||
ticket.currentPersons
|
||||
.map((person) => person.text)
|
||||
.join(", ")
|
||||
}}
|
||||
{{ ticket.currentPersons.map((person) => person.text).join(", ") }}
|
||||
</h2>
|
||||
</div>
|
||||
|
||||
@ -53,9 +49,7 @@
|
||||
<Teleport to="#header-ticket-details">
|
||||
<div class="container-xxl">
|
||||
<div class="row justify-content-between">
|
||||
<div
|
||||
class="col-md-4 col-sm-12 d-flex flex-column align-items-start"
|
||||
>
|
||||
<div class="col-md-4 col-sm-12 d-flex flex-column align-items-start">
|
||||
<h3 class="text-primary">
|
||||
{{ trans(CHILL_TICKET_TICKET_BANNER_CALLER) }}
|
||||
</h3>
|
||||
@ -64,14 +58,12 @@
|
||||
:key="ticket.caller.id"
|
||||
:type="ticket.caller.type"
|
||||
:id="ticket.caller.id"
|
||||
:buttonText="ticket.caller.textAge"
|
||||
:buttonText="ticket.caller.text"
|
||||
:displayBadge="'true' === 'true'"
|
||||
action="show"
|
||||
></on-the-fly>
|
||||
</div>
|
||||
<div
|
||||
class="col-md-4 col-sm-12 d-flex flex-column align-items-start"
|
||||
>
|
||||
<div class="col-md-4 col-sm-12 d-flex flex-column align-items-start">
|
||||
<h3 class="text-primary">
|
||||
{{ trans(CHILL_TICKET_TICKET_BANNER_CONCERNED_USAGER) }}
|
||||
</h3>
|
||||
@ -85,15 +77,11 @@
|
||||
action="show"
|
||||
></on-the-fly>
|
||||
</div>
|
||||
<div
|
||||
class="col-md-4 col-sm-12 d-flex flex-column align-items-start"
|
||||
>
|
||||
<div class="col-md-4 col-sm-12 d-flex flex-column align-items-start">
|
||||
<h3 class="text-primary">
|
||||
{{ trans(CHILL_TICKET_TICKET_BANNER_SPEAKER) }}
|
||||
</h3>
|
||||
<addressee-component
|
||||
:addressees="ticket.currentAddressees"
|
||||
/>
|
||||
<addressee-component :addressees="ticket.currentAddressees" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -165,9 +153,7 @@ const since = computed(() => {
|
||||
|
||||
const timeDiff = Math.abs(today.value.getTime() - date.getTime());
|
||||
const daysDiff = Math.floor(timeDiff / (1000 * 3600 * 24));
|
||||
const hoursDiff = Math.floor(
|
||||
(timeDiff % (1000 * 3600 * 24)) / (1000 * 3600),
|
||||
);
|
||||
const hoursDiff = Math.floor((timeDiff % (1000 * 3600 * 24)) / (1000 * 3600));
|
||||
const minutesDiff = Math.floor((timeDiff % (1000 * 3600)) / (1000 * 60));
|
||||
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 }));
|
||||
}
|
||||
if (hoursDiff > 0 || daysDiff > 0) {
|
||||
parts.push(
|
||||
trans(CHILL_TICKET_TICKET_BANNER_HOURS, { count: hoursDiff }),
|
||||
);
|
||||
parts.push(trans(CHILL_TICKET_TICKET_BANNER_HOURS, { count: hoursDiff }));
|
||||
}
|
||||
if (minutesDiff > 0 || hoursDiff > 0 || daysDiff > 0) {
|
||||
parts.push(
|
||||
|
@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<pick-entity
|
||||
uniqid="ticket-person-selector"
|
||||
:types="['person', 'third_party']"
|
||||
:types="['person', 'thirdparty']"
|
||||
:picked="selectedEntity ? [selectedEntity] : []"
|
||||
:suggested="suggestedValues"
|
||||
:multiple="false"
|
||||
|
@ -11,9 +11,7 @@
|
||||
class="history-header d-flex align-items-center justify-content-between"
|
||||
>
|
||||
<div class="d-flex align-items-center fw-bold">
|
||||
<i
|
||||
:class="`${actionIcons[history_line.event_type]} me-1`"
|
||||
></i>
|
||||
<i :class="`${actionIcons[history_line.event_type]} me-1`"></i>
|
||||
<span>{{ explainSentence(history_line) }}</span>
|
||||
<TicketHistoryStateComponent
|
||||
:new_state="history_line.data.new_state"
|
||||
@ -39,19 +37,17 @@
|
||||
<div
|
||||
class="card-body row"
|
||||
v-if="
|
||||
!['state_change', 'emergency_change'].includes(
|
||||
history_line.event_type,
|
||||
)
|
||||
!['state_change', 'emergency_change'].includes(history_line.event_type)
|
||||
"
|
||||
>
|
||||
<ticket-history-person-component
|
||||
:persons="history_line.data.persons"
|
||||
:entities="history_line.data.persons"
|
||||
v-if="history_line.event_type == 'persons_state'"
|
||||
/>
|
||||
<ticket-history-person-component
|
||||
:persons="
|
||||
:entities="
|
||||
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'"
|
||||
@ -82,6 +78,8 @@ import { useStore } from "vuex";
|
||||
// Types
|
||||
import { DateTime } from "../../../../../../../ChillMainBundle/Resources/public/types";
|
||||
import { TicketHistoryLine } from "../../../types";
|
||||
import { Person } from "ChillPersonAssets/types";
|
||||
import { Thirdparty } from "src/Bundle/ChillThirdPartyBundle/Resources/public/types";
|
||||
|
||||
// Components
|
||||
import TicketHistoryPersonComponent from "./TicketHistoryPersonComponent.vue";
|
||||
|
@ -1,11 +1,11 @@
|
||||
<template>
|
||||
<div class="col-12">
|
||||
<ul class="persons-list" v-if="persons.length > 0">
|
||||
<li v-for="person in persons" :key="person.id">
|
||||
<ul class="persons-list" v-if="entities.length > 0">
|
||||
<li v-for="entity in entities" :key="entity.text">
|
||||
<on-the-fly
|
||||
:type="person.type"
|
||||
:id="person.id"
|
||||
:buttonText="person.textAge"
|
||||
:type="entity.type"
|
||||
:id="entity.id"
|
||||
:buttonText="entity.text"
|
||||
:displayBadge="true"
|
||||
action="show"
|
||||
></on-the-fly>
|
||||
@ -20,8 +20,9 @@ import OnTheFly from "ChillMainAssets/vuejs/OnTheFly/components/OnTheFly.vue";
|
||||
|
||||
// Types
|
||||
import { Person } from "ChillPersonAssets/types";
|
||||
import { Thirdparty } from "src/Bundle/ChillThirdPartyBundle/Resources/public/types";
|
||||
|
||||
defineProps<{ persons: Person[] }>();
|
||||
defineProps<{ entities: Person[] | Thirdparty[] }>();
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
Loading…
x
Reference in New Issue
Block a user