Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: make possible press enter to submit some forms #4235

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/Components/Request/RequestPicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
- SPDX-License-Identifier: AGPL-3.0-or-later
-->
<template>
<form>
<div>
<NcActions :menu-name="t('libresign', 'Request')"
:inline="inline ? 3 : 0"
:force-name="inline"
Expand Down Expand Up @@ -43,6 +43,8 @@
<NcDialog v-if="modalUploadFromUrl"
:name="t('libresign', 'URL of a PDF file')"
:can-close="!loading"
is-form
@submit.prevent="uploadUrl()"
@closing="closeModalUploadFromUrl">
<NcNoteCard v-for="message in uploadUrlErrors"
:key="message"
Expand All @@ -56,7 +58,7 @@
<template #actions>
<NcButton :disabled="!canUploadFronUrl"
type="primary"
@click="uploadUrl">
native-type="submit">
{{ t('libresign', 'Send') }}
<template #icon>
<NcLoadingIcon v-if="loading" :size="20" />
Expand All @@ -65,7 +67,7 @@
</NcButton>
</template>
</NcDialog>
</form>
</div>
</template>
<script>
import CloudUploadIcon from 'vue-material-design-icons/CloudUpload.vue'
Expand Down
6 changes: 5 additions & 1 deletion src/views/CreatePassword.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@
<template>
<NcDialog v-if="signMethodsStore.modal.createPassword"
:name="t('libresign', 'Password Creation')"
is-form
@submit.prevent="send()"
@closing="signMethodsStore.closeModal('createPassword')">
<p>{{ t('libresign', 'For security reasons, you must create a password to sign the documents. Enter your new password in the field below.') }}</p>
<NcPasswordField v-model="password"
:disabled="hasLoading"
:label="t('libresign', 'Enter a password')"
:placeholder="t('libresign', 'Enter a password')" />
<template #actions>
<NcButton :disabled="hasLoading" @click="send">
<NcButton :disabled="hasLoading"
native-type="submit"
type="primary">
<template #icon>
<NcLoadingIcon v-if="hasLoading" :size="20" />
</template>
Expand Down
6 changes: 5 additions & 1 deletion src/views/ReadCertificate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
<NcDialog v-if="signMethodsStore.modal.readCertificate"
:name="t('libresign', 'Certificate data')"
:size="size"
is-form
@submit.prevent="send()"
@closing="onClose">
<NcNoteCard v-if="error" type="error">
<p>{{ error }}</p>
Expand Down Expand Up @@ -81,7 +83,9 @@
</div>
</div>
<template v-if="Object.keys(certificateData).length === 0" #actions>
<NcButton :disabled="hasLoading" @click="send()">
<NcButton :disabled="hasLoading"
native-type="submit"
type="primary">
<template #icon>
<NcLoadingIcon v-if="hasLoading" :size="20" />
</template>
Expand Down
87 changes: 29 additions & 58 deletions src/views/ResetPassword.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,23 @@
<template>
<NcDialog v-if="signMethodsStore.modal.resetPassword"
:name="t('libresign', 'Password reset')"
class="container"
is-form
@submit.prevent="send()"
@closing="signMethodsStore.closeModal('resetPassword')">
<p>{{ t('libresign', 'Enter new password and then repeat it') }}</p>
<div class="container">
<div class="input-group">
<label for="new-password">{{ t('libresign', 'Current password') }}</label>
<NcPasswordField v-model="currentPassword" type="password" />
</div>
<div class="input-group">
<label for="new-password">{{ t('libresign', 'New password') }}</label>
<NcPasswordField v-model="newPassword" type="password" />
</div>
<div class="input-group">
<label for="repeat-password">{{ t('libresign', 'Repeat password') }}</label>
<NcPasswordField v-model="rPassword" :has-error="!validNewPassord" type="password" />
</div>
</div>
<NcPasswordField v-model="currentPassword"
:label="t('libresign', 'Current password')" />
<NcPasswordField v-model="newPassword"
:label="t('libresign', 'New password')" />
<NcPasswordField v-model="rPassword"
:has-error="!validNewPassord"
:label="t('libresign', 'Repeat password')" />
<template #actions>
<NcButton :disabled="!canSave"
:class="hasLoading ? 'btn-load loading primary btn-confirm' : 'primary btn-confirm'"
@click="send">
native-type="submit"
type="primary">
<template #icon>
<NcLoadingIcon v-if="hasLoading" :size="20" />
</template>
Expand Down Expand Up @@ -78,51 +75,25 @@ export default {
methods: {
async send() {
this.hasLoading = true
try {
const response = await axios.patch(generateOcsUrl('/apps/libresign/api/v1/account/pfx'), {
current: this.currentPassword,
new: this.newPassword,
await axios.patch(generateOcsUrl('/apps/libresign/api/v1/account/pfx'), {
current: this.currentPassword,
new: this.newPassword,
})
.then(({ data }) => {
showSuccess(data.ocs.data.message)
this.hasLoading = false
this.signMethodsStore.closeModal('resetPassword')
this.$emit('close', true)
})
showSuccess(response.data.ocs.data.message)
this.hasLoading = false
this.signMethodsStore.closeModal('resetPassword')
this.$emit('close', true)
} catch (err) {
if (err.response.data.ocs.data.message) {
showError(err.response.data.ocs.data.message)
} else {
showError(t('libresign', 'Error creating new password, please contact the administrator'))
}
this.hasLoading = false
}
.catch(({ response }) => {
if (response.data.ocs.data.message) {
showError(response.data.ocs.data.message)
} else {
showError(t('libresign', 'Error creating new password, please contact the administrator'))
}
})
this.hasLoading = false
},
},
}
</script>
<style lang="scss" scoped>
.container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;

width: 100%;
max-width: 420px;

text-align: start;
}

.input-group{
display: flex;
flex-direction: column;
margin: 10px;
width: 100%;
label:first-child{
opacity: 0.7;
}
input{
width: 100%;
max-width: 370px;
}
}
</style>
11 changes: 9 additions & 2 deletions src/views/SignPDF/_partials/ModalEmailManager.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
:label="t('libresign', 'Enter your code')"
:placeholder="t('libresign', 'Enter your code')"
name="code"
type="text">
type="text"
@keyup.enter="sendCode">
<FormTextboxPasswordIcon :size="20" />
</NcTextField>
</div>
Expand All @@ -29,18 +30,23 @@
:placeholder="t('libresign', 'Email')"
:helper-text="errorMessage"
:error="errorMessage.length > 0"
@keyup.enter="requestCode"
@input="onChangeEmail">
<EmailIcon :size="20" />
</NcTextField>
<template #actions>
<NcButton v-if="signMethodsStore.settings.emailToken.hasConfirmCode" :disabled="loading && !canRequestCode" @click="requestNewCode">
<NcButton v-if="signMethodsStore.settings.emailToken.hasConfirmCode"
:disabled="loading && !canRequestCode"
native-type="submit"
@click="requestNewCode">
<template #icon>
<NcLoadingIcon v-if="loading" :size="20" />
</template>
{{ t('libresign', 'Request new code') }}
</NcButton>
<NcButton v-if="!signMethodsStore.settings.emailToken.hasConfirmCode"
:disabled="loading || !canRequestCode"
native-type="submit"
type="primary"
@click="requestCode">
<template #icon>
Expand All @@ -50,6 +56,7 @@
</NcButton>
<NcButton v-if="signMethodsStore.settings.emailToken.hasConfirmCode"
:disabled="!canSendCode"
native-type="submit"
type="primary"
@click="sendCode">
<template #icon>
Expand Down
8 changes: 6 additions & 2 deletions src/views/SignPDF/_partials/Sign.vue
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,15 @@
:name="t('libresign', 'Confirm your signature')"
@closing="onCloseConfirmPassword">
{{ t('libresign', 'Subscription password.') }}
<NcPasswordField v-model="signPassword" type="password" />
<form @submit.prevent="signWithPassword()">
<NcPasswordField v-model="signPassword" type="password" />
</form>
<a id="lost-password" @click="toggleManagePassword">{{ t('libresign', 'Forgot password?') }}</a>
<ManagePassword v-if="showManagePassword" />
<template #actions>
<NcButton type="primary" :disabled="signPassword.length < 3 || loading" @click="signWithPassword()">
<NcButton type="primary"
:disabled="signPassword.length < 3 || loading"
native-type="submit">
<template #icon>
<NcLoadingIcon v-if="loading" :size="20" />
</template>
Expand Down
6 changes: 3 additions & 3 deletions src/views/Validation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
compact
:name="t('libresign', 'Certificate valid from:')">
<template #name>
<strong>{{ t('libresign', 'Certificate valid from:')}}</strong>
<strong>{{ t('libresign', 'Certificate valid from:') }}</strong>
{{ dateFromUnixTimestamp(signer.valid_from) }}
</template>
</NcListItem>
Expand All @@ -142,7 +142,7 @@
compact
:name="t('libresign', 'Certificate valid to:')">
<template #name>
<strong>{{ t('libresign', 'Certificate valid to:')}}</strong>
<strong>{{ t('libresign', 'Certificate valid to:') }}</strong>
{{ dateFromUnixTimestamp(signer.valid_to) }}
</template>
</NcListItem>
Expand All @@ -151,7 +151,7 @@
compact
:name="t('libresign', 'Subject:')">
<template #name>
<strong>{{ t('libresign', 'Subject:')}}</strong>
<strong>{{ t('libresign', 'Subject:') }}</strong>
{{ signer.subject }}
</template>
</NcListItem>
Expand Down
Loading