mirror of
https://github.com/TeamPiped/Piped.git
synced 2026-09-15 17:23:45 +00:00
feat: option to create group in add to group modal
This commit is contained in:
@@ -1,27 +1,38 @@
|
||||
<template>
|
||||
<ModalComponent @close="$emit('close')">
|
||||
<div class="h-[80vh] overflow-y-scroll pr-4">
|
||||
<span v-t="'actions.add_to_group'" class="mb-3 inline-block w-max text-2xl" />
|
||||
<div v-for="(group, index) in channelGroups" :key="group.groupName" class="px-1">
|
||||
<div class="flex items-center justify-between">
|
||||
<span>{{ group.groupName }}</span>
|
||||
<input
|
||||
type="checkbox"
|
||||
:checked="group.channels.includes(channelId)"
|
||||
@change="onCheckedChange(index, group)"
|
||||
/>
|
||||
<div class="min-w-[50vw] flex flex-col">
|
||||
<div class="h-[70vh] overflow-y-scroll pr-4">
|
||||
<span v-t="'actions.add_to_group'" class="mb-3 inline-block w-max text-2xl" />
|
||||
<div v-for="(group, index) in channelGroups" :key="group.groupName" class="px-1">
|
||||
<div class="flex items-center justify-between">
|
||||
<span>{{ group.groupName }}</span>
|
||||
<input
|
||||
type="checkbox"
|
||||
:checked="group.channels.includes(channelId)"
|
||||
@change="onCheckedChange(index, group)"
|
||||
/>
|
||||
</div>
|
||||
<hr class="h-1 w-full" />
|
||||
</div>
|
||||
<hr class="h-1 w-full" />
|
||||
</div>
|
||||
<button v-t="'actions.create_group'" class="btn ml-auto w-max" @click="showCreateGroupModal = true" />
|
||||
</div>
|
||||
</ModalComponent>
|
||||
|
||||
<CreateGroupModal
|
||||
v-if="showCreateGroupModal"
|
||||
:on-create-group="onCreateGroup"
|
||||
@close="showCreateGroupModal = false"
|
||||
/>
|
||||
</template>
|
||||
<script>
|
||||
import ModalComponent from "./ModalComponent.vue";
|
||||
import CreateGroupModal from "./CreateGroupModal.vue";
|
||||
|
||||
export default {
|
||||
components: {
|
||||
ModalComponent,
|
||||
CreateGroupModal,
|
||||
},
|
||||
props: {
|
||||
channelId: {
|
||||
@@ -32,6 +43,7 @@ export default {
|
||||
emits: ["close"],
|
||||
data() {
|
||||
return {
|
||||
showCreateGroupModal: false,
|
||||
channelGroups: [],
|
||||
};
|
||||
},
|
||||
@@ -51,6 +63,18 @@ export default {
|
||||
}
|
||||
this.createOrUpdateChannelGroup(group);
|
||||
},
|
||||
onCreateGroup(newGroupName) {
|
||||
if (!newGroupName || this.channelGroups.some(group => group.groupName == newGroupName)) return;
|
||||
|
||||
const newGroup = {
|
||||
groupName: newGroupName,
|
||||
channels: [],
|
||||
};
|
||||
this.channelGroups.push(newGroup);
|
||||
this.createOrUpdateChannelGroup(newGroup);
|
||||
|
||||
this.showCreateGroupModal = false;
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user