Can delete a group conversation

This commit is contained in:
Pierre HUBERT 2021-04-05 15:16:37 +02:00
parent ac2ba87f18
commit 2fb3c7e789
5 changed files with 63 additions and 8 deletions

View File

@ -134,6 +134,17 @@ const GroupsInterface = {
}, true) }, 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 * Check the availability of a virtual directory for a group
* *

View File

@ -350,12 +350,17 @@ const GroupSettingsPage = {
Vue.createApp({ Vue.createApp({
data: () => { data: () => {
return { return {
conversations: settings.conversations,
newConvName: "", newConvName: "",
newConvVisibility: "member" newConvVisibility: "member"
} }
}, },
methods: { methods: {
/**
* Create a new conversation
*/
createNewConv: async function() { createNewConv: async function() {
try { try {
const convName = this.newConvName; const convName = this.newConvName;
@ -374,6 +379,27 @@ const GroupSettingsPage = {
console.error(e) console.error(e)
notify(tr("Failed to create group conversation!"), "danger") 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); }).mount(conversationsSettingsTarget);

View File

@ -27,6 +27,7 @@ declare interface Conversation {
color?: string, color?: string,
logo?: string, logo?: string,
group_id?: number, group_id?: number,
group_min_membership_level ?: "member"|"moderator"|"administrator",
members: ConversationMember[], members: ConversationMember[],
can_everyone_add_members: boolean, can_everyone_add_members: boolean,
can_have_call: boolean, can_have_call: boolean,

View File

@ -10,7 +10,8 @@ declare interface AdvancedGroupInfo extends Group {
description: String, description: String,
url: String, url: String,
number_likes: Number, number_likes: Number,
is_liking: Boolean is_liking: Boolean,
conversations: Conversation[],
} }
declare interface GroupSettings extends AdvancedGroupInfo {} declare interface GroupSettings extends AdvancedGroupInfo {}

View File

@ -5,6 +5,22 @@
</div> </div>
<!-- /.box-body --> <!-- /.box-body -->
<div class="box-body no-padding">
<table class="table">
<tbody><tr>
<th>Name</th>
<th>Visibility</th>
<th></th>
</tr>
<tr v-for="conv in conversations">
<td>{{ conv.name }}</td>
<td>{{ conv.group_min_membership_level }}</td>
<td>
<a style="color: white;" @click="deleteConv(conv.id)"><i class="fa fa-trash"></i></a>
</td>
</tr>
</tbody></table>
</div>
<!-- Create a new conversation--> <!-- Create a new conversation-->
<div class="box-footer"> <div class="box-footer">
@ -13,20 +29,20 @@
<div class="form-group"> <div class="form-group">
<label for="newConvName">tr("Name")</label> <label for="newConvName">tr("Name")</label>
<input type="text" class="form-control" id="newConvName" placeholder="tr("Conversation name")" v-model="newConvName"> <input type="text" class="form-control" id="newConvName" placeholder="tr("Conversation name")" v-model="newConvName">
</div> </div>
</div> </div>
<div class="col-xs-4"> <div class="col-xs-4">
<div class="form-group"> <div class="form-group">
<label>tr("Visibility")</label> <label>tr("Visibility")</label>
<select class="form-control" v-model="newConvVisibility"> <select class="form-control" v-model="newConvVisibility">
<option value="member">tr("Members")</option> <option value="member">tr("Members")</option>
<option value="moderator">tr("Moderators")</option> <option value="moderator">tr("Moderators")</option>
<option value="administrator">tr("Administrators")</option> <option value="administrator">tr("Administrators")</option>
</select> </select>
</div> </div>
</div> </div>
<div class="col-xs-2"> <div class="col-xs-2">
<label style="display: block;">&nbsp;</label> <label style="display: block;">&nbsp;</label>
<button type="button" class="btn btn-primary" @click="createNewConv">tr("Create")</button> <button type="button" class="btn btn-primary" @click="createNewConv">tr("Create")</button>