From 7c62d3629ca0248dffaa3a66bdd4836798dfc486 Mon Sep 17 00:00:00 2001 From: Nithin David Thomas Date: Fri, 25 Dec 2020 13:15:01 +0530 Subject: [PATCH] feat: Add pending message on dashboard (#1547) --- app/javascript/dashboard/api/inbox/message.js | 12 ++- .../widgets/conversation/Message.vue | 47 +++++++++--- .../widgets/conversation/bubble/Actions.vue | 2 +- app/javascript/dashboard/helper/commons.js | 43 ++++++++++- .../dashboard/helper/specs/commons.spec.js | 73 ++++++++++++++++++- .../i18n/locale/en/conversation.json | 1 + .../store/modules/conversations/actions.js | 22 +++++- .../store/modules/conversations/helpers.js | 6 ++ .../store/modules/conversations/index.js | 12 +-- .../specs/conversations/helpers.spec.js | 37 ++++++++++ .../dashboard/store/mutation-types.js | 1 + .../shared/assets/stylesheets/colors.scss | 2 + .../shared/constants/messageTypes.js | 6 -- app/javascript/shared/constants/messages.js | 12 +++ .../messages/create.json.jbuilder | 12 +-- .../messages/index.json.jbuilder | 12 +-- .../api/v1/models/_message.json.jbuilder | 13 ++++ 17 files changed, 260 insertions(+), 53 deletions(-) create mode 100644 app/javascript/dashboard/store/modules/conversations/helpers.js create mode 100644 app/javascript/dashboard/store/modules/specs/conversations/helpers.spec.js delete mode 100644 app/javascript/shared/constants/messageTypes.js create mode 100644 app/javascript/shared/constants/messages.js create mode 100644 app/views/api/v1/models/_message.json.jbuilder diff --git a/app/javascript/dashboard/api/inbox/message.js b/app/javascript/dashboard/api/inbox/message.js index 07754fd10..f745febfe 100644 --- a/app/javascript/dashboard/api/inbox/message.js +++ b/app/javascript/dashboard/api/inbox/message.js @@ -7,10 +7,17 @@ class MessageApi extends ApiClient { super('conversations', { accountScoped: true }); } - create({ conversationId, message, private: isPrivate, contentAttributes }) { + create({ + conversationId, + message, + private: isPrivate, + contentAttributes, + echo_id: echoId, + }) { return axios.post(`${this.url}/${conversationId}/messages`, { content: message, private: isPrivate, + echo_id: echoId, content_attributes: contentAttributes, }); } @@ -21,10 +28,11 @@ class MessageApi extends ApiClient { }); } - sendAttachment([conversationId, { file, isPrivate = false }]) { + sendAttachment([conversationId, { file, isPrivate = false }, echoId]) { const formData = new FormData(); formData.append('attachments[]', file, file.name); formData.append('private', isPrivate); + formData.append('echo_id', echoId); return axios({ method: 'post', url: `${this.url}/${conversationId}/messages`, diff --git a/app/javascript/dashboard/components/widgets/conversation/Message.vue b/app/javascript/dashboard/components/widgets/conversation/Message.vue index 3432a57c0..5439f6451 100644 --- a/app/javascript/dashboard/components/widgets/conversation/Message.vue +++ b/app/javascript/dashboard/components/widgets/conversation/Message.vue @@ -1,14 +1,20 @@