Changeset View
Changeset View
Standalone View
Standalone View
src/resources/vue/User/Info.vue
<template> | <template> | ||||
<div class="container"> | <div class="container"> | ||||
<status-component v-if="user_id !== 'new'" :status="status" @status-update="statusUpdate"></status-component> | <status-component v-if="user_id !== 'new'" :status="status" @status-update="statusUpdate"></status-component> | ||||
<div class="card" id="user-info"> | <div class="card" id="user-info"> | ||||
<div class="card-body"> | <div class="card-body"> | ||||
<div class="card-title" v-if="user_id !== 'new'">{{ $t('user.title') }} | <div class="card-title" v-if="user_id !== 'new'">{{ $t('user.title') }} | ||||
<button | <button | ||||
class="btn btn-outline-danger button-delete float-right" | class="btn btn-outline-danger button-delete float-end" | ||||
@click="showDeleteConfirmation()" type="button" | @click="showDeleteConfirmation()" type="button" | ||||
> | > | ||||
<svg-icon icon="trash-alt"></svg-icon> {{ $t('user.delete') }} | <svg-icon icon="trash-alt"></svg-icon> {{ $t('user.delete') }} | ||||
</button> | </button> | ||||
</div> | </div> | ||||
<div class="card-title" v-if="user_id === 'new'">{{ $t('user.new') }}</div> | <div class="card-title" v-if="user_id === 'new'">{{ $t('user.new') }}</div> | ||||
<div class="card-text"> | <div class="card-text"> | ||||
<ul class="nav nav-tabs mt-3" role="tablist"> | <ul class="nav nav-tabs mt-3" role="tablist"> | ||||
<li class="nav-item"> | <li class="nav-item"> | ||||
<a class="nav-link active" id="tab-general" href="#general" role="tab" aria-controls="general" aria-selected="true" @click="$root.tab"> | <a class="nav-link active" id="tab-general" href="#general" role="tab" aria-controls="general" aria-selected="true" @click="$root.tab"> | ||||
{{ $t('form.general') }} | {{ $t('form.general') }} | ||||
</a> | </a> | ||||
</li> | </li> | ||||
<li v-if="user_id !== 'new'" class="nav-item"> | <li v-if="user_id !== 'new'" class="nav-item"> | ||||
<a class="nav-link" id="tab-settings" href="#settings" role="tab" aria-controls="settings" aria-selected="false" @click="$root.tab"> | <a class="nav-link" id="tab-settings" href="#settings" role="tab" aria-controls="settings" aria-selected="false" @click="$root.tab"> | ||||
{{ $t('form.settings') }} | {{ $t('form.settings') }} | ||||
</a> | </a> | ||||
</li> | </li> | ||||
</ul> | </ul> | ||||
<div class="tab-content"> | <div class="tab-content"> | ||||
<div class="tab-pane show active" id="general" role="tabpanel" aria-labelledby="tab-general"> | <div class="tab-pane show active" id="general" role="tabpanel" aria-labelledby="tab-general"> | ||||
<div class="card-body"> | <div class="card-body"> | ||||
<form @submit.prevent="submit"> | <form @submit.prevent="submit"> | ||||
<div v-if="user_id !== 'new'" class="form-group row plaintext"> | <div v-if="user_id !== 'new'" class="row plaintext mb-3"> | ||||
<label for="status" class="col-sm-4 col-form-label">{{ $t('form.status') }}</label> | <label for="status" class="col-sm-4 col-form-label">{{ $t('form.status') }}</label> | ||||
<div class="col-sm-8"> | <div class="col-sm-8"> | ||||
<span :class="$root.userStatusClass(user) + ' form-control-plaintext'" id="status">{{ $root.userStatusText(user) }}</span> | <span :class="$root.userStatusClass(user) + ' form-control-plaintext'" id="status">{{ $root.userStatusText(user) }}</span> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
<div class="form-group row"> | <div class="row mb-3"> | ||||
<label for="first_name" class="col-sm-4 col-form-label">{{ $t('form.firstname') }}</label> | <label for="first_name" class="col-sm-4 col-form-label">{{ $t('form.firstname') }}</label> | ||||
<div class="col-sm-8"> | <div class="col-sm-8"> | ||||
<input type="text" class="form-control" id="first_name" v-model="user.first_name"> | <input type="text" class="form-control" id="first_name" v-model="user.first_name"> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
<div class="form-group row"> | <div class="row mb-3"> | ||||
<label for="last_name" class="col-sm-4 col-form-label">{{ $t('form.lastname') }}</label> | <label for="last_name" class="col-sm-4 col-form-label">{{ $t('form.lastname') }}</label> | ||||
<div class="col-sm-8"> | <div class="col-sm-8"> | ||||
<input type="text" class="form-control" id="last_name" v-model="user.last_name"> | <input type="text" class="form-control" id="last_name" v-model="user.last_name"> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
<div class="form-group row"> | <div class="row mb-3"> | ||||
<label for="organization" class="col-sm-4 col-form-label">{{ $t('user.org') }}</label> | <label for="organization" class="col-sm-4 col-form-label">{{ $t('user.org') }}</label> | ||||
<div class="col-sm-8"> | <div class="col-sm-8"> | ||||
<input type="text" class="form-control" id="organization" v-model="user.organization"> | <input type="text" class="form-control" id="organization" v-model="user.organization"> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
<div class="form-group row"> | <div class="row mb-3"> | ||||
<label for="email" class="col-sm-4 col-form-label">{{ $t('form.email') }}</label> | <label for="email" class="col-sm-4 col-form-label">{{ $t('form.email') }}</label> | ||||
<div class="col-sm-8"> | <div class="col-sm-8"> | ||||
<input type="text" class="form-control" id="email" :disabled="user_id !== 'new'" required v-model="user.email"> | <input type="text" class="form-control" id="email" :disabled="user_id !== 'new'" required v-model="user.email"> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
<div class="form-group row"> | <div class="row mb-3"> | ||||
<label for="aliases-input" class="col-sm-4 col-form-label">{{ $t('user.aliases-email') }}</label> | <label for="aliases-input" class="col-sm-4 col-form-label">{{ $t('user.aliases-email') }}</label> | ||||
<div class="col-sm-8"> | <div class="col-sm-8"> | ||||
<list-input id="aliases" :list="user.aliases"></list-input> | <list-input id="aliases" :list="user.aliases"></list-input> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
<div class="form-group row"> | <div class="row mb-3"> | ||||
<label for="password" class="col-sm-4 col-form-label">{{ $t('form.password') }}</label> | <label for="password" class="col-sm-4 col-form-label">{{ $t('form.password') }}</label> | ||||
<div class="col-sm-8"> | <div class="col-sm-8"> | ||||
<input type="password" class="form-control" id="password" v-model="user.password" :required="user_id === 'new'"> | <input type="password" class="form-control" id="password" v-model="user.password" :required="user_id === 'new'"> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
<div class="form-group row"> | <div class="row mb-3"> | ||||
<label for="password_confirmaton" class="col-sm-4 col-form-label">{{ $t('form.password-confirm') }}</label> | <label for="password_confirmaton" class="col-sm-4 col-form-label">{{ $t('form.password-confirm') }}</label> | ||||
<div class="col-sm-8"> | <div class="col-sm-8"> | ||||
<input type="password" class="form-control" id="password_confirmation" v-model="user.password_confirmation" :required="user_id === 'new'"> | <input type="password" class="form-control" id="password_confirmation" v-model="user.password_confirmation" :required="user_id === 'new'"> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
<div v-if="user_id === 'new'" id="user-packages" class="form-group row"> | <div v-if="user_id === 'new'" id="user-packages" class="row mb-3"> | ||||
<label class="col-sm-4 col-form-label">Package</label> | <label class="col-sm-4 col-form-label">Package</label> | ||||
<div class="col-sm-8"> | <div class="col-sm-8"> | ||||
<table class="table table-sm form-list"> | <table class="table table-sm form-list"> | ||||
<thead class="thead-light sr-only"> | <thead class="visually-hidden"> | ||||
<tr> | <tr> | ||||
<th scope="col"></th> | <th scope="col"></th> | ||||
<th scope="col">{{ $t('user.package') }}</th> | <th scope="col">{{ $t('user.package') }}</th> | ||||
<th scope="col">{{ $t('user.price') }}</th> | <th scope="col">{{ $t('user.price') }}</th> | ||||
<th scope="col"></th> | <th scope="col"></th> | ||||
</tr> | </tr> | ||||
</thead> | </thead> | ||||
<tbody> | <tbody> | ||||
<tr v-for="pkg in packages" :id="'p' + pkg.id" :key="pkg.id"> | <tr v-for="pkg in packages" :id="'p' + pkg.id" :key="pkg.id"> | ||||
<td class="selection"> | <td class="selection"> | ||||
<input type="checkbox" @click="selectPackage" | <input type="checkbox" @click="selectPackage" | ||||
:value="pkg.id" | :value="pkg.id" | ||||
:checked="pkg.id == package_id" | :checked="pkg.id == package_id" | ||||
:id="'pkg-input-' + pkg.id" | :id="'pkg-input-' + pkg.id" | ||||
> | > | ||||
</td> | </td> | ||||
<td class="name"> | <td class="name"> | ||||
<label :for="'pkg-input-' + pkg.id">{{ pkg.name }}</label> | <label :for="'pkg-input-' + pkg.id">{{ pkg.name }}</label> | ||||
</td> | </td> | ||||
<td class="price text-nowrap"> | <td class="price text-nowrap"> | ||||
{{ $root.priceLabel(pkg.cost, discount) }} | {{ $root.priceLabel(pkg.cost, discount) }} | ||||
</td> | </td> | ||||
<td class="buttons"> | <td class="buttons"> | ||||
<button v-if="pkg.description" type="button" class="btn btn-link btn-lg p-0" v-tooltip.click="pkg.description"> | <button v-if="pkg.description" type="button" class="btn btn-link btn-lg p-0" v-tooltip="pkg.description"> | ||||
<svg-icon icon="info-circle"></svg-icon> | <svg-icon icon="info-circle"></svg-icon> | ||||
<span class="sr-only">{{ $t('btn.moreinfo') }}</span> | <span class="visually-hidden">{{ $t('btn.moreinfo') }}</span> | ||||
</button> | </button> | ||||
</td> | </td> | ||||
</tr> | </tr> | ||||
</tbody> | </tbody> | ||||
</table> | </table> | ||||
<small v-if="discount > 0" class="hint"> | <small v-if="discount > 0" class="hint"> | ||||
<hr class="m-0"> | <hr class="m-0"> | ||||
¹ {{ $t('user.discount-hint') }}: {{ discount }}% - {{ discount_description }} | ¹ {{ $t('user.discount-hint') }}: {{ discount }}% - {{ discount_description }} | ||||
</small> | </small> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
<div v-if="user_id !== 'new'" id="user-skus" class="form-group row"> | <div v-if="user_id !== 'new'" id="user-skus" class="row mb-3"> | ||||
<label class="col-sm-4 col-form-label">{{ $t('user.subscriptions') }}</label> | <label class="col-sm-4 col-form-label">{{ $t('user.subscriptions') }}</label> | ||||
<div class="col-sm-8"> | <div class="col-sm-8"> | ||||
<table class="table table-sm form-list"> | <table class="table table-sm form-list"> | ||||
<thead class="thead-light sr-only"> | <thead class="visually-hidden"> | ||||
<tr> | <tr> | ||||
<th scope="col"></th> | <th scope="col"></th> | ||||
<th scope="col">{{ $t('user.subscription') }}</th> | <th scope="col">{{ $t('user.subscription') }}</th> | ||||
<th scope="col">{{ $t('user.price') }}</th> | <th scope="col">{{ $t('user.price') }}</th> | ||||
<th scope="col"></th> | <th scope="col"></th> | ||||
</tr> | </tr> | ||||
</thead> | </thead> | ||||
<tbody> | <tbody> | ||||
<tr v-for="sku in skus" :id="'s' + sku.id" :key="sku.id"> | <tr v-for="sku in skus" :id="'s' + sku.id" :key="sku.id"> | ||||
<td class="selection"> | <td class="selection"> | ||||
<input type="checkbox" @input="onInputSku" | <input type="checkbox" @input="onInputSku" | ||||
:value="sku.id" | :value="sku.id" | ||||
:disabled="sku.readonly" | :disabled="sku.readonly" | ||||
:checked="sku.enabled" | :checked="sku.enabled" | ||||
:id="'sku-input-' + sku.title" | :id="'sku-input-' + sku.title" | ||||
> | > | ||||
</td> | </td> | ||||
<td class="name"> | <td class="name"> | ||||
<label :for="'sku-input-' + sku.title">{{ sku.name }}</label> | <label :for="'sku-input-' + sku.title">{{ sku.name }}</label> | ||||
<div v-if="sku.range" class="range-input"> | <div v-if="sku.range" class="range-input"> | ||||
<label class="text-nowrap">{{ sku.range.min }} {{ sku.range.unit }}</label> | <label class="text-nowrap">{{ sku.range.min }} {{ sku.range.unit }}</label> | ||||
<input | <input | ||||
type="range" class="custom-range" @input="rangeUpdate" | type="range" class="form-range" @input="rangeUpdate" | ||||
:value="sku.value || sku.range.min" | :value="sku.value || sku.range.min" | ||||
:min="sku.range.min" | :min="sku.range.min" | ||||
:max="sku.range.max" | :max="sku.range.max" | ||||
> | > | ||||
</div> | </div> | ||||
</td> | </td> | ||||
<td class="price text-nowrap"> | <td class="price text-nowrap"> | ||||
{{ $root.priceLabel(sku.cost, discount) }} | {{ $root.priceLabel(sku.cost, discount) }} | ||||
</td> | </td> | ||||
<td class="buttons"> | <td class="buttons"> | ||||
<button v-if="sku.description" type="button" class="btn btn-link btn-lg p-0" v-tooltip.click="sku.description"> | <button v-if="sku.description" type="button" class="btn btn-link btn-lg p-0" v-tooltip="sku.description"> | ||||
<svg-icon icon="info-circle"></svg-icon> | <svg-icon icon="info-circle"></svg-icon> | ||||
<span class="sr-only">{{ $t('btn.moreinfo') }}</span> | <span class="visually-hidden">{{ $t('btn.moreinfo') }}</span> | ||||
</button> | </button> | ||||
</td> | </td> | ||||
</tr> | </tr> | ||||
</tbody> | </tbody> | ||||
</table> | </table> | ||||
<small v-if="discount > 0" class="hint"> | <small v-if="discount > 0" class="hint"> | ||||
<hr class="m-0"> | <hr class="m-0"> | ||||
¹ {{ $t('user.discount-hint') }}: {{ discount }}% - {{ discount_description }} | ¹ {{ $t('user.discount-hint') }}: {{ discount }}% - {{ discount_description }} | ||||
</small> | </small> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
<button class="btn btn-primary" type="submit"><svg-icon icon="check"></svg-icon> {{ $t('btn.submit') }}</button> | <button class="btn btn-primary" type="submit"><svg-icon icon="check"></svg-icon> {{ $t('btn.submit') }}</button> | ||||
</form> | </form> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
<div class="tab-pane" id="settings" role="tabpanel" aria-labelledby="tab-settings"> | <div class="tab-pane" id="settings" role="tabpanel" aria-labelledby="tab-settings"> | ||||
<div class="card-body"> | <div class="card-body"> | ||||
<form @submit.prevent="submitSettings"> | <form @submit.prevent="submitSettings"> | ||||
<div class="form-group row checkbox"> | <div class="row checkbox mb-3"> | ||||
<label for="greylisting" class="col-sm-4 col-form-label">{{ $t('user.greylisting') }}</label> | <label for="greylisting" class="col-sm-4 col-form-label">{{ $t('user.greylisting') }}</label> | ||||
<div class="col-sm-8 pt-2"> | <div class="col-sm-8 pt-2"> | ||||
<input type="checkbox" id="greylisting" name="greylisting" value="1" :checked="user.config.greylisting"> | <input type="checkbox" id="greylisting" name="greylisting" value="1" class="form-check-input d-block mb-2" :checked="user.config.greylisting"> | ||||
<small id="greylisting-hint" class="form-text text-muted"> | <small id="greylisting-hint" class="text-muted"> | ||||
{{ $t('user.greylisting-text') }} | {{ $t('user.greylisting-text') }} | ||||
</small> | </small> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
<button class="btn btn-primary" type="submit"><svg-icon icon="check"></svg-icon> {{ $t('btn.submit') }}</button> | <button class="btn btn-primary" type="submit"><svg-icon icon="check"></svg-icon> {{ $t('btn.submit') }}</button> | ||||
</form> | </form> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
<div id="delete-warning" class="modal" tabindex="-1" role="dialog"> | <div id="delete-warning" class="modal" tabindex="-1" role="dialog"> | ||||
<div class="modal-dialog" role="document"> | <div class="modal-dialog" role="document"> | ||||
<div class="modal-content"> | <div class="modal-content"> | ||||
<div class="modal-header"> | <div class="modal-header"> | ||||
<h5 class="modal-title">{{ $t('user.delete-email', { email: user.email }) }}</h5> | <h5 class="modal-title">{{ $t('user.delete-email', { email: user.email }) }}</h5> | ||||
<button type="button" class="close" data-dismiss="modal" :aria-label="$t('btn.close')"> | <button type="button" class="btn-close" data-bs-dismiss="modal" :aria-label="$t('btn.close')"></button> | ||||
<span aria-hidden="true">×</span> | |||||
</button> | |||||
</div> | </div> | ||||
<div class="modal-body"> | <div class="modal-body"> | ||||
<p>{{ $t('user.delete-text') }}</p> | <p>{{ $t('user.delete-text') }}</p> | ||||
</div> | </div> | ||||
<div class="modal-footer"> | <div class="modal-footer"> | ||||
<button type="button" class="btn btn-secondary modal-cancel" data-dismiss="modal">{{ $t('btn.cancel') }}</button> | <button type="button" class="btn btn-secondary modal-cancel" data-bs-dismiss="modal">{{ $t('btn.cancel') }}</button> | ||||
<button type="button" class="btn btn-danger modal-action" @click="deleteUser()"> | <button type="button" class="btn btn-danger modal-action" @click="deleteUser()"> | ||||
<svg-icon icon="trash-alt"></svg-icon> {{ $t('btn.delete') }} | <svg-icon icon="trash-alt"></svg-icon> {{ $t('btn.delete') }} | ||||
</button> | </button> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
</template> | </template> | ||||
<script> | <script> | ||||
import { Modal } from 'bootstrap' | |||||
import ListInput from '../Widgets/ListInput' | import ListInput from '../Widgets/ListInput' | ||||
import StatusComponent from '../Widgets/Status' | import StatusComponent from '../Widgets/Status' | ||||
export default { | export default { | ||||
components: { | components: { | ||||
ListInput, | ListInput, | ||||
StatusComponent | StatusComponent | ||||
}, | }, | ||||
▲ Show 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | export default { | ||||
}) | }) | ||||
.catch(this.$root.errorHandler) | .catch(this.$root.errorHandler) | ||||
}) | }) | ||||
.catch(this.$root.errorHandler) | .catch(this.$root.errorHandler) | ||||
} | } | ||||
}, | }, | ||||
mounted() { | mounted() { | ||||
$('#first_name').focus() | $('#first_name').focus() | ||||
$('#delete-warning')[0].addEventListener('shown.bs.modal', event => { | |||||
$(event.target).find('button.modal-cancel').focus() | |||||
}) | |||||
}, | }, | ||||
methods: { | methods: { | ||||
submit() { | submit() { | ||||
this.$root.clearFormValidation($('#user-info form')) | this.$root.clearFormValidation($('#user-info form')) | ||||
let method = 'post' | let method = 'post' | ||||
let location = '/api/v4/users' | let location = '/api/v4/users' | ||||
▲ Show 20 Lines • Show All 141 Lines • ▼ Show 20 Lines | export default { | ||||
.then(response => { | .then(response => { | ||||
if (response.data.status == 'success') { | if (response.data.status == 'success') { | ||||
this.$toast.success(response.data.message) | this.$toast.success(response.data.message) | ||||
this.$router.push({ name: 'users' }) | this.$router.push({ name: 'users' }) | ||||
} | } | ||||
}) | }) | ||||
}, | }, | ||||
showDeleteConfirmation() { | showDeleteConfirmation() { | ||||
// Deleting self, redirect to /profile/delete page | |||||
if (this.user_id == this.$store.state.authInfo.id) { | if (this.user_id == this.$store.state.authInfo.id) { | ||||
// Deleting self, redirect to /profile/delete page | |||||
this.$router.push({ name: 'profile-delete' }) | this.$router.push({ name: 'profile-delete' }) | ||||
} else { | } else { | ||||
// Display the warning | // Display the warning | ||||
let dialog = $('#delete-warning') | new Modal('#delete-warning').show() | ||||
dialog.on('shown.bs.modal', () => { | |||||
dialog.find('button.modal-cancel').focus() | |||||
}).modal() | |||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
</script> | </script> |