Skip to content

Commit

Permalink
feat: do not show tag list in torrent edition is there are no tags
Browse files Browse the repository at this point in the history
Tags are defined by the admin. If the admin does not define any, the
user cannot add tags to the torrent. The upload form does not show tags
in that case. This commit does the same in the edition form.
  • Loading branch information
josecelano committed Jun 27, 2023
1 parent 525aad7 commit 65c6e01
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions pages/torrent/edit/[infoHash].vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,17 @@
</select>
</div>
</template>
<div>
<label for="tags" class="px-2">Tags</label>
<TorrustSelect
v-model:selected="form.tags"
:options="tags.map(entry => ({ name: entry.name, value: entry.tag_id }))"
:multiple="true"
search
/>
</div>
<template v-if="tags?.length > 0">
<div>
<label for="tags" class="px-2">Tags</label>
<TorrustSelect
v-model:selected="form.tags"
:options="tags.map(entry => ({ name: entry.name, value: entry.tag_id }))"
:multiple="true"
search
/>
</div>
</template>
<template v-if="user?.username">
<button
class="btn btn-primary"
Expand Down Expand Up @@ -132,10 +134,10 @@ function getTorrentFromApi (infoHash: string) {
form.value.title = data.title;
form.value.description = data.description;
if (typeof data.category === "object" && "category_id" in data.category) {
form.value.category = data.category.category_id;
} else {
if (data.category === null) {
form.value.category = null;
} else {
form.value.category = data.category.category_id;
}
form.value.tags = data.tags.map((tag) => {
Expand All @@ -154,7 +156,7 @@ function getTorrentFromApi (infoHash: string) {
}
function formValid () {
return form.value.title && (form.value.title + form.value.description) !== (torrent.value.title + torrent.value.description + torrent.value.category.name);
return form.value.title && form.value.description;
}
function submitForm () {
Expand Down

0 comments on commit 65c6e01

Please sign in to comment.