Can create conversations for groups

This commit is contained in:
Pierre HUBERT 2021-04-05 14:59:57 +02:00
parent 07fc609694
commit ac2ba87f18
3 changed files with 92 additions and 1 deletions

View File

@ -119,6 +119,21 @@ const GroupsInterface = {
ComunicWeb.common.api.makeAPIrequest(apiURI, settings, true, callback); 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 * Check the availability of a virtual directory for a group
* *

View File

@ -47,7 +47,7 @@ const GroupSettingsPage = {
//Create form container //Create form container
var formContainer = createElem2({ var formContainer = createElem2({
appendTo: settingsBox, //TODO : remove comment appendTo: settingsBox,
type: "div", type: "div",
class: "group-settings-form" 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);

View File

@ -0,0 +1,37 @@
<!-- Group conversations settings -->
<div class="box box-primary">
<div class="box-header with-border">
<h3 class="box-title">Group conversations</h3>
</div>
<!-- /.box-body -->
<!-- Create a new conversation-->
<div class="box-footer">
<div class="row">
<div class="col-xs-5">
<div class="form-group">
<label for="newConvName">tr("Name")</label>
<input type="text" class="form-control" id="newConvName" placeholder="tr("Conversation name")" v-model="newConvName">
</div>
</div>
<div class="col-xs-4">
<div class="form-group">
<label>tr("Visibility")</label>
<select class="form-control" v-model="newConvVisibility">
<option value="member">tr("Members")</option>
<option value="moderator">tr("Moderators")</option>
<option value="administrator">tr("Administrators")</option>
</select>
</div>
</div>
<div class="col-xs-2">
<label style="display: block;">&nbsp;</label>
<button type="button" class="btn btn-primary" @click="createNewConv">tr("Create")</button>
</div>
</div>
</div>
</div>