diff --git a/src/Bundle/ChillMainBundle/Resources/public/types.ts b/src/Bundle/ChillMainBundle/Resources/public/types.ts
index 3c883e631..3ab9dd4b8 100644
--- a/src/Bundle/ChillMainBundle/Resources/public/types.ts
+++ b/src/Bundle/ChillMainBundle/Resources/public/types.ts
@@ -1,15 +1,35 @@
-import {GenericDoc} from "ChillDocStoreAssets/types/generic_doc";
-import {StoredObject, StoredObjectStatus} from "ChillDocStoreAssets/types";
-import {CreatableEntityType} from "ChillPersonAssets/types";
+import { GenericDoc } from "ChillDocStoreAssets/types/generic_doc";
+import { StoredObject, StoredObjectStatus } from "ChillDocStoreAssets/types";
+import { CreatableEntityType } from "ChillPersonAssets/types";
export interface DateTime {
datetime: string;
datetime8601: string;
}
+/**
+ * A date representation to use when we create an instance
+ */
+export interface DateTimeCreate {
+ /**
+ * Must be a string in format Y-m-d\TH:i:sO
+ */
+ datetime: string;
+}
+
export interface Civility {
+ type: "chill_main_civility";
id: number;
- // TODO
+ abbreviation: TranslatableString;
+ active: boolean;
+ name: TranslatableString;
+}
+
+export interface Gender {
+ type: "chill_main_gender";
+ id: number;
+ label: string;
+ genderTranslation: string;
}
export interface Household {
@@ -306,7 +326,7 @@ export interface TabDefinition {
* Configuration for the CreateModal and Create component
*/
export interface CreateComponentConfig {
- action?: string;
- allowedTypes: CreatableEntityType[];
- query?: string;
+ action?: string;
+ allowedTypes: CreatableEntityType[];
+ query?: string;
}
diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/Create.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/Create.vue
index a33215b3a..00b8b610f 100644
--- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/Create.vue
+++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/Create.vue
@@ -1,6 +1,6 @@
@@ -18,15 +21,15 @@ const props = defineProps();
-
+
-
-
-
-
+
+
-
+
diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/PickEntity/PickEntity.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/PickEntity/PickEntity.vue
index 344c276e6..3d246d5f2 100644
--- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/PickEntity/PickEntity.vue
+++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/PickEntity/PickEntity.vue
@@ -76,7 +76,8 @@ import {
Entities,
EntitiesOrMe,
EntityType,
- SearchOptions, Suggestion,
+ SearchOptions,
+ Suggestion,
} from "ChillPersonAssets/types";
import {
PICK_ENTITY_MODAL_TITLE,
@@ -183,7 +184,7 @@ function addNewSuggested(entity: EntitiesOrMe) {
emits("addNewEntity", { entity });
}
-function addNewEntity({ selected }: { selected: Suggestion[]}) {
+function addNewEntity({ selected }: { selected: Suggestion[] }) {
Object.values(selected).forEach((item) => {
emits("addNewEntity", { entity: item.result });
});
diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/Modal.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/Modal.vue
index 22c934c67..9084c56ae 100644
--- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/Modal.vue
+++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/Modal.vue
@@ -52,23 +52,15 @@ import { trans, MODAL_ACTION_CLOSE } from "translator";
import { defineProps } from "vue";
export interface ModalProps {
- modalDialogClass: string;
- hideFooter: boolean;
+ modalDialogClass?: string | Record;
+ hideFooter?: boolean;
+ show?: boolean;
}
-defineProps({
- modalDialogClass: {
- type: String,
- default: "",
- },
- hideFooter: {
- type: Boolean,
- default: false,
- },
- show: {
- type: Boolean,
- default: true,
- },
+const props = withDefaults(defineProps(), {
+ modalDialogClass: "",
+ hideFooter: false,
+ show: true,
});
const emits = defineEmits<{
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/types.ts b/src/Bundle/ChillPersonBundle/Resources/public/types.ts
index 848f92763..8610dd66e 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/types.ts
+++ b/src/Bundle/ChillPersonBundle/Resources/public/types.ts
@@ -10,6 +10,7 @@ import {
Scope,
Job,
PrivateCommentEmbeddable,
+ TranslatableString,
} from "ChillMainAssets/types";
import { StoredObject } from "ChillDocStoreAssets/types";
import { Thirdparty } from "../../../ChillThirdPartyBundle/Resources/public/types";
@@ -17,7 +18,7 @@ import { Calendar } from "../../../ChillCalendarBundle/Resources/public/types";
import Person from "./vuejs/_components/OnTheFly/Person.vue";
export interface AltName {
- label: string;
+ label: TranslatableString;
key: string;
}
export interface Person {
@@ -331,15 +332,13 @@ export interface AccompanyingPeriodWorkEvaluationDocument {
/**
* Entity types that a user can create
*/
-export type CreatableEntityType =
- | "person"
- | "thirdparty";
-
+export type CreatableEntityType = "person" | "thirdparty";
/**
* Entities that can be search and selected by a user
*/
-export type EntityType = CreatableEntityType
+export type EntityType =
+ | CreatableEntityType
| "user_group"
| "user"
| "household";
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_api/OnTheFly.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_api/OnTheFly.js
deleted file mode 100644
index 51dedec98..000000000
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_api/OnTheFly.js
+++ /dev/null
@@ -1,88 +0,0 @@
-import { makeFetch } from "ChillMainAssets/lib/api/apiMethods";
-
-/*
- * GET a person by id
- */
-const getPerson = (id) => {
- const url = `/api/1.0/person/person/${id}.json`;
- return fetch(url).then((response) => {
- if (response.ok) {
- return response.json();
- }
- throw Error("Error with request resource response");
- });
-};
-
-const getPersonAltNames = () =>
- fetch("/api/1.0/person/config/alt_names.json").then((response) => {
- if (response.ok) {
- return response.json();
- }
- throw Error("Error with request resource response");
- });
-
-const getCivilities = () =>
- fetch("/api/1.0/main/civility.json").then((response) => {
- if (response.ok) {
- return response.json();
- }
- throw Error("Error with request resource response");
- });
-
-const getGenders = () => makeFetch("GET", "/api/1.0/main/gender.json");
-// .then(response => {
-// console.log(response)
-// if (response.ok) { return response.json(); }
-// throw Error('Error with request resource response');
-// });
-
-const getCentersForPersonCreation = () =>
- makeFetch("GET", "/api/1.0/person/creation/authorized-centers", null);
-
-/*
- * POST a new person
- */
-const postPerson = (body) => {
- const url = `/api/1.0/person/person.json`;
- return fetch(url, {
- method: "POST",
- headers: {
- "Content-Type": "application/json;charset=utf-8",
- },
- body: JSON.stringify(body),
- }).then((response) => {
- if (response.ok) {
- return response.json();
- }
- throw Error("Error with request resource response");
- });
-};
-
-/*
- * PATCH an existing person
- */
-const patchPerson = (id, body) => {
- const url = `/api/1.0/person/person/${id}.json`;
- return fetch(url, {
- method: "PATCH",
- headers: {
- "Content-Type": "application/json;charset=utf-8",
- },
- body: JSON.stringify(body),
- }).then((response) => {
- if (response.ok) {
- return response.json();
- }
- throw Error("Error with request resource response");
- });
-};
-
-export {
- getCentersForPersonCreation,
- getPerson,
- getPersonAltNames,
- getCivilities,
- getGenders,
- postPerson,
- patchPerson,
-};
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_api/OnTheFly.ts b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_api/OnTheFly.ts
new file mode 100644
index 000000000..f8df76478
--- /dev/null
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_api/OnTheFly.ts
@@ -0,0 +1,33 @@
+import { fetchResults, makeFetch } from "ChillMainAssets/lib/api/apiMethods";
+import { Center, Civility, Gender } from "ChillMainAssets/types";
+import { AltName, Person } from "ChillPersonAssets/types";
+
+/*
+ * GET a person by id
+ */
+export const getPerson = async (id: number): Promise => {
+ const url = `/api/1.0/person/person/${id}.json`;
+ return fetch(url).then((response) => {
+ if (response.ok) {
+ return response.json();
+ }
+ throw Error("Error with request resource response");
+ });
+};
+
+export const getPersonAltNames = async (): Promise =>
+ fetch("/api/1.0/person/config/alt_names.json").then((response) => {
+ if (response.ok) {
+ return response.json();
+ }
+ throw Error("Error with request resource response");
+ });
+
+export const getCivilities = async (): Promise =>
+ fetchResults("/api/1.0/main/civility.json");
+
+export const getGenders = async (): Promise =>
+ fetchResults("/api/1.0/main/gender.json");
+
+export const getCentersForPersonCreation = async (): Promise =>
+ makeFetch("GET", "/api/1.0/person/creation/authorized-centers", null);
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons.vue
index 18adee87d..3668fa289 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons.vue
@@ -3,7 +3,7 @@
class="btn"
:class="getClassButton"
:title="buttonTitle"
- @click="openModal"
+ @click="openModalChoose"
>
{{ buttonTitle }}
@@ -16,22 +16,28 @@
:selected="selected"
:modal-dialog-class="'modal-dialog-scrollable modal-xl'"
:allow-create="props.allowCreate"
- @close="closeModal"
- @addNewPersons="payload => emit('addNewPersons', payload)"
+ @close="closeModalChoose"
+ @addNewPersons="(payload) => emit('addNewPersons', payload)"
@onAskForCreate="onAskForCreate"
/>
+ @close="closeModalCreate"
+ >