mirror of
https://github.com/danbulant/Nertivia-Client
synced 2026-07-06 11:30:46 +00:00
send message permission
This commit is contained in:
parent
652f06d18f
commit
c1f567144c
2 changed files with 57 additions and 7 deletions
|
|
@ -33,7 +33,18 @@
|
||||||
@input="inputEvent('name', $event)"
|
@input="inputEvent('name', $event)"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="button" v-if="update.name" @click="updateChannel">Save Changes</div>
|
<div class="input">
|
||||||
|
<div class="input-title">Permissions</div>
|
||||||
|
<div class="check-box" @click="updatePermissions('send_message')">
|
||||||
|
<div
|
||||||
|
class="box"
|
||||||
|
:class="{checked: sendMessagePermission}"
|
||||||
|
/>
|
||||||
|
<div class="name">Send Messages</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="button" v-if="update.name || update.permissions" @click="updateChannel">Save Changes</div>
|
||||||
<div
|
<div
|
||||||
class="button warn delete-server disabled"
|
class="button warn delete-server disabled"
|
||||||
v-if="server.default_channel_id === channels[selectedChannelIndex].channelID"
|
v-if="server.default_channel_id === channels[selectedChannelIndex].channelID"
|
||||||
|
|
@ -65,7 +76,7 @@ export default {
|
||||||
selectedChannelIndex: 0,
|
selectedChannelIndex: 0,
|
||||||
errors: null,
|
errors: null,
|
||||||
update: {
|
update: {
|
||||||
name: null
|
name: null,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
@ -81,13 +92,16 @@ export default {
|
||||||
const data = {
|
const data = {
|
||||||
name: this.update.name || this.channels[this.selectedChannelIndex].name
|
name: this.update.name || this.channels[this.selectedChannelIndex].name
|
||||||
};
|
};
|
||||||
|
if (this.update.permissions) {
|
||||||
|
data.permissions = this.update.permissions;
|
||||||
|
}
|
||||||
const { ok, error, result } = await ServerService.updateChannel(
|
const { ok, error, result } = await ServerService.updateChannel(
|
||||||
this.server.server_id,
|
this.server.server_id,
|
||||||
this.channels[this.selectedChannelIndex].channelID,
|
this.channels[this.selectedChannelIndex].channelID,
|
||||||
data
|
data
|
||||||
);
|
);
|
||||||
if (ok) {
|
if (ok) {
|
||||||
this.update.name = null;
|
this.update = {name: null};
|
||||||
} else {
|
} else {
|
||||||
if (error.response) {
|
if (error.response) {
|
||||||
if (error.response.data.message)
|
if (error.response.data.message)
|
||||||
|
|
@ -118,8 +132,13 @@ export default {
|
||||||
channelClick(event, index) {
|
channelClick(event, index) {
|
||||||
this.selectedChannelIndex = index;
|
this.selectedChannelIndex = index;
|
||||||
this.$refs["name"].value = this.channels[this.selectedChannelIndex].name;
|
this.$refs["name"].value = this.channels[this.selectedChannelIndex].name;
|
||||||
this.update.name = null;
|
this.update = {name: null};
|
||||||
this.deleteButtonConfirmed = false;
|
this.deleteButtonConfirmed = false;
|
||||||
|
},
|
||||||
|
updatePermissions(permissionName) {
|
||||||
|
const permissions = this.update.permissions || {}
|
||||||
|
permissions[permissionName] = !this.sendMessagePermission;
|
||||||
|
this.$set(this.update, 'permissions', permissions )
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
|
@ -134,12 +153,23 @@ export default {
|
||||||
return channelIDs.map(c => {
|
return channelIDs.map(c => {
|
||||||
return channels[c];
|
return channels[c];
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
sendMessagePermission() {
|
||||||
|
const channel = this.channels[this.selectedChannelIndex];
|
||||||
|
const permissions = this.update.permissions || undefined
|
||||||
|
if (permissions) {
|
||||||
|
return !!permissions.send_message
|
||||||
|
}
|
||||||
|
if (!channel.permissions) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return !!channel.permissions.send_message
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped lang="scss">
|
||||||
.server-avatar {
|
.server-avatar {
|
||||||
background: grey;
|
background: grey;
|
||||||
height: 90px;
|
height: 90px;
|
||||||
|
|
@ -248,6 +278,26 @@ export default {
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
width: initial;
|
width: initial;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.check-box {
|
||||||
|
display: flex;
|
||||||
|
margin: 5px;
|
||||||
|
align-content: center;
|
||||||
|
align-items: center;
|
||||||
|
user-select: none;
|
||||||
|
cursor: pointer;
|
||||||
|
.box {
|
||||||
|
height: 20px;
|
||||||
|
width: 20px;
|
||||||
|
flex-shrink: 0;
|
||||||
|
background-color: rgb(255, 31, 31);
|
||||||
|
margin-right: 5px;
|
||||||
|
border-radius: 2px;
|
||||||
|
&.checked {
|
||||||
|
background-color: rgb(31, 154, 255);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -323,8 +323,8 @@ const actions = {
|
||||||
context.dispatch('channel', channel);
|
context.dispatch('channel', channel);
|
||||||
context.dispatch('servers/AddChannelsIDs', {serverID: channel.server_id, channelsIDs: [channel.channelID]})
|
context.dispatch('servers/AddChannelsIDs', {serverID: channel.server_id, channelsIDs: [channel.channelID]})
|
||||||
},
|
},
|
||||||
['socket_server:updateChannel'](context, {name, channelID}) { // update_channel
|
['socket_server:updateChannel'](context, update) { // update_channel
|
||||||
context.dispatch('updateChannel', {name, channelID});
|
context.dispatch('updateChannel', update);
|
||||||
},
|
},
|
||||||
['socket_server:removeChannel'](context, {server_id, channelID}) {
|
['socket_server:removeChannel'](context, {server_id, channelID}) {
|
||||||
context.dispatch('servers/removeServerChannel', {server_id, channelID});
|
context.dispatch('servers/removeServerChannel', {server_id, channelID});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue