From 137bc1ce0de312e2cf78ce71a97930ce29839e0a Mon Sep 17 00:00:00 2001 From: Daniel <50702276+daniboygg@users.noreply.github.com> Date: Thu, 16 May 2024 20:09:48 +0200 Subject: [PATCH] Disable send button on message when title and receivers are not set #5465 * Messages: use new component to show user profile when query has user to parameter * Messages: use async/await for consistency with other code * Change hardcoded url from component to userService so all strings related to endpoints are in the same place * Messages: allow send message only when title and to is defined * Messages: migrate a function from deprecated service to a new one * Add documentation on how to migrate message service --------- Co-authored-by: Angel Fernando Quiroz Campos --- assets/vue/services/message.js | 23 +++++++++- assets/vue/services/userService.js | 6 +-- assets/vue/views/message/MessageCreate.vue | 52 +++++++++++++++------- 3 files changed, 59 insertions(+), 22 deletions(-) diff --git a/assets/vue/services/message.js b/assets/vue/services/message.js index 507b6635bc..5bc6a575a6 100644 --- a/assets/vue/services/message.js +++ b/assets/vue/services/message.js @@ -1,3 +1,22 @@ -import makeService from './api'; +import makeService from "./api" +import baseService from "./baseService" -export default makeService('messages'); +// MIGRATION IN PROGRESS. makeService is deprecated +// if you use some method in this service you should try to refactor it with new baseService defining async functions +// like create below. A fully migrated service looks like: assets/vue/services/userService.js. +// BE AWARE that makeService use vuex, so we need to ensure behaviour to be the same as the older service +// When makeService is fully migrated, export by default the const messageService and change imports in all components +// that use this service +export default makeService("messages") + +/** + * @param {Object} message + * @returns {Promise} + */ +async function create(message) { + return await baseService.post("/api/messages", message) +} + +export const messageService = { + create, +} diff --git a/assets/vue/services/userService.js b/assets/vue/services/userService.js index 634dad666b..fe8a9947d0 100644 --- a/assets/vue/services/userService.js +++ b/assets/vue/services/userService.js @@ -1,11 +1,11 @@ import baseService from "./baseService" /** - * @param {string} userIri + * @param {string} userId * @returns {Promise} */ -async function find(userIri) { - return await baseService.get(userIri) +async function find(userId) { + return await baseService.get(`/api/users/${userId}`) } /** diff --git a/assets/vue/views/message/MessageCreate.vue b/assets/vue/views/message/MessageCreate.vue index 32aefac489..4d922d44f0 100644 --- a/assets/vue/views/message/MessageCreate.vue +++ b/assets/vue/views/message/MessageCreate.vue @@ -5,14 +5,14 @@ >
- -
+ + {{ t('Send is disabled because title of message or "to" recipent are not filled in') }} + @@ -52,20 +60,20 @@