2026-02-16 19:12:00 -06:00
|
|
|
<script lang="ts" setup>
|
2026-02-25 17:33:37 -06:00
|
|
|
import type {MovieList} from "~/types/movie-list";
|
2026-04-05 00:36:20 -05:00
|
|
|
import Card from "~/components/common/card.vue";
|
2026-04-08 19:04:15 -05:00
|
|
|
import InputAction from "~/components/common/input-action.vue";
|
2026-04-16 17:58:28 -05:00
|
|
|
import ButtonAction from "~/components/common/button-action.vue";
|
2026-04-09 18:44:44 -05:00
|
|
|
import type {Role} from "~/types/role";
|
|
|
|
|
import type {ResourceResponse} from "~/types/api";
|
|
|
|
|
import type {User} from "~/types/user";
|
2026-02-16 19:12:00 -06:00
|
|
|
|
2026-04-09 18:44:44 -05:00
|
|
|
const emits = defineEmits(['back-to-list', 'update-list'])
|
2026-02-16 19:12:00 -06:00
|
|
|
const props = defineProps<{
|
2026-02-25 17:33:37 -06:00
|
|
|
list: MovieList
|
2026-02-16 19:12:00 -06:00
|
|
|
}>()
|
|
|
|
|
|
2026-04-05 00:36:20 -05:00
|
|
|
const localName = ref(props.list.name)
|
|
|
|
|
|
|
|
|
|
const collaboratorInvites = ref("");
|
|
|
|
|
const responseMessage = ref("");
|
|
|
|
|
type BasicResponse = {
|
|
|
|
|
message: string
|
|
|
|
|
}
|
|
|
|
|
const sendInvites = () => {
|
|
|
|
|
$api<BasicResponse>(`/api/invitations/`, {
|
|
|
|
|
method: 'POST',
|
|
|
|
|
body: {
|
|
|
|
|
emails: collaboratorInvites.value.split(',').map(email => email.trim()),
|
|
|
|
|
movie_list_id: props.list.id
|
|
|
|
|
}
|
|
|
|
|
}).then((response) => {
|
|
|
|
|
collaboratorInvites.value = "";
|
|
|
|
|
responseMessage.value = response.message;
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-09 18:44:44 -05:00
|
|
|
const updateCollaboratorRole = (collaborator: User) => {
|
|
|
|
|
$api<ResourceResponse<MovieList>>(`/api/movielists/${props.list.id}/collaborators/${collaborator.id}/`, {
|
|
|
|
|
method: 'PATCH',
|
|
|
|
|
body: {
|
|
|
|
|
role_id: collaborator.role
|
|
|
|
|
}
|
|
|
|
|
}).then((response) => {
|
|
|
|
|
emits('update-list', response.data)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-05 00:36:20 -05:00
|
|
|
const deleteList = () => {
|
|
|
|
|
if (!confirm("Are you sure you want to delete this list?")) return
|
|
|
|
|
|
|
|
|
|
$api(`/api/movielists/${props.list.id}`, {
|
|
|
|
|
method: 'DELETE',
|
|
|
|
|
}).then(() => {
|
|
|
|
|
navigateTo('/lists')
|
|
|
|
|
})
|
2026-02-16 19:12:00 -06:00
|
|
|
}
|
2026-04-09 18:44:44 -05:00
|
|
|
|
|
|
|
|
const roles = ref<Role[]>([])
|
|
|
|
|
|
|
|
|
|
const getRoles = () => {
|
|
|
|
|
return $api<ResourceResponse<Role[]>>(`/api/roles`, {
|
|
|
|
|
method: 'GET'
|
|
|
|
|
}).then((response) => {
|
|
|
|
|
roles.value = response.data
|
|
|
|
|
}).catch((error) => {
|
|
|
|
|
alert(error.message)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getRoles()
|
2026-02-16 19:12:00 -06:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
2026-04-08 19:04:15 -05:00
|
|
|
<Card class="card">
|
2026-04-05 00:36:20 -05:00
|
|
|
<div class="settings-header">
|
|
|
|
|
<div @click="$emit('back-to-list')">
|
|
|
|
|
<Icon name="solar:arrow-left-linear"/>
|
|
|
|
|
<span class="back-to-list">Back to MovieList</span>
|
|
|
|
|
</div>
|
2026-02-16 19:12:00 -06:00
|
|
|
</div>
|
|
|
|
|
|
2026-04-05 00:36:20 -05:00
|
|
|
<ul class="settings-list">
|
|
|
|
|
<li class="list-setting">
|
|
|
|
|
<label for="list-name-input">MovieList Name</label>
|
2026-04-08 19:04:15 -05:00
|
|
|
<InputAction
|
|
|
|
|
v-model="localName"
|
|
|
|
|
buttonText="Save"
|
|
|
|
|
inputName="list-name-input"
|
|
|
|
|
placeholder="List Name"
|
|
|
|
|
@action="$emit('update-list', { ...list, name: localName })"
|
|
|
|
|
/>
|
2026-04-05 00:36:20 -05:00
|
|
|
</li>
|
|
|
|
|
<li class="list-setting-row">
|
2026-02-16 19:12:00 -06:00
|
|
|
<label for="make-list-public">Make list public</label>
|
2026-04-05 00:36:20 -05:00
|
|
|
<input id="make-list-public" :checked="list.is_public" type="checkbox"
|
|
|
|
|
@change="$emit('update-list', { ...list, is_public: ($event.target as HTMLInputElement).checked })"/>
|
|
|
|
|
</li>
|
|
|
|
|
<li class="list-setting collaborator-list">
|
|
|
|
|
<span>Collaborators</span>
|
|
|
|
|
<details>
|
|
|
|
|
<summary>Permission levels</summary>
|
|
|
|
|
<ul>
|
2026-04-09 18:44:44 -05:00
|
|
|
<li v-for="role in roles">
|
|
|
|
|
{{ role.display_name }}: {{ role.description }}
|
2026-04-05 00:36:20 -05:00
|
|
|
</li>
|
|
|
|
|
</ul>
|
|
|
|
|
</details>
|
|
|
|
|
|
2026-04-09 18:44:44 -05:00
|
|
|
<div v-if="!list.collaborators?.length">No collaborators found</div>
|
2026-04-08 19:27:20 -05:00
|
|
|
<ul v-else class="collaborators">
|
2026-04-05 00:36:20 -05:00
|
|
|
<li v-for="collaborator in list.collaborators" :key="collaborator.id">
|
|
|
|
|
<span>{{ collaborator.username }}</span>
|
2026-04-09 18:44:44 -05:00
|
|
|
<select v-model="collaborator.role" @change="updateCollaboratorRole(collaborator)">
|
2026-04-05 00:36:20 -05:00
|
|
|
<option
|
2026-04-09 18:44:44 -05:00
|
|
|
v-for="role in roles"
|
|
|
|
|
:value="role.id"
|
2026-04-05 00:36:20 -05:00
|
|
|
>
|
2026-04-09 18:44:44 -05:00
|
|
|
{{ role.display_name }}
|
2026-04-05 00:36:20 -05:00
|
|
|
</option>
|
|
|
|
|
</select>
|
2026-02-16 19:12:00 -06:00
|
|
|
</li>
|
|
|
|
|
</ul>
|
2026-04-05 00:36:20 -05:00
|
|
|
</li>
|
|
|
|
|
<li class="list-setting">
|
|
|
|
|
<form class="list-setting" @submit.prevent="sendInvites">
|
|
|
|
|
<label for="invite-collaborators-input">Invite Collaborators</label>
|
|
|
|
|
<textarea v-model="collaboratorInvites" name="invite-collaborators-input" type="text"></textarea>
|
|
|
|
|
<button>Send Invites</button>
|
|
|
|
|
<span v-if="responseMessage">{{ responseMessage }}</span>
|
|
|
|
|
</form>
|
|
|
|
|
</li>
|
|
|
|
|
<li class="list-setting">
|
|
|
|
|
<label for="delete-list-button">Delete MovieList</label>
|
2026-04-16 17:58:28 -05:00
|
|
|
<ButtonAction button-color="danger" button-text="Delete" @action="deleteList"/>
|
2026-04-05 00:36:20 -05:00
|
|
|
</li>
|
|
|
|
|
</ul>
|
|
|
|
|
</Card>
|
2026-02-16 19:12:00 -06:00
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
2026-04-16 17:58:28 -05:00
|
|
|
select {
|
|
|
|
|
padding: 0.5rem;
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-05 00:36:20 -05:00
|
|
|
.back-to-list:hover {
|
|
|
|
|
text-decoration: underline;
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-16 19:12:00 -06:00
|
|
|
.collaborator-list {
|
|
|
|
|
gap: 1rem;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.collaborators li {
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.list-setting {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
gap: 1rem;
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-16 17:58:28 -05:00
|
|
|
.list-setting > button {
|
|
|
|
|
background-color: var(--color-button-primary, #4caf50);
|
|
|
|
|
color: white;
|
|
|
|
|
border: none;
|
|
|
|
|
border-radius: 0.25rem;
|
|
|
|
|
padding: 0.5rem 1rem;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-05 00:36:20 -05:00
|
|
|
.list-setting-row {
|
|
|
|
|
display: flex;
|
|
|
|
|
gap: 1rem;
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-16 19:12:00 -06:00
|
|
|
.settings-header {
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: space-between;
|
2026-04-05 00:36:20 -05:00
|
|
|
padding-bottom: 1rem;
|
2026-02-16 19:12:00 -06:00
|
|
|
cursor: pointer;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.settings-header > div {
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.settings-list {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
gap: 1rem;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.settings-list > li {
|
|
|
|
|
display: flex;
|
2026-04-05 00:36:20 -05:00
|
|
|
border: rgba(0, 0, 0, 0.2) 1px solid;
|
2026-02-16 19:12:00 -06:00
|
|
|
padding: 1rem;
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-16 17:58:28 -05:00
|
|
|
summary {
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-16 19:12:00 -06:00
|
|
|
details ul > li {
|
|
|
|
|
padding: 1rem;
|
2026-04-16 17:58:28 -05:00
|
|
|
border: rgba(0, 0, 0, 0.3) 1px solid;
|
2026-02-16 19:12:00 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
details ul > li:not(:last-child) {
|
|
|
|
|
border-bottom: none;
|
|
|
|
|
}
|
2026-04-08 19:04:15 -05:00
|
|
|
|
|
|
|
|
|
2026-02-16 19:12:00 -06:00
|
|
|
</style>
|