From 73d0a9a25c86494bb8916c7e60dd6d8159c1c645 Mon Sep 17 00:00:00 2001
From: Vijaivir Dhaliwal <91633223+vijaivir@users.noreply.github.com>
Date: Wed, 26 Jun 2024 13:36:52 -0700
Subject: [PATCH] Feat: Autocomplete and Multiple Email Support for Status
Panel Revising Status (#1388)
* limit one email for revised status
* fix submissionUserEmail error
* fix error
* added translations
* remove comment
* multiple email support
* resolve conflicts
* resolve conflict
---
.../forms/submission/StatusPanel.vue | 157 ++++++++++++------
.../trans/chefs/ar/ar.json | 1 +
.../trans/chefs/de/de.json | 1 +
.../trans/chefs/en/en.json | 1 +
.../trans/chefs/es/es.json | 1 +
.../trans/chefs/fa/fa.json | 1 +
.../trans/chefs/fr/fr.json | 1 +
.../trans/chefs/hi/hi.json | 1 +
.../trans/chefs/it/it.json | 1 +
.../trans/chefs/ja/ja.json | 1 +
.../trans/chefs/ko/ko.json | 1 +
.../trans/chefs/pa/pa.json | 1 +
.../trans/chefs/pt/pt.json | 1 +
.../trans/chefs/ru/ru.json | 1 +
.../trans/chefs/tl/tl.json | 1 +
.../trans/chefs/uk/uk.json | 1 +
.../trans/chefs/vi/vi.json | 1 +
.../trans/chefs/zh/zh.json | 1 +
.../trans/chefs/zhTW/zh-TW.json | 1 +
19 files changed, 128 insertions(+), 47 deletions(-)
diff --git a/app/frontend/src/components/forms/submission/StatusPanel.vue b/app/frontend/src/components/forms/submission/StatusPanel.vue
index bc5b1aa9b..c1bbca44d 100644
--- a/app/frontend/src/components/forms/submission/StatusPanel.vue
+++ b/app/frontend/src/components/forms/submission/StatusPanel.vue
@@ -47,6 +47,7 @@ export default {
valid: false,
showSendConfirmEmail: false,
showStatusContent: false,
+ selectedUsers: [], // array to hold multiple users for REVISING status
};
},
computed: {
@@ -235,59 +236,77 @@ export default {
throw new Error(this.$t('trans.statusPanel.status'));
}
- const statusBody = {
+ const baseStatusBody = {
code: this.statusToSet,
- submissionUserEmail: this.submissionUserEmail,
revisionNotificationEmailContent: this.emailComment,
};
- if (this.showAssignee) {
- if (this.assignee) {
- statusBody.assignedToUserId = this.assignee.userId;
- statusBody.assignmentNotificationEmail = this.assignee.email;
- }
- }
- const statusResponse = await formService.updateSubmissionStatus(
- this.submissionId,
- statusBody
- );
- if (!statusResponse.data) {
- throw new Error(
- this.$t('trans.statusPanel.updtSubmissionsStatusErr')
- );
+
+ if (this.showAssignee && this.assignee) {
+ baseStatusBody.assignedToUserId = this.assignee.userId;
+ baseStatusBody.assignmentNotificationEmail = this.assignee.email;
}
- if (this.emailComment) {
- let formattedComment;
- if (this.statusToSet === 'ASSIGNED') {
- formattedComment = `Email to ${this.assignee.email}: ${this.emailComment}`;
- } else if (
- this.statusToSet === 'REVISING' ||
- this.statusToSet === 'COMPLETED'
- ) {
- formattedComment = `Email to ${this.submissionUserEmail}: ${this.emailComment}`;
- }
+ if (this.statusToSet === 'REVISING') {
+ // Handle multiple emails for REVISING
+ for (const user of this.selectedUsers) {
+ const statusBody = {
+ ...baseStatusBody,
+ submissionUserEmail: user.email,
+ };
+ const statusResponse = await formService.updateSubmissionStatus(
+ this.submissionId,
+ statusBody
+ );
- const submissionStatusId =
- statusResponse.data[0].submissionStatusId;
- const user = await rbacService.getCurrentUser();
- const noteBody = {
- submissionId: this.submissionId,
- submissionStatusId: submissionStatusId,
- note: formattedComment,
- userId: user.data.id,
+ if (!statusResponse.data) {
+ throw new Error(
+ this.$t('trans.statusPanel.updtSubmissionsStatusErr')
+ );
+ }
+
+ if (this.emailComment) {
+ const formattedComment = `Email to ${user.email}: ${this.emailComment}`;
+ await this.sendEmailWithComment(
+ formattedComment,
+ statusResponse.data[0].submissionStatusId
+ );
+ }
+ }
+ } else {
+ // Handle single email for other statuses
+ const statusBody = {
+ ...baseStatusBody,
+ submissionUserEmail: this.submissionUserEmail,
};
- const response = await formService.addNote(
+ const statusResponse = await formService.updateSubmissionStatus(
this.submissionId,
- noteBody
+ statusBody
);
- if (!response.data) {
+
+ if (!statusResponse.data) {
throw new Error(
- this.$t('trans.statusPanel.addNoteNoReponserErr')
+ this.$t('trans.statusPanel.updtSubmissionsStatusErr')
+ );
+ }
+
+ if (this.emailComment) {
+ let formattedComment;
+ if (this.statusToSet === 'ASSIGNED') {
+ formattedComment = `Email to ${this.assignee.email}: ${this.emailComment}`;
+ } else if (this.statusToSet === 'COMPLETED') {
+ formattedComment = `Email to ${this.submissionUserEmail}: ${this.emailComment}`;
+ }
+
+ await this.sendEmailWithComment(
+ formattedComment,
+ statusResponse.data[0].submissionStatusId
);
}
- // Update the parent if the note was updated
- this.$emit('note-updated');
}
+
+ // Update the parent if the note was updated
+ this.$emit('note-updated');
+
this.resetForm();
this.getStatus();
}
@@ -300,6 +319,24 @@ export default {
});
}
},
+
+ async sendEmailWithComment(comment, submissionStatusId) {
+ const user = await rbacService.getCurrentUser();
+ const noteBody = {
+ submissionId: this.submissionId,
+ submissionStatusId: submissionStatusId,
+ note: comment,
+ userId: user.data.id,
+ };
+ const response = await formService.addNote(this.submissionId, noteBody);
+ if (!response.data) {
+ throw new Error(this.$t('trans.statusPanel.addNoteNoReponserErr'));
+ }
+ },
+
+ updateSubmissionUserEmail(selectedUsers) {
+ this.selectedUsers = selectedUsers;
+ },
},
};
@@ -447,15 +484,41 @@ export default {
- Recipient Email
+
+ clearable
+ :custom-filter="autoCompleteFilter"
+ :items="formReviewers"
+ item-title="fullName"
+ :loading="loading"
+ :no-data-text="$t('trans.statusPanel.noDataText')"
+ variant="outlined"
+ return-object
+ :rules="[
+ (v) => !!v || $t('trans.statusPanel.recipientIsRequired'),
+ ]"
+ :lang="locale"
+ multiple
+ @update:model-value="updateSubmissionUserEmail"
+ >
+
+
+
+
+
+
+
+
+
+
diff --git a/app/frontend/src/internationalization/trans/chefs/ar/ar.json b/app/frontend/src/internationalization/trans/chefs/ar/ar.json
index c0c85a886..80de7e662 100644
--- a/app/frontend/src/internationalization/trans/chefs/ar/ar.json
+++ b/app/frontend/src/internationalization/trans/chefs/ar/ar.json
@@ -615,6 +615,7 @@
"assigneeIsRequired": "مطلوب الوكيل",
"assignToMe": "تعيين لي",
"recipientEmail": "البريد الإلكتروني المستلم",
+ "recipientIsRequired": "المستلم مطلوب",
"attachCommentToEmail": "إرفاق تعليق بالبريد الإلكتروني",
"emailComment": "التعليق بالبريد الإلكتروني",
"maxChars": "4000 حرف كحد أقصى",
diff --git a/app/frontend/src/internationalization/trans/chefs/de/de.json b/app/frontend/src/internationalization/trans/chefs/de/de.json
index 1562ea8a9..028f93fd4 100644
--- a/app/frontend/src/internationalization/trans/chefs/de/de.json
+++ b/app/frontend/src/internationalization/trans/chefs/de/de.json
@@ -616,6 +616,7 @@
"assigneeIsRequired": "Bevollmächtigter ist erforderlich",
"assignToMe": "MIR ZUWEISEN",
"recipientEmail": "Empfänger E-Mail",
+ "recipientIsRequired": "Empfänger ist erforderlich",
"attachCommentToEmail": "Kommentar an E-Mail anhängen",
"emailComment": "E-Mail-Kommentar",
"maxChars": "Maximal 4000 Zeichen",
diff --git a/app/frontend/src/internationalization/trans/chefs/en/en.json b/app/frontend/src/internationalization/trans/chefs/en/en.json
index dc8efe274..a9abec3ca 100644
--- a/app/frontend/src/internationalization/trans/chefs/en/en.json
+++ b/app/frontend/src/internationalization/trans/chefs/en/en.json
@@ -659,6 +659,7 @@
"assigneeIsRequired": "Assignee is required",
"assignToMe": "ASSIGN TO ME",
"recipientEmail": "Recipient Email",
+ "recipientIsRequired": "Recipient is required",
"attachCommentToEmail": "Attach Comment to Email",
"emailComment": "Email Comment",
"maxChars": "Max 4000 characters",
diff --git a/app/frontend/src/internationalization/trans/chefs/es/es.json b/app/frontend/src/internationalization/trans/chefs/es/es.json
index 2d5d8bbff..2c603a9e0 100644
--- a/app/frontend/src/internationalization/trans/chefs/es/es.json
+++ b/app/frontend/src/internationalization/trans/chefs/es/es.json
@@ -615,6 +615,7 @@
"assigneeIsRequired": "Se requiere cesionario",
"assignToMe": "ASIGNARME",
"recipientEmail": "Receptor de E-mail",
+ "recipientIsRequired": "Se requiere destinatario",
"attachCommentToEmail": "Adjuntar comentario al correo electrónico",
"emailComment": "Comentario de correo electrónico",
"maxChars": "4000 caracteres como máximo",
diff --git a/app/frontend/src/internationalization/trans/chefs/fa/fa.json b/app/frontend/src/internationalization/trans/chefs/fa/fa.json
index b31755e88..13d3c9b2b 100644
--- a/app/frontend/src/internationalization/trans/chefs/fa/fa.json
+++ b/app/frontend/src/internationalization/trans/chefs/fa/fa.json
@@ -615,6 +615,7 @@
"assigneeIsRequired": "کارمند مورد نیاز است",
"assignToMe": "به من اختصاص دهید",
"recipientEmail": "ایمیل گیرنده",
+ "recipientIsRequired": "دریافت کننده الزامی است",
"attachCommentToEmail": "نظر را به ایمیل ضمیمه کنید",
"emailComment": "نظر ایمیل",
"maxChars": "حداکثر 4000 کاراکتر",
diff --git a/app/frontend/src/internationalization/trans/chefs/fr/fr.json b/app/frontend/src/internationalization/trans/chefs/fr/fr.json
index 5693bbd64..99fa85af3 100644
--- a/app/frontend/src/internationalization/trans/chefs/fr/fr.json
+++ b/app/frontend/src/internationalization/trans/chefs/fr/fr.json
@@ -615,6 +615,7 @@
"assigneeIsRequired": "Le cessionnaire est requis",
"assignToMe": "M'ASSIGNER",
"recipientEmail": "Destinataire E-mail",
+ "recipientIsRequired": "Le destinataire est requis",
"attachCommentToEmail": "Joindre un commentaire à un e-mail",
"emailComment": "Commentaire par e-mail",
"maxChars": "4000 caractères maximum",
diff --git a/app/frontend/src/internationalization/trans/chefs/hi/hi.json b/app/frontend/src/internationalization/trans/chefs/hi/hi.json
index 953e53e23..f45dff7f2 100644
--- a/app/frontend/src/internationalization/trans/chefs/hi/hi.json
+++ b/app/frontend/src/internationalization/trans/chefs/hi/hi.json
@@ -615,6 +615,7 @@
"assigneeIsRequired": "समनुदेशिती आवश्यक है",
"assignToMe": "मेरे लिए आवंटित",
"recipientEmail": "प्राप्तकर्ता का ई - मेल",
+ "recipientIsRequired": "प्राप्तकर्ता आवश्यक है",
"attachCommentToEmail": "ईमेल पर टिप्पणी संलग्न करें",
"emailComment": "ईमेल टिप्पणी",
"maxChars": "अधिकतम 4000 अक्षर",
diff --git a/app/frontend/src/internationalization/trans/chefs/it/it.json b/app/frontend/src/internationalization/trans/chefs/it/it.json
index 8e7320c4e..939fdebdb 100644
--- a/app/frontend/src/internationalization/trans/chefs/it/it.json
+++ b/app/frontend/src/internationalization/trans/chefs/it/it.json
@@ -615,6 +615,7 @@
"assigneeIsRequired": "L'assegnatario è obbligatorio",
"assignToMe": "ASSEGNAMI",
"recipientEmail": "Destinatario dell'email",
+ "recipientIsRequired": "Il destinatario è richiesto",
"attachCommentToEmail": "Allega commento all'e-mail",
"emailComment": "E-mail Commento",
"maxChars": "Massimo 4000 caratteri",
diff --git a/app/frontend/src/internationalization/trans/chefs/ja/ja.json b/app/frontend/src/internationalization/trans/chefs/ja/ja.json
index 4ed001333..206963b61 100644
--- a/app/frontend/src/internationalization/trans/chefs/ja/ja.json
+++ b/app/frontend/src/internationalization/trans/chefs/ja/ja.json
@@ -615,6 +615,7 @@
"assigneeIsRequired": "譲受人は必須です",
"assignToMe": "私に割り当ててください",
"recipientEmail": "受信者のEメール",
+ "recipientIsRequired": "受取人が必要です",
"attachCommentToEmail": "メールにコメントを添付",
"emailComment": "メールでのコメント",
"maxChars": "最大4000文字",
diff --git a/app/frontend/src/internationalization/trans/chefs/ko/ko.json b/app/frontend/src/internationalization/trans/chefs/ko/ko.json
index bc8f9fe3e..6f1b22268 100644
--- a/app/frontend/src/internationalization/trans/chefs/ko/ko.json
+++ b/app/frontend/src/internationalization/trans/chefs/ko/ko.json
@@ -615,6 +615,7 @@
"assigneeIsRequired": "담당자는 필수 항목입니다.",
"assignToMe": "나에게 할당",
"recipientEmail": "이메일 수령인",
+ "recipientIsRequired": "수령인이 필요합니다",
"attachCommentToEmail": "이메일에 댓글 첨부",
"emailComment": "이메일 댓글",
"maxChars": "최대 4000자",
diff --git a/app/frontend/src/internationalization/trans/chefs/pa/pa.json b/app/frontend/src/internationalization/trans/chefs/pa/pa.json
index bf68bb416..3e6790d08 100644
--- a/app/frontend/src/internationalization/trans/chefs/pa/pa.json
+++ b/app/frontend/src/internationalization/trans/chefs/pa/pa.json
@@ -615,6 +615,7 @@
"assigneeIsRequired": "ਜ਼ਿੰਮੇਦਾਰ ਲੋੜੀਂਦਾ ਹੈ",
"assignToMe": "ਮੈਨੂੰ ਸੌਂਪੋ",
"recipientEmail": "ਪ੍ਰਾਪਤਕਰਤਾ ਈਮੇਲ",
+ "recipientIsRequired": "ਪ੍ਰਾਪਤਕਰਤਾ ਦੀ ਲੋੜ ਹੈ",
"attachCommentToEmail": "ਈਮੇਲ ਨਾਲ ਟਿੱਪਣੀ ਨੱਥੀ ਕਰੋ",
"emailComment": "ਈਮੇਲ ਟਿੱਪਣੀ",
"maxChars": "ਅਧਿਕਤਮ 4000 ਅੱਖਰ",
diff --git a/app/frontend/src/internationalization/trans/chefs/pt/pt.json b/app/frontend/src/internationalization/trans/chefs/pt/pt.json
index ec9ed5a75..2bd28fed1 100644
--- a/app/frontend/src/internationalization/trans/chefs/pt/pt.json
+++ b/app/frontend/src/internationalization/trans/chefs/pt/pt.json
@@ -615,6 +615,7 @@
"assigneeIsRequired": "O cessionário é obrigatório",
"assignToMe": "ATRIBUIR PARA MIM",
"recipientEmail": "E-mail do destinatário",
+ "recipientIsRequired": "Destinatário é necessário",
"attachCommentToEmail": "Anexar comentário ao e-mail",
"emailComment": "Comentário de e-mail",
"maxChars": "Máximo de 4.000 caracteres",
diff --git a/app/frontend/src/internationalization/trans/chefs/ru/ru.json b/app/frontend/src/internationalization/trans/chefs/ru/ru.json
index f584cc74f..552791168 100644
--- a/app/frontend/src/internationalization/trans/chefs/ru/ru.json
+++ b/app/frontend/src/internationalization/trans/chefs/ru/ru.json
@@ -615,6 +615,7 @@
"assigneeIsRequired": "Требуется правопреемник",
"assignToMe": "НАЗНАЧИТЬ МНЕ",
"recipientEmail": "Электронная почта получателя",
+ "recipientIsRequired": "Получатель обязателен",
"attachCommentToEmail": "Прикрепить комментарий к электронной почте",
"emailComment": "Комментарий по электронной почте",
"maxChars": "Максимум 4000 символов",
diff --git a/app/frontend/src/internationalization/trans/chefs/tl/tl.json b/app/frontend/src/internationalization/trans/chefs/tl/tl.json
index f6fe50241..8d9992323 100644
--- a/app/frontend/src/internationalization/trans/chefs/tl/tl.json
+++ b/app/frontend/src/internationalization/trans/chefs/tl/tl.json
@@ -615,6 +615,7 @@
"assigneeIsRequired": "Kinakailangan ang assignee",
"assignToMe": "ASSIGN TO ME",
"recipientEmail": "Email ng Tatanggap",
+ "recipientIsRequired": "Kinakailangan ang tatanggap",
"attachCommentToEmail": "Maglakip ng Komento sa Email",
"emailComment": "Komento sa Email",
"maxChars": "Max na 4000 character",
diff --git a/app/frontend/src/internationalization/trans/chefs/uk/uk.json b/app/frontend/src/internationalization/trans/chefs/uk/uk.json
index b27db03c1..4c7437dcf 100644
--- a/app/frontend/src/internationalization/trans/chefs/uk/uk.json
+++ b/app/frontend/src/internationalization/trans/chefs/uk/uk.json
@@ -614,6 +614,7 @@
"assigneeIsRequired": "Потрібен правонаступник",
"assignToMe": "ПРИЗНАЧИ МЕНІ",
"recipientEmail": "Електронна адреса одержувача",
+ "recipientIsRequired": "Одержувач обов'язковий",
"attachCommentToEmail": "Додайте коментар до електронного листа",
"emailComment": "Коментар електронною поштою",
"maxChars": "Макс. 4000 символів",
diff --git a/app/frontend/src/internationalization/trans/chefs/vi/vi.json b/app/frontend/src/internationalization/trans/chefs/vi/vi.json
index ebd4edd8f..3f6fd5c0e 100644
--- a/app/frontend/src/internationalization/trans/chefs/vi/vi.json
+++ b/app/frontend/src/internationalization/trans/chefs/vi/vi.json
@@ -615,6 +615,7 @@
"assigneeIsRequired": "Người được ủy quyền là bắt buộc",
"assignToMe": "GIAO CHO TÔI",
"recipientEmail": "Người nhận E-mail",
+ "recipientIsRequired": "Người nhận là bắt buộc",
"attachCommentToEmail": "Đính kèm Nhận xét vào Email",
"emailComment": "Nhận xét email",
"maxChars": "Tối đa 4000 ký tự",
diff --git a/app/frontend/src/internationalization/trans/chefs/zh/zh.json b/app/frontend/src/internationalization/trans/chefs/zh/zh.json
index e1ca464bc..3088f0d5e 100644
--- a/app/frontend/src/internationalization/trans/chefs/zh/zh.json
+++ b/app/frontend/src/internationalization/trans/chefs/zh/zh.json
@@ -615,6 +615,7 @@
"assigneeIsRequired": "受让人为必填项",
"assignToMe": "分配给我",
"recipientEmail": "收件人电子邮件",
+ "recipientIsRequired": "需要收件人",
"attachCommentToEmail": "将评论附加到电子邮件",
"emailComment": "电子邮件评论",
"maxChars": "最多 4000 个字符",
diff --git a/app/frontend/src/internationalization/trans/chefs/zhTW/zh-TW.json b/app/frontend/src/internationalization/trans/chefs/zhTW/zh-TW.json
index e85716ed4..4864004b6 100644
--- a/app/frontend/src/internationalization/trans/chefs/zhTW/zh-TW.json
+++ b/app/frontend/src/internationalization/trans/chefs/zhTW/zh-TW.json
@@ -615,6 +615,7 @@
"assigneeIsRequired": "受讓人為必填項",
"assignToMe": "分配給我",
"recipientEmail": "收件人電子郵件",
+ "recipientIsRequired": "需要收件人",
"attachCommentToEmail": "將評論附加到電子郵件",
"emailComment": "電子郵件評論",
"maxChars": "最多 4000 個字符",