Fix eslint issues and add ts interfaces for typing

This commit is contained in:
Julie Lenaerts 2025-03-27 14:26:43 +01:00
parent 4cea678e93
commit bd4c34cc1d
10 changed files with 255 additions and 131 deletions

View File

@ -204,4 +204,6 @@ export interface WorkflowAttachment {
genericDoc: null | GenericDoc; genericDoc: null | GenericDoc;
} }
export type PrivateCommentEmbeddable = any; export interface PrivateCommentEmbeddable {
comments: Record<number, string>;
}

View File

@ -16,7 +16,7 @@ const appMessages = {
user_one: "Utilisateur", user_one: "Utilisateur",
thirdparty_one: "Tiers", thirdparty_one: "Tiers",
person_one: "Usager", person_one: "Usager",
acpw_one: "Action d'accompagnement" acpw_one: "Action d'accompagnement",
}, },
}, },
}; };

View File

@ -1,10 +1,12 @@
import { createApp } from 'vue'; import { createApp } from "vue";
import AccompanyingPeriodWorkSelectorModal from "../../vuejs/_components/AccompanyingPeriodWorkSelector/AccompanyingPeriodWorkSelectorModal.vue"; import AccompanyingPeriodWorkSelectorModal from "../../vuejs/_components/AccompanyingPeriodWorkSelector/AccompanyingPeriodWorkSelectorModal.vue";
document.addEventListener("DOMContentLoaded", () => { document.addEventListener("DOMContentLoaded", () => {
const el = document.getElementById('linked-acpw-selector'); const el = document.getElementById("linked-acpw-selector");
if (el) { if (el) {
const accompanyingPeriodId = el.dataset.accompanyingPeriod; const accompanyingPeriodId = el.dataset.accompanyingPeriod;
createApp(AccompanyingPeriodWorkSelectorModal, { accompanyingPeriodId }).mount(el); createApp(AccompanyingPeriodWorkSelectorModal, {
} accompanyingPeriodId,
}).mount(el);
}
}); });

View File

@ -7,10 +7,11 @@ import {
User, User,
WorkflowAvailable, WorkflowAvailable,
Job, Job,
PrivateCommentEmbeddable,
} from "ChillMainAssets/types"; } from "ChillMainAssets/types";
import { StoredObject } from "ChillDocStoreAssets/types"; import { StoredObject } from "ChillDocStoreAssets/types";
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 Person { export interface Person {
id: number; id: number;
@ -45,7 +46,7 @@ export interface AccompanyingPeriod {
createdAt?: Date | null; createdAt?: Date | null;
createdBy?: User | null; createdBy?: User | null;
emergency: boolean; emergency: boolean;
intensity?: 'occasional' | 'regular'; intensity?: "occasional" | "regular";
job?: Job | null; job?: Job | null;
locationHistories: AccompanyingPeriodLocationHistory[]; locationHistories: AccompanyingPeriodLocationHistory[];
openingDate?: Date | null; openingDate?: Date | null;
@ -61,7 +62,12 @@ export interface AccompanyingPeriod {
resources: AccompanyingPeriodResource[]; resources: AccompanyingPeriodResource[];
scopes: Scope[]; scopes: Scope[];
socialIssues: SocialIssue[]; socialIssues: SocialIssue[];
step?: 'CLOSED' | 'CONFIRMED' | 'CONFIRMED_INACTIVE_SHORT' | 'CONFIRMED_INACTIVE_LONG' | 'DRAFT'; step?:
| "CLOSED"
| "CONFIRMED"
| "CONFIRMED_INACTIVE_SHORT"
| "CONFIRMED_INACTIVE_LONG"
| "DRAFT";
} }
export interface AccompanyingPeriodWorkEvaluationDocument { export interface AccompanyingPeriodWorkEvaluationDocument {
@ -102,7 +108,7 @@ export interface AccompanyingPeriodWork {
} }
interface SocialAction { interface SocialAction {
id?: number; id: number;
parent?: SocialAction | null; parent?: SocialAction | null;
children: SocialAction[]; children: SocialAction[];
issue?: SocialIssue | null; issue?: SocialIssue | null;
@ -162,11 +168,86 @@ export interface AccompanyingPeriodLocationHistory {
personLocation?: Person | null; personLocation?: Person | null;
} }
type SocialIssue = any; export interface SocialIssue {
type Goal = any; id: number;
type Result = any; parent?: SocialIssue | null;
type Evaluation = any; children: SocialIssue[];
type AccompanyingPeriodWorkEvaluation = any; socialActions?: SocialAction[] | null;
type AccompanyingPeriodWorkGoal = any; ordering: number;
type PrivateCommentEmbeddable = any; title: {
type AccompanyingPeriodWorkReferrerHistory = any; fr: string;
};
desactivationDate?: string | null;
}
export interface Goal {
id: number;
results: Result[];
socialActions?: SocialAction[] | null;
title: {
fr: string;
};
}
export interface Result {
id: number;
accompanyingPeriodWorks: AccompanyingPeriodWork[];
accompanyingPeriodWorkGoals: AccompanyingPeriodWorkGoal[];
goals: Goal[];
socialActions: SocialAction[];
title: {
fr: string;
};
desactivationDate?: string | null;
}
export interface AccompanyingPeriodWorkGoal {
id: number;
accompanyingPeriodWork: AccompanyingPeriodWork;
goal: Goal;
note: string;
results: Result[];
}
export interface AccompanyingPeriodWorkEvaluation {
accompanyingPeriodWork: AccompanyingPeriodWork | null;
comment: string;
createdAt: DateTime | null;
createdBy: User | null;
documents: AccompanyingPeriodWorkEvaluationDocument[];
endDate: DateTime | null;
evaluation: Evaluation | null;
id: number | null;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
key: any;
maxDate: DateTime | null;
startDate: DateTime | null;
updatedAt: DateTime | null;
updatedBy: User | null;
warningInterval: string | null;
timeSpent: number | null;
}
export interface Evaluation {
id: number;
url: string;
socialActions: SocialAction[];
title: {
fr: string;
};
active: boolean;
delay: string;
notificationDelay: string;
}
export interface AccompanyingPeriodWorkReferrerHistory {
id: number;
accompanyingPeriodWork: AccompanyingPeriodWork;
user: User;
startDate: DateTime;
endDate: DateTime | null;
createdAt: DateTime;
updatedAt: DateTime | null;
createdBy: User;
updatedBy: User | null;
}

View File

@ -1,52 +1,59 @@
<template> <template>
<div class="container"> <div class="container">
<div class="item-bloc"> <div class="item-bloc">
<div class="item-row"> <div class="item-row">
<h2 class="badge-title"> <h2 class="badge-title">
<span class="title_label"></span> <span class="title_label"></span>
<span class="title_action"> <span class="title_action">
<span class="chill-entity entity-social-action"> <span class="chill-entity entity-social-action">
<span class="badge bg-light text-dark"> <span class="badge bg-light text-dark">
{{ acpw?.socialAction?.title.fr }} {{ acpw?.socialAction?.title.fr }}
</span>
</span>
<ul class="small_in_title columns mt-1">
<li>
<span class="item-key">
{{ trans(ACCOMPANYING_COURSE_WORK_START_DATE) }} :
</span>
<b>{{ formatDate(acpw.startDate) }}</b>
</li>
<li v-if="acpw.endDate">
<span class="item-key">
{{ trans(ACCOMPANYING_COURSE_WORK_END_DATE) }} :
</span>
<b>{{ formatDate(acpw.endDate) }}</b>
</li>
</ul>
</span> </span>
</span> </h2>
</div>
<ul class="small_in_title columns mt-1">
<li>
<span class="item-key">
{{ trans(ACCOMPANYING_COURSE_WORK_START_DATE) }} :
</span>
<b>{{ formatDate(acpw.startDate) }}</b>
</li>
<li v-if="acpw.endDate">
<span class="item-key">
{{ trans(ACCOMPANYING_COURSE_WORK_END_DATE) }} :
</span>
<b>{{ formatDate(acpw.endDate) }}</b>
</li>
</ul>
</span>
</h2>
</div> </div>
</div> </div>
</div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import {ACCOMPANYING_COURSE_WORK_END_DATE, ACCOMPANYING_COURSE_WORK_START_DATE, trans} from "translator"; import {
import {ISOToDate} from "ChillMainAssets/chill/js/date"; ACCOMPANYING_COURSE_WORK_END_DATE,
import {DateTime} from "ChillMainAssets/types"; ACCOMPANYING_COURSE_WORK_START_DATE,
import {AccompanyingPeriodWork} from "../../../types"; trans,
} from "translator";
import { ISOToDate } from "ChillMainAssets/chill/js/date";
import { DateTime } from "ChillMainAssets/types";
import { AccompanyingPeriodWork } from "../../../types";
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const props = defineProps<{ acpw: AccompanyingPeriodWork }>(); const props = defineProps<{ acpw: AccompanyingPeriodWork }>();
const formatDate = (dateObject: DateTime) => { const formatDate = (dateObject: DateTime) => {
if(dateObject) { if (dateObject) {
const parsedDate = ISOToDate(dateObject.datetime); const parsedDate = ISOToDate(dateObject.datetime);
if (parsedDate) { if (parsedDate) {
return new Intl.DateTimeFormat('default', { dateStyle: 'short' }).format(parsedDate); return new Intl.DateTimeFormat("default", { dateStyle: "short" }).format(
parsedDate,
);
} else { } else {
return ''; return "";
} }
} }
}; };

View File

@ -1,34 +1,43 @@
<template> <template>
<div class="results"> <div class="results">
<div v-for="acpw in accompanyingPeriodWorks" :key="acpw.id" class="list-item"> <div
<label class="acpw-item"> v-for="acpw in accompanyingPeriodWorks"
:key="acpw.id"
class="list-item"
>
<label class="acpw-item">
<div>
<input
type="radio"
:value="acpw"
v-model="selectedAcpw"
name="item"
/>
</div>
<div> <accompanying-period-work-item :acpw="acpw" />
<input type="radio" :value="acpw" v-model="selectedAcpw" name="item"/> </label>
</div>
<accompanying-period-work-item :acpw="acpw" />
</label>
</div>
</div> </div>
</div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import AccompanyingPeriodWorkItem import AccompanyingPeriodWorkItem from "./AccompanyingPeriodWorkItem.vue";
from "./AccompanyingPeriodWorkItem.vue"; import { AccompanyingPeriodWork } from "../../../types";
import { AccompanyingPeriodWork} from "../../../types"; import { defineProps, ref, watch } from "vue";
import {defineProps, ref, watch} from "vue";
const props = defineProps<{ accompanyingPeriodWorks: AccompanyingPeriodWork[] }>() // eslint-disable-next-line @typescript-eslint/no-unused-vars
const props = defineProps<{
accompanyingPeriodWorks: AccompanyingPeriodWork[];
}>();
const selectedAcpw = ref<AccompanyingPeriodWork | null>(null); const selectedAcpw = ref<AccompanyingPeriodWork | null>(null);
// eslint-disable-next-line vue/valid-define-emits
const emit = defineEmits(); const emit = defineEmits();
watch(selectedAcpw, (newValue) => { watch(selectedAcpw, (newValue) => {
emit('update:selectedAcpw', newValue); emit("update:selectedAcpw", newValue);
}); });
</script> </script>
<style> <style>

View File

@ -4,7 +4,9 @@
<div class="col-md-6 col-sm-10" v-if="selectedAcpw"> <div class="col-md-6 col-sm-10" v-if="selectedAcpw">
<ul class="list-suggest remove-items"> <ul class="list-suggest remove-items">
<li> <li>
<span @click="selectedAcpw = null" class="chill-denomination">{{ selectedAcpw?.socialAction?.title.fr }}</span> <span @click="selectedAcpw = null" class="chill-denomination">{{
selectedAcpw?.socialAction?.title.fr
}}</span>
</li> </li>
</ul> </ul>
</div> </div>
@ -19,36 +21,43 @@
</ul> </ul>
<teleport to="body"> <teleport to="body">
<modal v-if="showModal" @close="closeModal" modal-dialog-class="modal-dialog-scrollable modal-xl"> <modal
v-if="showModal"
@close="closeModal"
modal-dialog-class="modal-dialog-scrollable modal-xl"
>
<template #header> <template #header>
<h3>{{ trans(ACPW_DUPLICATE_SELECT_ACCOMPANYING_PERIOD_WORK) }}</h3> <h3>{{ trans(ACPW_DUPLICATE_SELECT_ACCOMPANYING_PERIOD_WORK) }}</h3>
</template> </template>
<template #body> <template #body>
<accompanying-period-work-list <accompanying-period-work-list
:accompanying-period-works="accompanyingPeriodWorks" :accompanying-period-works="accompanyingPeriodWorks"
v-model:selectedAcpw="selectedAcpw" v-model:selectedAcpw="selectedAcpw"
/> />
</template> </template>
<template #footer> <template #footer>
<button type="button" class="btn btn-save" @click="confirmSelection">{{ trans(CONFIRM) }}</button> <button type="button" class="btn btn-save" @click="confirmSelection">
{{ trans(CONFIRM) }}
</button>
</template> </template>
</modal> </modal>
</teleport> </teleport>
</div> </div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import {ref, watch, onMounted, Ref} from "vue"; import { ref, watch, onMounted } from "vue";
import Modal from "ChillMainAssets/vuejs/_components/Modal.vue" import Modal from "ChillMainAssets/vuejs/_components/Modal.vue";
import AccompanyingPeriodWorkList from "./AccompanyingPeriodWorkList.vue"; import AccompanyingPeriodWorkList from "./AccompanyingPeriodWorkList.vue";
import { AccompanyingPeriodWork} from "../../../types"; import { AccompanyingPeriodWork } from "../../../types";
import { trans, ACPW_DUPLICATE_SELECT_ACCOMPANYING_PERIOD_WORK, SOCIAL_ACTION, CONFIRM } from "translator"; import {
import {makeFetch} from "ChillMainAssets/lib/api/apiMethods"; trans,
import {DateTime} from "ChillMainAssets/types"; ACPW_DUPLICATE_SELECT_ACCOMPANYING_PERIOD_WORK,
import {ISOToDate} from "ChillMainAssets/chill/js/date"; CONFIRM,
} from "translator";
import { makeFetch } from "ChillMainAssets/lib/api/apiMethods";
const selectedAcpw = ref<AccompanyingPeriodWork | null>(null); const selectedAcpw = ref<AccompanyingPeriodWork | null>(null);
const showModal = ref(false); const showModal = ref(false);
@ -61,39 +70,30 @@ onMounted(() => {
if (props.accompanyingPeriodId) { if (props.accompanyingPeriodId) {
getAccompanyingPeriodWorks(parseInt(props.accompanyingPeriodId)); getAccompanyingPeriodWorks(parseInt(props.accompanyingPeriodId));
} else { } else {
console.error("No accompanyingperiod id was given") console.error("No accompanyingperiod id was given");
} }
}); });
const getAccompanyingPeriodWorks = (periodId: number) => { const getAccompanyingPeriodWorks = (periodId: number) => {
const url = `/api/1.0/person/accompanying-course/${periodId}/works.json`; const url = `/api/1.0/person/accompanying-course/${periodId}/works.json`;
makeFetch<number, AccompanyingPeriodWork[]>("GET", url) makeFetch<number, AccompanyingPeriodWork[]>("GET", url)
.then((response) => { .then((response) => {
accompanyingPeriodWorks.value = response; accompanyingPeriodWorks.value = response;
}) })
.catch((error) => { .catch((error) => {
console.log(error) console.log(error);
}); });
}; };
watch(selectedAcpw, (newValue) => { watch(selectedAcpw, (newValue) => {
const inputField = document.getElementById('find_accompanying_period_work_acpw') as HTMLInputElement; const inputField = document.getElementById(
"find_accompanying_period_work_acpw",
) as HTMLInputElement;
if (inputField) { if (inputField) {
inputField.value = String(newValue?.id); inputField.value = String(newValue?.id);
} }
}); });
const formatDate = (dateObject: DateTime) => {
if(dateObject) {
const parsedDate = ISOToDate(dateObject.datetime);
if (parsedDate) {
return new Intl.DateTimeFormat('default', { dateStyle: 'short' }).format(parsedDate);
} else {
return '';
}
}
};
const openModal = () => (showModal.value = true); const openModal = () => (showModal.value = true);
const closeModal = () => (showModal.value = false); const closeModal = () => (showModal.value = false);
const confirmSelection = () => { const confirmSelection = () => {

View File

@ -1,22 +0,0 @@
<template>
<div class="item-row">
<div class="item-col">
<h4 class="badge-title">
<span class="title_action">
{{ accompanyingPeriodWork.socialAction.title.fr }}
</span>
</h4>
</div>
</div>
</template>
<script setup lang="ts">
import TypeAccompanyingPeriodWork from "ChillPersonAssets/vuejs/_components/AddPersons/TypeAccompanyingPeriodWork.vue";
const props = defineProps({
accompanyingPeriodWork: TypeAccompanyingPeriodWork
})
</script>

View File

@ -1 +1,47 @@
export type Thirdparty = any; import {
Address,
Center,
Civility,
DateTime,
User,
} from "ChillMainAssets/types";
export interface Thirdparty {
acronym: string | null;
active: boolean;
address: Address | null;
canonicalized: string | null;
categories: ThirdpartyCategory[];
centers: Center[];
children: Thirdparty[];
civility: Civility | null;
comment: string | null;
contactDataAnonymous: boolean;
createdAt: DateTime;
createdBy: User | null;
email: string | null;
firstname: string | null;
id: number | null;
kind: string;
name: string;
nameCompany: string | null;
parent: Thirdparty | null;
profession: string;
telephone: string | null;
thirdPartyTypes: ThirdpartyType[] | null;
updatedAt: DateTime | null;
updatedBy: User | null;
}
interface ThirdpartyType {
key: string;
value: string;
}
export interface ThirdpartyCategory {
id: number;
active: boolean;
name: {
fr: string;
};
}

View File

@ -1 +0,0 @@
export type ThirdParty = any;