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'">User account</div> | <div class="card-title" v-if="user_id !== 'new'">User account | ||||
<button | |||||
class="btn btn-outline-danger button-delete float-right" | |||||
v-on:click="showDeleteConfirmation()" tag="button" | |||||
> | |||||
<svg-icon icon="trash-alt"></svg-icon> Delete user | |||||
</button> | |||||
</div> | |||||
<div class="card-title" v-if="user_id === 'new'">New user account</div> | <div class="card-title" v-if="user_id === 'new'">New user account</div> | ||||
<div class="card-text"> | <div class="card-text"> | ||||
<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="form-group row plaintext"> | ||||
<label for="first_name" class="col-sm-4 col-form-label">Status</label> | <label for="first_name" class="col-sm-4 col-form-label">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> | ||||
▲ Show 20 Lines • Show All 134 Lines • ▼ Show 20 Lines | <div class="container"> | ||||
</small> | </small> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
<button class="btn btn-primary" type="submit"><svg-icon icon="check"></svg-icon> Submit</button> | <button class="btn btn-primary" type="submit"><svg-icon icon="check"></svg-icon> Submit</button> | ||||
</form> | </form> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
<div id="delete-warning" class="modal" tabindex="-1" role="dialog"> | |||||
<div class="modal-dialog" role="document"> | |||||
<div class="modal-content"> | |||||
<div class="modal-header"> | |||||
<h5 class="modal-title"></h5> | |||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"> | |||||
<span aria-hidden="true">×</span> | |||||
</button> | |||||
</div> | |||||
<div class="modal-body"> | |||||
<p>Do you really want to delete this user permanently? | |||||
This will delete all account data and withdraw the permission to access the email account. | |||||
Please note that this action cannot be undone.</p> | |||||
</div> | |||||
<div class="modal-footer"> | |||||
<button type="button" class="btn btn-secondary modal-cancel" data-dismiss="modal">Cancel</button> | |||||
<button type="button" class="btn btn-danger modal-action" @click="deleteUser()"> | |||||
<svg-icon icon="trash-alt"></svg-icon> Delete | |||||
</button> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
</div> | </div> | ||||
</template> | </template> | ||||
<script> | <script> | ||||
import ListInput from '../Widgets/ListInput' | import ListInput from '../Widgets/ListInput' | ||||
import StatusComponent from '../Widgets/Status' | import StatusComponent from '../Widgets/Status' | ||||
export default { | export default { | ||||
▲ Show 20 Lines • Show All 196 Lines • ▼ Show 20 Lines | export default { | ||||
for (let i = 0; i < this.skus.length; i++) { | for (let i = 0; i < this.skus.length; i++) { | ||||
if (this.skus[i].id == id) { | if (this.skus[i].id == id) { | ||||
return this.skus[i]; | return this.skus[i]; | ||||
} | } | ||||
} | } | ||||
}, | }, | ||||
statusUpdate(user) { | statusUpdate(user) { | ||||
this.user = Object.assign({}, this.user, user) | this.user = Object.assign({}, this.user, user) | ||||
}, | |||||
deleteUser() { | |||||
// Delete the user from the confirm dialog | |||||
axios.delete('/api/v4/users/' + this.user_id) | |||||
.then(response => { | |||||
if (response.data.status == 'success') { | |||||
this.$toast.success(response.data.message) | |||||
this.$router.push({ name: 'users' }) | |||||
} | |||||
}) | |||||
}, | |||||
showDeleteConfirmation() { | |||||
// Deleting self, redirect to /profile/delete page | |||||
if (this.user_id == this.$store.state.authInfo.id) { | |||||
this.$router.push({ name: 'profile-delete' }) | |||||
} else { | |||||
// Display the warning | |||||
let dialog = $('#delete-warning').modal('hide') | |||||
machniak: `.modal('hide')` is redundant here. | |||||
dialog.find('.modal-title').text('Delete ' + this.user.email) | |||||
dialog.on('shown.bs.modal', () => { | |||||
dialog.find('button.modal-cancel').focus() | |||||
}).modal() | |||||
} | |||||
} | } | ||||
} | } | ||||
} | } | ||||
</script> | </script> |
.modal('hide') is redundant here.