Skip to content

Commit e992453

Browse files
committed
feat: [#622] force accept agreetment before uploading
1 parent cf18f58 commit e992453

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

pages/upload.vue

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
</div>
4242
</template>
4343
</div>
44+
4445
<template v-if="categories?.length > 0">
4546
<div>
4647
<label for="category" class="px-2">Category</label>
@@ -53,6 +54,7 @@
5354
</select>
5455
</div>
5556
</template>
57+
5658
<template v-if="tags?.length > 0">
5759
<div>
5860
<label for="tags" class="px-2">Tags</label>
@@ -67,14 +69,25 @@
6769
<div>
6870
<UploadFile sub-title="Only .torrent files allowed. BitTorrent v2 files are NOT supported." accept=".torrent" @on-change="setFile" />
6971
</div>
72+
73+
<!-- Checkbox for Terms and Conditions Agreement -->
74+
<div>
75+
<label for="agree-to-terms" class="px-2">Agreement</label>
76+
<div class="mt-1">
77+
<input v-model="agreeToTerms" name="agree-to-terms" type="checkbox" class="max-w-5" data-cy="upload-form-agree-terms">
78+
<span class="px-2">I have read the <NuxtLink to="/terms" target="_blank">{{ contentUploadAgreement }}</NuxtLink>.</span>
79+
</div>
80+
</div>
81+
7082
<template v-if="user?.username">
7183
<TorrustButton
7284
label="submit"
7385
data-cy="upload-form-submit"
74-
:disabled="!formValid() || uploading"
86+
:disabled="!formValid() || !agreeToTerms || uploading"
7587
@click="submitForm"
7688
/>
7789
</template>
90+
7891
<template v-else>
7992
<div class="relative flex justify-center text-sm">
8093
<NuxtLink to="/signin">
@@ -101,7 +114,7 @@ import {
101114
useTags,
102115
useUser
103116
} from "#imports";
104-
import { useCategories } from "~/composables/states";
117+
import { useCategories, useSettings } from "~/composables/states";
105118
106119
type FormUploadTorrent = {
107120
title: string;
@@ -111,11 +124,13 @@ type FormUploadTorrent = {
111124
torrentFile: any;
112125
}
113126
127+
const settings = useSettings();
114128
const categories = useCategories();
115129
const tags = useTags();
116130
const user = useUser();
117131
const rest = useRestApi();
118132
133+
const agreeToTerms: Ref<boolean> = ref(false);
119134
const uploading: Ref<boolean> = ref(false);
120135
const descriptionView = ref("edit");
121136
const form: Ref<FormUploadTorrent> = ref({
@@ -125,12 +140,23 @@ const form: Ref<FormUploadTorrent> = ref({
125140
tags: [],
126141
torrentFile: ""
127142
});
143+
const contentUploadAgreement = ref("");
128144
129145
onMounted(() => {
130146
getCategories();
131147
getTags();
132148
});
133149
150+
watch(
151+
() => settings.value,
152+
(newSettings) => {
153+
if (newSettings?.website?.terms?.upload?.content_upload_agreement) {
154+
contentUploadAgreement.value = newSettings.website.terms.page.title;
155+
}
156+
},
157+
{ immediate: true }
158+
);
159+
134160
function formValid () {
135161
return form.value.title && form.value.category && form.value.torrentFile;
136162
}

0 commit comments

Comments
 (0)