Add delete user UI

This provides the UI for the delete user feature introduced in
4229084c62

Placing of the user delete button is not perfect, but can be moved to an
own user tab later on.

Signed-off-by: Sheogorath <sheogorath@shivering-isles.com>
This commit is contained in:
Sheogorath 2018-05-25 17:03:35 +02:00
parent e31d204d74
commit 9fd09a8dfb
No known key found for this signature in database
GPG Key ID: 1F05CC3635CDDFFD
3 changed files with 44 additions and 16 deletions

View File

@ -107,5 +107,8 @@
"Night Theme": "Night Theme", "Night Theme": "Night Theme",
"Follow us on %s and %s.": "Follow us on %s, and %s.", "Follow us on %s and %s.": "Follow us on %s, and %s.",
"Privacy": "Privacy", "Privacy": "Privacy",
"Terms of Use": "Terms of Use" "Terms of Use": "Terms of Use",
"Do you really want to delete your user account?": "Do you really want to delete your user account?",
"This will delete your account, all notes that are owned by you and remove all references to your account from other notes.": "This will delete your account, all notes that are owned by you and remove all references to your account from other notes.",
"Delete user": "Delete user"
} }

View File

@ -39,7 +39,7 @@ const options = {
'<a href="#">' + '<a href="#">' +
'<div class="item">' + '<div class="item">' +
'<div class="ui-history-pin fa fa-thumb-tack fa-fw"></div>' + '<div class="ui-history-pin fa fa-thumb-tack fa-fw"></div>' +
'<div class="ui-history-close fa fa-close fa-fw" data-toggle="modal" data-target=".delete-modal"></div>' + '<div class="ui-history-close fa fa-close fa-fw" data-toggle="modal" data-target=".delete-history-modal"></div>' +
'<div class="content">' + '<div class="content">' +
'<h4 class="text"></h4>' + '<h4 class="text"></h4>' +
'<p>' + '<p>' +
@ -208,8 +208,8 @@ function historyCloseClick (e) {
e.preventDefault() e.preventDefault()
const id = $(this).closest('a').siblings('span').html() const id = $(this).closest('a').siblings('span').html()
const value = historyList.get('id', id)[0]._values const value = historyList.get('id', id)[0]._values
$('.ui-delete-modal-msg').text('Do you really want to delete below history?') $('.ui-delete-history-modal-msg').text('Do you really want to delete below history?')
$('.ui-delete-modal-item').html(`<i class="fa fa-file-text"></i> ${value.text}<br><i class="fa fa-clock-o"></i> ${value.time}`) $('.ui-delete-history-modal-item').html(`<i class="fa fa-file-text"></i> ${value.text}<br><i class="fa fa-clock-o"></i> ${value.time}`)
clearHistory = false clearHistory = false
deleteId = id deleteId = id
} }
@ -277,7 +277,7 @@ function deleteHistory () {
checkHistoryList() checkHistoryList()
} }
} }
$('.delete-modal').modal('hide') $('.delete-history-modal').modal('hide')
deleteId = null deleteId = null
clearHistory = false clearHistory = false
}) })
@ -297,12 +297,12 @@ function deleteHistory () {
deleteId = null deleteId = null
}) })
} }
$('.delete-modal').modal('hide') $('.delete-history-modal').modal('hide')
clearHistory = false clearHistory = false
}) })
} }
$('.ui-delete-modal-confirm').click(() => { $('.ui-delete-history-modal-confirm').click(() => {
deleteHistory() deleteHistory()
}) })
@ -342,8 +342,8 @@ $('.ui-open-history').bind('change', e => {
}) })
$('.ui-clear-history').click(() => { $('.ui-clear-history').click(() => {
$('.ui-delete-modal-msg').text('Do you really want to clear all history?') $('.ui-delete-history-modal-msg').text('Do you really want to clear all history?')
$('.ui-delete-modal-item').html('There is no turning back.') $('.ui-delete-history-modal-item').html('There is no turning back.')
clearHistory = true clearHistory = true
deleteId = null deleteId = null
}) })
@ -371,6 +371,10 @@ $('.ui-refresh-history').click(() => {
}) })
}) })
$('.ui-delete-user-modal-cancel').click(() => {
$('.ui-delete-user').parent().removeClass('active')
})
$('.ui-logout').click(() => { $('.ui-logout').click(() => {
clearLoginState() clearLoginState()
location.href = `${serverurl}/logout` location.href = `${serverurl}/logout`

View File

@ -27,6 +27,7 @@
</button> </button>
<ul class="dropdown-menu" aria-labelledby="profileLabel"> <ul class="dropdown-menu" aria-labelledby="profileLabel">
<li><a href="<%- url %>/features"><i class="fa fa-dot-circle-o fa-fw"></i> <%= __('Features') %></a></li> <li><a href="<%- url %>/features"><i class="fa fa-dot-circle-o fa-fw"></i> <%= __('Features') %></a></li>
<li><a class="ui-delete-user" data-toggle="modal" data-target=".delete-user-modal"><i class="fa fa-trash fa-fw"></i> <%= __('Delete user') %></a></li>
<li><a href="<%- url %>/logout"><i class="fa fa-sign-out fa-fw"></i> <%= __('Sign Out') %></a></li> <li><a href="<%- url %>/logout"><i class="fa fa-sign-out fa-fw"></i> <%= __('Sign Out') %></a></li>
</ul> </ul>
</span> </span>
@ -108,7 +109,7 @@
<span class="btn btn-default btn-file ui-open-history" title="<%= __('Import history') %>"> <span class="btn btn-default btn-file ui-open-history" title="<%= __('Import history') %>">
<i class="fa fa-folder-open-o"></i><input type="file" /> <i class="fa fa-folder-open-o"></i><input type="file" />
</span> </span>
<a href="#" class="btn btn-default ui-clear-history" title="<%= __('Clear history') %>" data-toggle="modal" data-target=".delete-modal"><i class="fa fa-trash-o"></i></a> <a href="#" class="btn btn-default ui-clear-history" title="<%= __('Clear history') %>" data-toggle="modal" data-target=".delete-history-modal"><i class="fa fa-trash-o"></i></a>
</span> </span>
<a href="#" class="btn btn-default ui-refresh-history" title="<%= __('Refresh history') %>"><i class="fa fa-refresh"></i></a> <a href="#" class="btn btn-default ui-refresh-history" title="<%= __('Refresh history') %>"><i class="fa fa-refresh"></i></a>
</form> </form>
@ -157,8 +158,8 @@
</div> </div>
</div> </div>
</div> </div>
<!-- delete modal --> <!-- delete history modal -->
<div class="modal fade delete-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal fade delete-history-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog modal-sm"> <div class="modal-dialog modal-sm">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
@ -167,12 +168,32 @@
<h4 class="modal-title" id="myModalLabel"><%= __('Are you sure?') %></h4> <h4 class="modal-title" id="myModalLabel"><%= __('Are you sure?') %></h4>
</div> </div>
<div class="modal-body" style="color:black;"> <div class="modal-body" style="color:black;">
<h5 class="ui-delete-modal-msg"></h5> <h5 class="ui-delete-history-modal-msg"></h5>
<strong class="ui-delete-modal-item"></strong> <strong class="ui-delete-history-modal-item"></strong>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal"><%= __('Cancel') %></button> <button type="button" class="btn btn-default" data-dismiss="modal"><%= __('Cancel') %></button>
<button type="button" class="btn btn-danger ui-delete-modal-confirm"><%= __('Yes, do it!') %></button> <button type="button" class="btn btn-danger ui-delete-history-modal-confirm"><%= __('Yes, do it!') %></button>
</div>
</div>
</div>
</div>
<!-- delete user modal -->
<div class="modal fade delete-user-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title" id="myModalLabel"><%= __('Are you sure?') %></h4>
</div>
<div class="modal-body" style="color:black;">
<h5 class="ui-delete-user-modal-msg"><%= __('Do you really want to delete your user account?') %></h5>
<strong class="ui-delete-user-modal-item"><%= __('This will delete your account, all notes that are owned by you and remove all references to your account from other notes.') %></strong>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default ui-delete-user-modal-cancel" data-dismiss="modal"><%= __('Cancel') %></button>
<a type="button" class="btn btn-danger" href="<%- url %>/me/delete"><%= __('Yes, do it!') %></a>
</div> </div>
</div> </div>
</div> </div>