Skip to content

Commit

Permalink
Merge branch 'main' into BC-9140-update-pinia
Browse files Browse the repository at this point in the history
  • Loading branch information
NFriedo authored Mar 4, 2025
2 parents ea4d3b3 + 019aace commit 195e129
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 12 deletions.
26 changes: 17 additions & 9 deletions src/components/organisms/administration/SchoolPolicyFormDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<v-custom-dialog
:is-open="isOpen"
:size="425"
@dialog-closed="cancel"
@dialog-canceled="cancel"
has-buttons
confirm-btn-title-key="pages.administration.school.index.schoolPolicy.replace"
:confirm-btn-icon="mdiFileReplaceOutline"
Expand All @@ -29,7 +29,6 @@
ref="input-file"
class="input-file mb-2"
data-testid="input-file"
v-model="files"
density="compact"
accept="application/pdf"
truncate-length="30"
Expand All @@ -44,6 +43,7 @@
:persistent-hint="true"
:rules="[rules.required, rules.mustBePdf, rules.maxSize(4194304)]"
@blur="onBlur"
@update:modelValue="onFileChange"
>
<template v-slot:append-inner>
<v-icon
Expand All @@ -61,19 +61,19 @@

<script lang="ts">
import vCustomDialog from "@/components/organisms/vCustomDialog.vue";
import { computed, ComputedRef, defineComponent, ref, Ref } from "vue";
import { currentDate } from "@/plugins/datetime";
import { CreateConsentVersionPayload } from "@/store/types/consent-version";
import { School } from "@/store/types/schools";
import { toBase64 } from "@/utils/fileHelper";
import {
injectStrict,
NOTIFIER_MODULE_KEY,
PRIVACY_POLICY_MODULE_KEY,
SCHOOLS_MODULE_KEY,
} from "@/utils/inject";
import { useI18n } from "vue-i18n";
import { mdiAlert, mdiFileReplaceOutline } from "@icons/material";
import { School } from "@/store/types/schools";
import { currentDate } from "@/plugins/datetime";
import { toBase64 } from "@/utils/fileHelper";
import { CreateConsentVersionPayload } from "@/store/types/consent-version";
import { computed, ComputedRef, defineComponent, ref, Ref } from "vue";
import { useI18n } from "vue-i18n";
export default defineComponent({
name: "SchoolPolicyFormDialog",
Expand Down Expand Up @@ -115,6 +115,14 @@ export default defineComponent({
),
};
const onFileChange = (_files: File[] | File) => {
if (Array.isArray(_files)) {
files.value = _files;
} else {
files.value = [_files];
}
};
const onBlur = () => {
isTouched.value = true;
};
Expand Down Expand Up @@ -156,11 +164,11 @@ export default defineComponent({
return {
t,
files,
rules,
cancel,
submit,
onBlur,
onFileChange,
isValid,
isTouched,
policyForm,
Expand Down
14 changes: 11 additions & 3 deletions src/components/organisms/administration/SchoolTermsFormDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<v-custom-dialog
:is-open="isOpen"
:size="425"
@dialog-closed="cancel"
@dialog-canceled="cancel"
has-buttons
confirm-btn-title-key="pages.administration.school.index.termsOfUse.replace"
:confirm-btn-icon="mdiFileReplaceOutline"
Expand All @@ -29,7 +29,6 @@
ref="input-file"
class="input-file mb-2"
data-testid="input-file"
v-model="files"
:multiple="false"
density="compact"
accept="application/pdf"
Expand All @@ -43,6 +42,7 @@
:persistent-hint="true"
:rules="[rules.required, rules.mustBePdf, rules.maxSize(4194304)]"
@blur="onBlur"
@update:modelValue="onFileChange"
>
<template v-slot:append-inner>
<v-icon
Expand Down Expand Up @@ -116,6 +116,14 @@ export default defineComponent({
isFormTouched.value = true;
};
const onFileChange = (_files: File[] | File) => {
if (Array.isArray(_files)) {
files.value = _files;
} else {
files.value = [_files];
}
};
const resetForm = () => {
termsForm.value = [];
isFormValid.value = false;
Expand Down Expand Up @@ -153,11 +161,11 @@ export default defineComponent({
return {
t,
files,
rules: validationRules,
cancel,
submit,
onBlur,
onFileChange,
isValid: isFormValid,
isTouched: isFormTouched,
termsForm,
Expand Down

0 comments on commit 195e129

Please sign in to comment.