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;
}
export type PrivateCommentEmbeddable = any;
export interface PrivateCommentEmbeddable {
comments: Record<number, string>;
}

View File

@ -16,7 +16,7 @@ const appMessages = {
user_one: "Utilisateur",
thirdparty_one: "Tiers",
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";
document.addEventListener("DOMContentLoaded", () => {
const el = document.getElementById('linked-acpw-selector');
if (el) {
const accompanyingPeriodId = el.dataset.accompanyingPeriod;
createApp(AccompanyingPeriodWorkSelectorModal, { accompanyingPeriodId }).mount(el);
}
const el = document.getElementById("linked-acpw-selector");
if (el) {
const accompanyingPeriodId = el.dataset.accompanyingPeriod;
createApp(AccompanyingPeriodWorkSelectorModal, {
accompanyingPeriodId,
}).mount(el);
}
});

View File

@ -7,10 +7,11 @@ import {
User,
WorkflowAvailable,
Job,
PrivateCommentEmbeddable,
} from "ChillMainAssets/types";
import { StoredObject } from "ChillDocStoreAssets/types";
import {Thirdparty} from "../../../ChillThirdPartyBundle/Resources/public/types";
import {Calendar} from "../../../ChillCalendarBundle/Resources/public/types";
import { Thirdparty } from "../../../ChillThirdPartyBundle/Resources/public/types";
import { Calendar } from "../../../ChillCalendarBundle/Resources/public/types";
export interface Person {
id: number;
@ -45,7 +46,7 @@ export interface AccompanyingPeriod {
createdAt?: Date | null;
createdBy?: User | null;
emergency: boolean;
intensity?: 'occasional' | 'regular';
intensity?: "occasional" | "regular";
job?: Job | null;
locationHistories: AccompanyingPeriodLocationHistory[];
openingDate?: Date | null;
@ -61,7 +62,12 @@ export interface AccompanyingPeriod {
resources: AccompanyingPeriodResource[];
scopes: Scope[];
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 {
@ -102,7 +108,7 @@ export interface AccompanyingPeriodWork {
}
interface SocialAction {
id?: number;
id: number;
parent?: SocialAction | null;
children: SocialAction[];
issue?: SocialIssue | null;
@ -162,11 +168,86 @@ export interface AccompanyingPeriodLocationHistory {
personLocation?: Person | null;
}
type SocialIssue = any;
type Goal = any;
type Result = any;
type Evaluation = any;
type AccompanyingPeriodWorkEvaluation = any;
type AccompanyingPeriodWorkGoal = any;
type PrivateCommentEmbeddable = any;
type AccompanyingPeriodWorkReferrerHistory = any;
export interface SocialIssue {
id: number;
parent?: SocialIssue | null;
children: SocialIssue[];
socialActions?: SocialAction[] | null;
ordering: number;
title: {
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>
<div class="container">
<div class="item-bloc">
<div class="item-row">
<h2 class="badge-title">
<span class="title_label"></span>
<span class="title_action">
<span class="chill-entity entity-social-action">
<span class="badge bg-light text-dark">
{{ acpw?.socialAction?.title.fr }}
<div class="container">
<div class="item-bloc">
<div class="item-row">
<h2 class="badge-title">
<span class="title_label"></span>
<span class="title_action">
<span class="chill-entity entity-social-action">
<span class="badge bg-light text-dark">
{{ 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>
<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>
</h2>
</div>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import {ACCOMPANYING_COURSE_WORK_END_DATE, ACCOMPANYING_COURSE_WORK_START_DATE, trans} from "translator";
import {ISOToDate} from "ChillMainAssets/chill/js/date";
import {DateTime} from "ChillMainAssets/types";
import {AccompanyingPeriodWork} from "../../../types";
import {
ACCOMPANYING_COURSE_WORK_END_DATE,
ACCOMPANYING_COURSE_WORK_START_DATE,
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 formatDate = (dateObject: DateTime) => {
if(dateObject) {
if (dateObject) {
const parsedDate = ISOToDate(dateObject.datetime);
if (parsedDate) {
return new Intl.DateTimeFormat('default', { dateStyle: 'short' }).format(parsedDate);
return new Intl.DateTimeFormat("default", { dateStyle: "short" }).format(
parsedDate,
);
} else {
return '';
return "";
}
}
};

View File

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

View File

@ -4,7 +4,9 @@
<div class="col-md-6 col-sm-10" v-if="selectedAcpw">
<ul class="list-suggest remove-items">
<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>
</ul>
</div>
@ -19,36 +21,43 @@
</ul>
<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>
<h3>{{ trans(ACPW_DUPLICATE_SELECT_ACCOMPANYING_PERIOD_WORK) }}</h3>
</template>
<template #body>
<accompanying-period-work-list
:accompanying-period-works="accompanyingPeriodWorks"
v-model:selectedAcpw="selectedAcpw"
:accompanying-period-works="accompanyingPeriodWorks"
v-model:selectedAcpw="selectedAcpw"
/>
</template>
<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>
</modal>
</teleport>
</div>
</template>
<script setup lang="ts">
import {ref, watch, onMounted, Ref} from "vue";
import Modal from "ChillMainAssets/vuejs/_components/Modal.vue"
import { ref, watch, onMounted } from "vue";
import Modal from "ChillMainAssets/vuejs/_components/Modal.vue";
import AccompanyingPeriodWorkList from "./AccompanyingPeriodWorkList.vue";
import { AccompanyingPeriodWork} from "../../../types";
import { trans, ACPW_DUPLICATE_SELECT_ACCOMPANYING_PERIOD_WORK, SOCIAL_ACTION, CONFIRM } from "translator";
import {makeFetch} from "ChillMainAssets/lib/api/apiMethods";
import {DateTime} from "ChillMainAssets/types";
import {ISOToDate} from "ChillMainAssets/chill/js/date";
import { AccompanyingPeriodWork } from "../../../types";
import {
trans,
ACPW_DUPLICATE_SELECT_ACCOMPANYING_PERIOD_WORK,
CONFIRM,
} from "translator";
import { makeFetch } from "ChillMainAssets/lib/api/apiMethods";
const selectedAcpw = ref<AccompanyingPeriodWork | null>(null);
const showModal = ref(false);
@ -61,39 +70,30 @@ onMounted(() => {
if (props.accompanyingPeriodId) {
getAccompanyingPeriodWorks(parseInt(props.accompanyingPeriodId));
} else {
console.error("No accompanyingperiod id was given")
console.error("No accompanyingperiod id was given");
}
});
const getAccompanyingPeriodWorks = (periodId: number) => {
const url = `/api/1.0/person/accompanying-course/${periodId}/works.json`;
makeFetch<number, AccompanyingPeriodWork[]>("GET", url)
.then((response) => {
accompanyingPeriodWorks.value = response;
})
.catch((error) => {
console.log(error)
});
.then((response) => {
accompanyingPeriodWorks.value = response;
})
.catch((error) => {
console.log(error);
});
};
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) {
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 closeModal = () => (showModal.value = false);
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;