Change behavior of information exchange between backend and frontend

This commit is contained in:
Julie Lenaerts 2025-03-11 07:19:52 +01:00
parent ae679e6997
commit ed71cffd6a
7 changed files with 147 additions and 26 deletions

View File

@ -33,8 +33,7 @@ class AccompanyingPeriodWorkDuplicateController extends AbstractController
public function assignDuplicate(AccompanyingPeriodWork $acpw, Request $request) public function assignDuplicate(AccompanyingPeriodWork $acpw, Request $request)
{ {
$accompanyingPeriod = $acpw->getAccompanyingPeriod(); $accompanyingPeriod = $acpw->getAccompanyingPeriod();
/* $acpwArray = $this->accompanyingPeriodWorkRepository->findByAccompanyingPeriod($accompanyingPeriod);
$acpwArray = $this->accompanyingPeriodWorkRepository->findByAccompanyingPeriod($accompanyingPeriod);
$acpwArray = array_map(function ($acpw) { $acpwArray = array_map(function ($acpw) {
return [ return [
@ -43,7 +42,7 @@ class AccompanyingPeriodWorkDuplicateController extends AbstractController
'startDate' => $acpw->getStartDate(), 'startDate' => $acpw->getStartDate(),
'endDate' => $acpw->getEndDate(), 'endDate' => $acpw->getEndDate(),
]; ];
}, $acpwArray); }, $acpwArray);*/
$this->denyAccessUnlessGranted( $this->denyAccessUnlessGranted(
'CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_UPDATE', 'CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_UPDATE',
@ -76,8 +75,8 @@ class AccompanyingPeriodWorkDuplicateController extends AbstractController
} }
return $this->render('@ChillPerson/AccompanyingPeriodWorkDuplicate/assign_acpw_duplicate.html.twig', [ return $this->render('@ChillPerson/AccompanyingPeriodWorkDuplicate/assign_acpw_duplicate.html.twig', [
'accompanyingCourse' => $acpw->getAccompanyingPeriod(), 'accompanyingCourse' => $accompanyingPeriod,
'acpwArray' => $acpwArray, // 'acpwArray' => $acpwArray,
'acpw' => $acpw, 'acpw' => $acpw,
'form' => $form->createView(), 'form' => $form->createView(),
]); ]);

View File

@ -4,7 +4,7 @@ import AccompanyingPeriodWorkSelectorModal from "../../vuejs/_components/Accompa
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 acpwList = JSON.parse(el.dataset.acpwArray); const accompanyingPeriodId = el.dataset.accompanyingPeriod;
createApp(AccompanyingPeriodWorkSelectorModal, { acpwList }).mount(el); createApp(AccompanyingPeriodWorkSelectorModal, { accompanyingPeriodId }).mount(el);
} }
}); });

View File

@ -1,13 +1,16 @@
import { import {
Address, Address,
Scope,
Center, Center,
Civility, Civility,
DateTime, DateTime,
User, User,
WorkflowAvailable, WorkflowAvailable,
} from "../../../ChillMainBundle/Resources/public/types"; Job,
import { StoredObject } from "../../../ChillDocStoreBundle/Resources/public/types"; } from "ChillMainAssets/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";
export interface Person { export interface Person {
id: number; id: number;
@ -30,6 +33,37 @@ export interface Person {
current_residential_addresses: Address[]; current_residential_addresses: Address[];
} }
export interface AccompanyingPeriod {
id: number;
addressLocation?: Address | null;
administrativeLocation?: Location | null;
calendars: Calendar[];
closingDate?: Date | null;
closingMotive?: ClosingMotive | null;
comments: Comment[];
confidential: boolean;
createdAt?: Date | null;
createdBy?: User | null;
emergency: boolean;
intensity?: 'occasional' | 'regular';
job?: Job | null;
locationHistories: AccompanyingPeriodLocationHistory[];
openingDate?: Date | null;
origin?: Origin | null;
participations: AccompanyingPeriodParticipation[];
personLocation?: Person | null;
pinnedComment?: Comment | null;
preventUserIsChangedNotification: boolean;
remark: string;
requestorAnonymous: boolean;
requestorPerson?: Person | null;
requestorThirdParty?: Thirdparty | null;
resources: AccompanyingPeriodResource[];
scopes: Scope[];
socialIssues: SocialIssue[];
step?: 'CLOSED' | 'CONFIRMED' | 'CONFIRMED_INACTIVE_SHORT' | 'CONFIRMED_INACTIVE_LONG' | 'DRAFT';
}
export interface AccompanyingPeriodWorkEvaluationDocument { export interface AccompanyingPeriodWorkEvaluationDocument {
id: number; id: number;
type: "accompanying_period_work_evaluation_document"; type: "accompanying_period_work_evaluation_document";
@ -73,7 +107,9 @@ interface SocialAction {
children: SocialAction[]; children: SocialAction[];
issue?: SocialIssue | null; issue?: SocialIssue | null;
ordering: number; ordering: number;
title: Record<string, string>; title: {
fr: string;
};
defaultNotificationDelay?: string | null; defaultNotificationDelay?: string | null;
desactivationDate?: string | null; desactivationDate?: string | null;
evaluations: Evaluation[]; evaluations: Evaluation[];
@ -81,11 +117,55 @@ interface SocialAction {
results: Result[]; results: Result[];
} }
export interface AccompanyingPeriodResource {
id: number;
accompanyingPeriod: AccompanyingPeriod;
comment?: string | null;
person?: Person | null;
thirdParty?: Thirdparty | null;
}
export interface Origin {
id: number;
label: {
fr: string;
};
noActiveAfter: DateTime;
}
export interface ClosingMotive {
id: number;
active: boolean;
name: {
fr: string;
};
ordering: number;
isCanceledAccompanyingPeriod: boolean;
parent?: ClosingMotive | null;
children: ClosingMotive[];
}
export interface AccompanyingPeriodParticipation {
id: number;
startDate: DateTime;
endDate?: DateTime | null;
accompanyingPeriod: AccompanyingPeriod;
person: Person;
}
export interface AccompanyingPeriodLocationHistory {
id: number;
startDate: DateTime;
endDate?: DateTime | null;
addressLocation?: Address | null;
period: AccompanyingPeriod;
personLocation?: Person | null;
}
type SocialIssue = any; type SocialIssue = any;
type Goal = any; type Goal = any;
type Result = any; type Result = any;
type Evaluation = any; type Evaluation = any;
type AccompanyingPeriod = any;
type AccompanyingPeriodWorkEvaluation = any; type AccompanyingPeriodWorkEvaluation = any;
type AccompanyingPeriodWorkGoal = any; type AccompanyingPeriodWorkGoal = any;
type PrivateCommentEmbeddable = any; type PrivateCommentEmbeddable = any;

View File

@ -7,7 +7,7 @@
<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 }} {{ acpw?.socialAction?.title.fr }}
</span> </span>
</span> </span>
@ -43,7 +43,7 @@ const props = defineProps<{ acpw: AccompanyingPeriodWork }>();
const formatDate = (dateObject) => { const formatDate = (dateObject) => {
if(dateObject) { if(dateObject) {
const parsedDate = ISOToDate(dateObject.date); const parsedDate = ISOToDate(dateObject.datetime);
return new Intl.DateTimeFormat('default', { dateStyle: 'short' }).format(parsedDate); return new Intl.DateTimeFormat('default', { dateStyle: 'short' }).format(parsedDate);
} }
}; };

View File

@ -1,6 +1,6 @@
<template> <template>
<div class="results"> <div class="results">
<div v-for="acpw in acpwList" :key="acpw.id" class="list-item"> <div v-for="acpw in accompanyingPeriodWorks" :key="acpw.id" class="list-item">
<label class="acpw-item"> <label class="acpw-item">
<div> <div>
@ -15,14 +15,19 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { defineProps, defineModel } from "vue";
import { AccompanyingPeriodWork } from "../../../types";
import AccompanyingPeriodWorkItem import AccompanyingPeriodWorkItem
from "ChillPersonAssets/vuejs/_components/AccompanyingPeriodWorkSelector/AccompanyingPeriodWorkItem.vue"; from "ChillPersonAssets/vuejs/_components/AccompanyingPeriodWorkSelector/AccompanyingPeriodWorkItem.vue";
import { AccompanyingPeriodWork} from "../../../types";
import {defineProps, ref, watch} from "vue";
const props = defineProps<{ acpwList: AccompanyingPeriodWork[] }>(); const props = defineProps<{ accompanyingPeriodWorks: AccompanyingPeriodWork[] }>()
const selectedAcpw = ref<AccompanyingPeriodWork | null>(null);
const emit = defineEmits();
watch(selectedAcpw, (newValue) => {
emit('update:selectedAcpw', newValue);
});
const selectedAcpw = defineModel<number | null>("selectedAcpw", { default: null });
</script> </script>
<style> <style>

View File

@ -1,5 +1,15 @@
<template> <template>
<div> <div>
<div class="row justify-content-end">
<div class="col-md-9 col-sm-12" v-if="selectedAcpw">
<ul class="list-suggest remove-items">
<li>
<span @click="selectedAcpw = null" class="chill-denomination">{{ trans(SOCIAL_ACTION) }}: {{ selectedAcpw.socialAction.title.fr }}</span>
</li>
</ul>
</div>
</div>
<ul class="record_actions"> <ul class="record_actions">
<li> <li>
<a class="btn btn-sm btn-create mt-3" @click="openModal"> <a class="btn btn-sm btn-create mt-3" @click="openModal">
@ -16,7 +26,7 @@
<template #body> <template #body>
<accompanying-period-work-list <accompanying-period-work-list
:acpw-list="acpwList" :accompanying-period-works="accompanyingPeriodWorks"
v-model:selectedAcpw="selectedAcpw" v-model:selectedAcpw="selectedAcpw"
/> />
</template> </template>
@ -27,24 +37,51 @@
</modal> </modal>
</teleport> </teleport>
<input type="hidden" name="form[acpw]" :value="selectedAcpw" />
</div> </div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref } from "vue"; import {ref, watch, onMounted, Ref} 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, CANCEL_1, CONFIRM } from "translator"; import { trans, ACPW_DUPLICATE_SELECT_ACCOMPANYING_PERIOD_WORK, SOCIAL_ACTION, CONFIRM } from "translator";
import {makeFetch} from "ChillMainAssets/lib/api/apiMethods";
const props = defineProps<{ acpwList: AccompanyingPeriodWork[] }>(); const selectedAcpw = ref<AccompanyingPeriodWork | null>(null);
const selectedAcpw = ref(null);
const showModal = ref(false); const showModal = ref(false);
const accompanyingPeriodWorks = ref([]);
const props = defineProps({
accompanyingPeriodId: String,
});
onMounted(() => {
getAccompanyingPeriodWorks(parseInt(props.accompanyingPeriodId));
});
const getAccompanyingPeriodWorks = (periodId: number) => {
const url = `/api/1.0/person/accompanying-course/${periodId}/works.json`;
makeFetch("GET", url)
.then((response) => {
accompanyingPeriodWorks.value = response;
})
.catch((error) => {
console.log(error)
});
};
watch(selectedAcpw, (newValue) => {
const inputField = document.getElementById('find_accompanying_period_work_acpw') as HTMLInputElement;
console.log('selected Acpw', newValue);
if (inputField) {
inputField.value = String(newValue?.id);
}
});
const openModal = () => (showModal.value = true); const openModal = () => (showModal.value = true);
const closeModal = () => (showModal.value = false); const closeModal = () => (showModal.value = false);
const confirmSelection = () => { const confirmSelection = () => {
selectedAcpw.value = selectedAcpw.value;
closeModal(); closeModal();
}; };
</script> </script>

View File

@ -11,7 +11,7 @@
{{ form_start(form) }} {{ form_start(form) }}
{%- if form.acpw is defined -%} {%- if form.acpw is defined -%}
{{ form_row(form.acpw) }} {{ form_row(form.acpw) }}
<div id="linked-acpw-selector" data-acpw-array='{{ acpwArray|json_encode }}'></div> <div id="linked-acpw-selector" data-accompanying-period='{{ accompanyingCourse.id }}'></div>
{% endif %} {% endif %}
{{ form_rest(form) }} {{ form_rest(form) }}