From ed9ddbfcebd534365254eb5a22ac7de49dadc6b7 Mon Sep 17 00:00:00 2001 From: Brock Anderson Date: Tue, 5 Nov 2024 14:40:48 -0800 Subject: [PATCH] validate length of data constraints and employer statement on frontend --- frontend/src/components/InputForm.vue | 62 +++++++++++++++++++++--- frontend/src/components/RichTextArea.vue | 3 +- 2 files changed, 57 insertions(+), 8 deletions(-) diff --git a/frontend/src/components/InputForm.vue b/frontend/src/components/InputForm.vue index f83eb9f6a..272a1a8af 100644 --- a/frontend/src/components/InputForm.vue +++ b/frontend/src/components/InputForm.vue @@ -351,7 +351,14 @@
- + @@ -393,7 +408,14 @@
- + @@ -764,6 +794,10 @@ export default { approvedRoute: null as string | null, reportStatus: null, reportingYearOptions: [] as number[], + employerStatementLength: undefined, + dataConstraintsLength: undefined, + employerStatementMaxLength: 4000, + dataConstraintsMaxLength: 3000, }), computed: { ...mapState(useConfigStore, ['config']), @@ -786,7 +820,9 @@ export default { !!this.endMonth && !!this.endYear && !!this.reportYear && - !!this.uploadFileValue + !!this.uploadFileValue && + this.isEmployerStatementValid && + this.isDataConstraintsValid ); }, uploadFileSize() { @@ -830,6 +866,18 @@ export default { isEditMode() { return this.reportId != null; }, + isEmployerStatementValid() { + return ( + !this.employerStatementLength || + this.employerStatementLength <= this.employerStatementMaxLength + ); + }, + isDataConstraintsValid() { + return ( + !this.dataConstraintsLength || + this.dataConstraintsLength <= this.dataConstraintsMaxLength + ); + }, }, watch: { reportYear: { diff --git a/frontend/src/components/RichTextArea.vue b/frontend/src/components/RichTextArea.vue index 681304b20..948e5fc20 100644 --- a/frontend/src/components/RichTextArea.vue +++ b/frontend/src/components/RichTextArea.vue @@ -50,7 +50,7 @@ const richTextEditor = ref(null); let quill: Quill | undefined = undefined; const plainTextLength = ref(undefined); -const emit = defineEmits(['update:modelValue']); +const emit = defineEmits(['update:modelValue', 'plainTextLengthChanged']); const props = defineProps<{ placeholder?: string | undefined; @@ -92,6 +92,7 @@ onMounted(() => { const onTextChanged = (delta, oldDelta?, source?) => { plainTextLength.value = getPlainTextLength(); emit('update:modelValue', getHtml()); + emit('plainTextLengthChanged', plainTextLength.value); }; const setHtml = (html: string | undefined | null) => {