-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixup! Force the user to scroll text to accept the TOS
Signed-off-by: greta <[email protected]>
- Loading branch information
Showing
2 changed files
with
222 additions
and
219 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,139 +1,136 @@ | ||
|
||
<!-- | ||
- SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors | ||
- SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors | ||
- SPDX-License-Identifier: AGPL-3.0-or-later | ||
--> | ||
|
||
<template> | ||
<div id="terms_of_service_confirm"> | ||
<NcModal v-if="showModal" | ||
:can-close="hasSigned" | ||
@close="handleCloseModal"> | ||
<ModalContent @click="acceptTerms"> | ||
<template #header> | ||
<h3>{{ t('terms_of_service', 'Terms of service') }}</h3> | ||
<select v-if="terms.length > 1" v-model="selectedLanguage"> | ||
<option v-for="(language, index) in languages" :key="index" :value="index"> | ||
{{ language }} | ||
</option> | ||
</select> | ||
</template> | ||
|
||
<!-- eslint-disable-next-line vue/no-v-html --> | ||
<div class="text-content" v-html="termsBody" /> | ||
</ModalContent> | ||
</NcModal> | ||
<div id="terms_of_service_content" | ||
class="modal-content" | ||
aria-live="polite"> | ||
<div class="modal-content__header"> | ||
<slot name="header" /> | ||
</div> | ||
|
||
<!-- Scrollable terms of service --> | ||
<div ref="termsContent" class="terms-content"> | ||
<slot /> | ||
</div> | ||
|
||
<NcButton ref="acceptButton" | ||
class="modal-content__button" | ||
type="primary" | ||
:wide="true" | ||
autofocus | ||
:title="t('terms_of_service', 'I acknowledge that I have read and agree to the above terms of service')" | ||
:disabled="!isScrollComplete" | ||
@click.prevent.stop="handleClick" | ||
@keydown.enter="handleClick"> | ||
{{ t('terms_of_service', 'I acknowledge that I have read and agree to the above terms of service') }} | ||
</NcButton> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import axios from '@nextcloud/axios' | ||
import { generateUrl } from '@nextcloud/router' | ||
import NcModal from '@nextcloud/vue/dist/Components/NcModal.js' | ||
import ModalContent from './components/ModalContent.vue' | ||
import NcButton from '@nextcloud/vue/dist/Components/NcButton.js' | ||
|
||
export default { | ||
name: 'UserApp', | ||
name: 'ModalContent', | ||
|
||
components: { | ||
NcModal, | ||
ModalContent, | ||
}, | ||
|
||
data() { | ||
return { | ||
showModal: false, | ||
hasSigned: false, | ||
terms: {}, | ||
languages: [], | ||
selectedLanguage: 0, | ||
termsId: 0, | ||
termsBody: '', | ||
publicContent: null, | ||
} | ||
NcButton, | ||
}, | ||
|
||
watch: { | ||
selectedLanguage(newLanguage) { | ||
this.selectTerms(newLanguage) | ||
props: { | ||
isScrollComplete: { | ||
type: Boolean, | ||
default: false, | ||
}, | ||
}, | ||
|
||
mounted() { | ||
this.loadTerms() | ||
this.$nextTick(() => { | ||
this.$refs.acceptButton.$el.focus() | ||
}) | ||
}, | ||
|
||
methods: { | ||
loadTerms() { | ||
axios | ||
.get(generateUrl('/apps/terms_of_service/terms')) | ||
.then(response => { | ||
this.hasSigned = response.data.hasSigned | ||
this.terms = response.data.terms | ||
|
||
const language = OC.getLanguage().split('-')[0] | ||
|
||
if (!this.terms.length || this.hasSigned) { | ||
return | ||
} | ||
|
||
// make it Vue | ||
this.publicContent = document.getElementById('files-public-content') | ||
if (this.publicContent !== null) { | ||
this.publicContent.style.visibility = 'hidden' | ||
} | ||
|
||
this.selectTerms(0) | ||
if (this.terms.length > 1) { | ||
Object.keys(this.terms).forEach((index) => { | ||
if (language === this.terms[index].languageCode) { | ||
this.selectedLanguage = index | ||
} | ||
|
||
this.languages.push(response.data.languages[this.terms[index].languageCode]) | ||
}) | ||
} | ||
|
||
this.showTerms() | ||
}) | ||
}, | ||
|
||
selectTerms(index) { | ||
this.termsBody = this.terms[index].renderedBody | ||
this.termsId = this.terms[index].id | ||
}, | ||
|
||
showTerms() { | ||
this.showModal = true | ||
}, | ||
|
||
acceptTerms() { | ||
this.hasSigned = true | ||
this.showModal = false | ||
|
||
let url = '/apps/terms_of_service/sign' | ||
if (this.$root.source === 'public') { | ||
url = '/apps/terms_of_service/sign_public' | ||
handleClick() { | ||
if (this.isScrollComplete) { | ||
this.$emit('click') | ||
} | ||
|
||
axios.post( | ||
generateUrl(url), | ||
{ termId: this.termsId }, | ||
).then(() => { | ||
window.location.reload() | ||
}) | ||
}, | ||
|
||
handleCloseModal() { | ||
this.showModal = false | ||
}, | ||
}, | ||
} | ||
</script> | ||
|
||
<style lang="scss" scoped> | ||
|
||
:deep .modal-container { | ||
display: flex; | ||
#terms_of_service_content.modal-content, | ||
.modal-content { | ||
padding: 0 12px; | ||
height: 100%; | ||
display: flex; | ||
flex-direction: column; | ||
color: var(--color-main-text); | ||
|
||
&__header { | ||
padding-top: 12px; | ||
} | ||
|
||
h3 { | ||
float: left; | ||
font-weight: 800; | ||
} | ||
|
||
&__button { | ||
margin: 8px 0 12px 0; | ||
} | ||
|
||
.terms-content { | ||
height: 100%; | ||
overflow-y: auto; | ||
flex: 1; | ||
} | ||
|
||
select { | ||
float: right; | ||
padding: 0 12px; | ||
|
||
color: var(--color-main-text); | ||
border: 1px solid var(--color-border-dark); | ||
border-radius: var(--border-radius); | ||
&:hover { | ||
border-color: var(--color-primary-element); | ||
} | ||
} | ||
|
||
:deep div.text-content { | ||
height: 100%; | ||
overflow: auto; | ||
text-align: left; | ||
|
||
h3 { | ||
font-weight: 800; | ||
} | ||
|
||
p { | ||
padding-top: 5px; | ||
padding-bottom: 5px; | ||
} | ||
|
||
ol { | ||
padding-left: 12px; | ||
} | ||
|
||
ul { | ||
list-style-type: disc; | ||
padding-left: 25px; | ||
} | ||
|
||
a { | ||
text-decoration: underline; | ||
color: var(--color-main-text) !important; | ||
} | ||
} | ||
} | ||
</style> | ||
|
Oops, something went wrong.