Fix conflicting history and sync delete mode on user page

This commit is contained in:
JonnyWong16 2018-02-19 10:59:10 -08:00
parent 9eddfafeae
commit 8e1a588ced
4 changed files with 22 additions and 14 deletions

View file

@ -270,7 +270,7 @@ history_table_options = {
}); });
if ($('#row-edit-mode').hasClass('active')) { if ($('#row-edit-mode').hasClass('active')) {
$('.delete-control').each(function () { $('.history_table .delete-control').each(function () {
$(this).removeClass('hidden'); $(this).removeClass('hidden');
}); });
} }
@ -466,7 +466,7 @@ function childTableOptions(rowData) {
}); });
if ($('#row-edit-mode').hasClass('active')) { if ($('#row-edit-mode').hasClass('active')) {
$('.delete-control').each(function () { $('.history_table .delete-control').each(function () {
$(this).removeClass('hidden'); $(this).removeClass('hidden');
}); });
} }

View file

@ -139,6 +139,13 @@ sync_table_options = {
// $('html,body').scrollTop(0); // $('html,body').scrollTop(0);
$('#ajaxMsg').fadeOut(); $('#ajaxMsg').fadeOut();
if ($('#sync-row-edit-mode').hasClass('active')) {
$('.sync_table .delete-control').each(function () {
$(this).removeClass('hidden');
});
}
}, },
"preDrawCallback": function (settings) { "preDrawCallback": function (settings) {
var msg = "<i class='fa fa-refresh fa-spin'></i>&nbspFetching rows..."; var msg = "<i class='fa fa-refresh fa-spin'></i>&nbspFetching rows...";

View file

@ -20,10 +20,10 @@
</div> </div>
<div class="button-bar"> <div class="button-bar">
% if _session['user_group'] == 'admin': % if _session['user_group'] == 'admin':
<div class="alert alert-danger alert-edit" role="alert" id="row-edit-mode-alert"><i class="fa fa-exclamation-triangle"></i>&nbspSelect syncs to delete. Data is deleted upon exiting edit mode.</div> <div class="alert alert-danger alert-edit" role="alert" id="sync-row-edit-mode-alert"><i class="fa fa-exclamation-triangle"></i>&nbspSelect syncs to delete. Data is deleted upon exiting delete mode.</div>
<div class="btn-group"> <div class="btn-group">
<button class="btn btn-danger btn-edit" data-toggle="button" aria-pressed="false" autocomplete="off" id="row-edit-mode"> <button class="btn btn-danger btn-edit" data-toggle="button" aria-pressed="false" autocomplete="off" id="sync-row-edit-mode">
<i class="fa fa-pencil"></i> Edit mode <i class="fa fa-trash-o"></i> Delete mode
</button>&nbsp </button>&nbsp
</div> </div>
% endif % endif
@ -138,8 +138,8 @@
loadSyncTable(selected_user_id); loadSyncTable(selected_user_id);
% if _session['user_group'] == 'admin': % if _session['user_group'] == 'admin':
$('#row-edit-mode').on('click', function() { $('#sync-row-edit-mode').on('click', function() {
$('#row-edit-mode-alert').fadeIn(200); $('#sync-row-edit-mode-alert').fadeIn(200);
if ($(this).hasClass('active')) { if ($(this).hasClass('active')) {
if (syncs_to_delete.length > 0) { if (syncs_to_delete.length > 0) {
@ -167,7 +167,7 @@
$('.delete-control').each(function () { $('.delete-control').each(function () {
$(this).addClass('hidden'); $(this).addClass('hidden');
$('#row-edit-mode-alert').fadeOut(200); $('#sync-row-edit-mode-alert').fadeOut(200);
}); });
} else { } else {

View file

@ -214,10 +214,10 @@ DOCUMENTATION :: END
</div> </div>
<div class="button-bar"> <div class="button-bar">
% if _session['user_group'] == 'admin': % if _session['user_group'] == 'admin':
<div class="alert alert-danger alert-edit" role="alert" id="sync-row-edit-mode-alert"><i class="fa fa-exclamation-triangle"></i>&nbspSelect syncs to delete. Data is deleted upon exiting edit mode.</div> <div class="alert alert-danger alert-edit" role="alert" id="sync-row-edit-mode-alert"><i class="fa fa-exclamation-triangle"></i>&nbspSelect syncs to delete. Data is deleted upon exiting delete mode.</div>
<div class="btn-group"> <div class="btn-group">
<button class="btn btn-danger btn-edit" data-toggle="button" aria-pressed="false" autocomplete="off" id="sync-row-edit-mode"> <button class="btn btn-danger btn-edit" data-toggle="button" aria-pressed="false" autocomplete="off" id="sync-row-edit-mode">
<i class="fa fa-pencil"></i> Edit mode <i class="fa fa-trash-o"></i> Delete mode
</button>&nbsp </button>&nbsp
</div> </div>
% endif % endif
@ -231,6 +231,7 @@ DOCUMENTATION :: END
<table class="display sync_table" id="sync_table-UID-${data['user_id']}" width="100%"> <table class="display sync_table" id="sync_table-UID-${data['user_id']}" width="100%">
<thead> <thead>
<tr> <tr>
<th align="left" id="delete_row">Delete</th>
<th align="left" id="state">State</th> <th align="left" id="state">State</th>
<th align="left" id="username">Username</th> <th align="left" id="username">Username</th>
<th align="left" id="sync_title">Title</th> <th align="left" id="sync_title">Title</th>
@ -529,14 +530,14 @@ DOCUMENTATION :: END
}); });
} }
$('.delete-control').each(function () { $('.history_table .delete-control').each(function () {
$(this).addClass('hidden'); $(this).addClass('hidden');
$('#row-edit-mode-alert').fadeOut(200); $('#row-edit-mode-alert').fadeOut(200);
}); });
} else { } else {
history_to_delete = []; history_to_delete = [];
$('.delete-control').each(function() { $('.history_table .delete-control').each(function() {
$(this).find('button.btn-danger').toggleClass('btn-warning').toggleClass('btn-danger'); $(this).find('button.btn-danger').toggleClass('btn-warning').toggleClass('btn-danger');
$(this).removeClass('hidden'); $(this).removeClass('hidden');
}); });
@ -571,14 +572,14 @@ DOCUMENTATION :: END
}); });
} }
$('.delete-control').each(function () { $('.sync_table .delete-control').each(function () {
$(this).addClass('hidden'); $(this).addClass('hidden');
$('#sync-row-edit-mode-alert').fadeOut(200); $('#sync-row-edit-mode-alert').fadeOut(200);
}); });
} else { } else {
syncs_to_delete = []; syncs_to_delete = [];
$('.delete-control').each(function() { $('.sync_table .delete-control').each(function() {
$(this).find('button.btn-danger').toggleClass('btn-warning').toggleClass('btn-danger'); $(this).find('button.btn-danger').toggleClass('btn-warning').toggleClass('btn-danger');
$(this).removeClass('hidden'); $(this).removeClass('hidden');
}); });