diff --git a/assets/js/components/groups/interface.js b/assets/js/components/groups/interface.js index 7f3c87f5..e70d0ea6 100644 --- a/assets/js/components/groups/interface.js +++ b/assets/js/components/groups/interface.js @@ -119,6 +119,21 @@ const GroupsInterface = { ComunicWeb.common.api.makeAPIrequest(apiURI, settings, true, callback); }, + /** + * Create a new group conversation + * + * @param {Number} groupID The ID of the target group + * @param {String} convName The name of the new conversation + * @param {String} minMembershipLevel Minimal membership level + */ + createGroupConversation: async function(groupID, convName, minMembershipLevel) { + await api("groups/create_conversation", { + group_id: groupID, + min_membership_level: minMembershipLevel, + name: convName + }, 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 36415fbd..ecf1e714 100644 --- a/assets/js/pages/groups/pages/settings.js +++ b/assets/js/pages/groups/pages/settings.js @@ -47,7 +47,7 @@ const GroupSettingsPage = { //Create form container var formContainer = createElem2({ - appendTo: settingsBox, + //TODO : remove comment appendTo: settingsBox, type: "div", class: "group-settings-form" }); @@ -339,6 +339,45 @@ const GroupSettingsPage = { }); + /** + * Group conversations + */ + const conversationsSettingsTPL = await Page.loadHTMLTemplate("pages/groups/sections/GroupConversationsSettings.html"); + const conversationsSettingsTarget = document.createElement("div") + conversationsSettingsTarget.innerHTML = conversationsSettingsTPL + settingsPage.appendChild(conversationsSettingsTarget) + + Vue.createApp({ + data: () => { + return { + newConvName: "", + newConvVisibility: "member" + } + }, + + methods: { + createNewConv: async function() { + try { + const convName = this.newConvName; + + if (convName.length == 0) + return notify(tr("Please give a name to new group conversations!"), "danger") + + await GroupsInterface.createGroupConversation(settings.id, convName, this.newConvVisibility) + + notify("The conversation was successfully created!", "success") + + Page.refresh_current_page(); + } + + catch(e) { + console.error(e) + notify(tr("Failed to create group conversation!"), "danger") + } + } + } + }).mount(conversationsSettingsTarget); + diff --git a/assets/templates/pages/groups/sections/GroupConversationsSettings.html b/assets/templates/pages/groups/sections/GroupConversationsSettings.html new file mode 100644 index 00000000..7cd51e7a --- /dev/null +++ b/assets/templates/pages/groups/sections/GroupConversationsSettings.html @@ -0,0 +1,37 @@ + +