|
5 | 5 | closable |
6 | 6 | class="w-full max-w-[30rem]" |
7 | 7 | :header="props.family.entity_form.title" |
8 | | - :content-props="{ onClick: (event: Event) => { event.stopPropagation() } }" |
9 | 8 | > |
10 | 9 | <!-- Entity Form Pages --> |
11 | 10 | <form |
|
35 | 34 | v-model:locations="editedEntity!.locations" |
36 | 35 | /> |
37 | 36 |
|
38 | | - <AdminInputSwitchField |
| 37 | + <div |
39 | 38 | v-if="state.permissions?.can_add_comment" |
40 | | - id="include_comment" |
41 | | - label="Ajouter un commentaire" |
42 | | - v-model:="include_comment" |
43 | | - /> |
| 39 | + class="flex flex-col gap-2" |
| 40 | + > |
| 41 | + <span class="flex items-center gap-2"> |
| 42 | + <ToggleSwitch |
| 43 | + class="shrink-0" |
| 44 | + :model-value="include_comment" |
| 45 | + input-id="include_comment" |
| 46 | + @change="(event: Event) => onIncludeCommentToggle(event)" |
| 47 | + /> |
| 48 | + <label for="include_comment">Inclure un commentaire</label> |
| 49 | + </span> |
| 50 | + </div> |
44 | 51 | </template> |
45 | 52 | <template v-else> |
46 | 53 | <FormDynamicField |
|
147 | 154 | </template> |
148 | 155 |
|
149 | 156 | <script setup lang="ts"> |
| 157 | +import type { ConfirmationOptions } from 'primevue/confirmationoptions' |
150 | 158 | import type { Category, EntityOrCommentData, Family, FormField, PublicNewComment, PublicNewEntity } from '~/lib' |
151 | 159 | import state from '~/lib/viewer-state' |
152 | 160 | import { isValidRichText, isValidText } from '~/lib/validation' |
@@ -328,4 +336,32 @@ async function realOnSave(token: string | null) { |
328 | 336 | } |
329 | 337 | processingRequest.value = false |
330 | 338 | } |
| 339 | +
|
| 340 | +const confirm = useConfirm() |
| 341 | +function onIncludeCommentToggle(event: Event) { |
| 342 | + console.log(event) |
| 343 | + console.log(event.currentTarget as HTMLElement) |
| 344 | + if (!include_comment.value) { |
| 345 | + include_comment.value = true |
| 346 | + } |
| 347 | + else { |
| 348 | + const options: ConfirmationOptions = { |
| 349 | + target: event.currentTarget as HTMLElement, |
| 350 | + group: 'delete', |
| 351 | + message: `Ne pas inclure de commentaire empêchera les autres utilisateur·ices de bénéficier de vos retours, |
| 352 | + et ne vous laissera préciser que les informations générales. Si vous avez une expérience personelle avec cette entité, |
| 353 | + nous vous conseillons d'inclure un commentaire.`, |
| 354 | + icon: 'warning', |
| 355 | + rejectClass: 'p-button-secondary p-button-outlined p-button-sm', |
| 356 | + acceptClass: 'p-button-sm', |
| 357 | + rejectLabel: 'Annuler', |
| 358 | + acceptLabel: 'Confirmer', |
| 359 | + reject: () => {}, |
| 360 | + accept: () => { |
| 361 | + include_comment.value = false |
| 362 | + }, |
| 363 | + } |
| 364 | + confirm.require(options) |
| 365 | + } |
| 366 | +} |
331 | 367 | </script> |
0 commit comments