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)
},
/**
* 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
*

View File

@ -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);

View File

@ -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,

View File

@ -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 {}

View File

@ -5,6 +5,22 @@
</div>
<!-- /.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-->
<div class="box-footer">
@ -13,18 +29,18 @@
<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>
<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>
<option value="member">tr("Members")</option>
<option value="moderator">tr("Moderators")</option>
<option value="administrator">tr("Administrators")</option>
</select>
</div>
</div>
</div>
<div class="col-xs-2">