From 2fb3c7e7894231f24167b513ee6001d10427f8e9 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Mon, 5 Apr 2021 15:16:37 +0200 Subject: [PATCH] Can delete a group conversation --- assets/js/components/groups/interface.js | 11 +++++++ assets/js/pages/groups/pages/settings.js | 26 ++++++++++++++++ assets/js/typings/Conversations.d.ts | 1 + assets/js/typings/Group.d.ts | 3 +- .../sections/GroupConversationsSettings.html | 30 ++++++++++++++----- 5 files changed, 63 insertions(+), 8 deletions(-) diff --git a/assets/js/components/groups/interface.js b/assets/js/components/groups/interface.js index e70d0ea6..77c78e1a 100644 --- a/assets/js/components/groups/interface.js +++ b/assets/js/components/groups/interface.js @@ -134,6 +134,17 @@ const GroupsInterface = { }, true) }, + /** + * Delete a group conversation + * + * @param {Number} convID The ID of the conversation to delete + */ + deleteGroupConversation: async function(convID) { + await api("groups/delete_conversation", { + conv_id: convID, + }, true) + }, + /** * Check the availability of a virtual directory for a group * diff --git a/assets/js/pages/groups/pages/settings.js b/assets/js/pages/groups/pages/settings.js index ecf1e714..2685e757 100644 --- a/assets/js/pages/groups/pages/settings.js +++ b/assets/js/pages/groups/pages/settings.js @@ -350,12 +350,17 @@ const GroupSettingsPage = { Vue.createApp({ data: () => { return { + conversations: settings.conversations, newConvName: "", newConvVisibility: "member" } }, methods: { + + /** + * Create a new conversation + */ createNewConv: async function() { try { const convName = this.newConvName; @@ -374,6 +379,27 @@ const GroupSettingsPage = { console.error(e) notify(tr("Failed to create group conversation!"), "danger") } + }, + + /** + * Delete a conversation + */ + deleteConv: async function(convID) { + try { + if (!await showConfirmDialog("Do you really want to delete this conversation ?")) + return; + + await GroupsInterface.deleteGroupConversation(convID) + + notify("The conversation was successfully deleted!", "success") + + Page.refresh_current_page(); + } + + catch(e) { + console.error(e) + notify(tr("Failed to delete group conversation!"), "danger") + } } } }).mount(conversationsSettingsTarget); diff --git a/assets/js/typings/Conversations.d.ts b/assets/js/typings/Conversations.d.ts index 0ee00691..ee263dba 100644 --- a/assets/js/typings/Conversations.d.ts +++ b/assets/js/typings/Conversations.d.ts @@ -27,6 +27,7 @@ declare interface Conversation { color?: string, logo?: string, group_id?: number, + group_min_membership_level ?: "member"|"moderator"|"administrator", members: ConversationMember[], can_everyone_add_members: boolean, can_have_call: boolean, diff --git a/assets/js/typings/Group.d.ts b/assets/js/typings/Group.d.ts index ba79be59..89cdcef8 100644 --- a/assets/js/typings/Group.d.ts +++ b/assets/js/typings/Group.d.ts @@ -10,7 +10,8 @@ declare interface AdvancedGroupInfo extends Group { description: String, url: String, number_likes: Number, - is_liking: Boolean + is_liking: Boolean, + conversations: Conversation[], } declare interface GroupSettings extends AdvancedGroupInfo {} \ No newline at end of file diff --git a/assets/templates/pages/groups/sections/GroupConversationsSettings.html b/assets/templates/pages/groups/sections/GroupConversationsSettings.html index 7cd51e7a..a07ecb99 100644 --- a/assets/templates/pages/groups/sections/GroupConversationsSettings.html +++ b/assets/templates/pages/groups/sections/GroupConversationsSettings.html @@ -5,6 +5,22 @@ +
+ + + + + + + + + + + +
NameVisibility
{{ conv.name }}{{ conv.group_min_membership_level }} + +
+
- +
-
+
- +