Fix quick actions for alias table when pagination is true

This commit is contained in:
andryyy 2017-04-27 09:49:04 +02:00
parent e26304f6d0
commit 68e67ba9b7
2 changed files with 77 additions and 66 deletions

View File

@ -31,4 +31,7 @@ table.footable>tbody>tr.footable-empty>td {
} }
#alias_table { #alias_table {
cursor:pointer; cursor:pointer;
}
#alias_table .footable-paging {
cursor: auto;
} }

View File

@ -271,74 +271,82 @@ $(document).ready(function() {
"sorting": { "sorting": {
"enabled": true "enabled": true
} }
}, function aliases_table_hook() { });
var selected_aliases = {};
$('input[name=sel_aliases]').change(function() { var selected_aliases = {};
selected_aliases = {};
$('input[name=sel_aliases]:checked').each(function(i) { $(document).on('click', 'tr', function(e) {
selected_aliases[i] = ($(this).val()); if (e.target.type == "checkbox") {
}); e.stopPropagation();
}); } else {
$("#select_all_aliases").click(function(e) { var $checkbox = $(this).find(':checkbox');
e.preventDefault(); var checkbox = $(this).find(':checkbox');
var alias_chkbxs = $("input[name=sel_aliases]"); checkbox.trigger('click');
alias_chkbxs.prop("checked", !alias_chkbxs.prop("checked")).change(); }
}); });
$("#activate_selected_alias").click(function(e) {
e.preventDefault(); $(document).on('change', 'input[name=sel_aliases]', function() {
if (Object.keys(selected_aliases).length !== 0) { selected_aliases = {};
$.ajax({ $('input[name=sel_aliases]:checked').each(function(i) {
type: "POST", selected_aliases[i] = ($(this).val());
dataType: "json",
data: { "address": JSON.stringify(selected_aliases), "active": "1" },
url: '/api/v1/edit/alias/post',
jsonp: false,
complete: function (data) {
location.reload();
}
});
}
});
$("#deactivate_selected_alias").click(function(e) {
e.preventDefault();
if (Object.keys(selected_aliases).length !== 0) {
$.ajax({
type: "POST",
dataType: "json",
data: { "address": JSON.stringify(selected_aliases), "active": "0" },
url: '/api/v1/edit/alias/post',
jsonp: false,
complete: function (data) {
location.reload();
}
});
}
});
$("#delete_selected_alias").click(function(e) {
e.preventDefault();
if (Object.keys(selected_aliases).length !== 0) {
$.ajax({
type: "POST",
dataType: "json",
data: { "address": JSON.stringify(selected_aliases) },
url: '/api/v1/delete/alias/post',
jsonp: false,
complete: function (data) {
location.reload();
}
});
}
});
$("tr").on('click',function(e) {
if (e.target.type == "checkbox") {
e.stopPropagation();
} else {
var $checkbox = $(this).find(':checkbox');
var checkbox = $(this).find(':checkbox');
checkbox.trigger('click');
}
}); });
}); });
$(document).on('click', '#select_all_aliases', function(e) {
e.preventDefault();
var alias_chkbxs = $("input[name=sel_aliases]:visible");
alias_chkbxs.prop("checked", !alias_chkbxs.prop("checked")).change();
});
$(document).on('click', '#activate_selected_alias', function(e) {
e.preventDefault();
if (Object.keys(selected_aliases).length !== 0) {
$.ajax({
type: "POST",
dataType: "json",
data: { "address": JSON.stringify(selected_aliases), "active": "1" },
url: '/api/v1/edit/alias/post',
jsonp: false,
complete: function (data) {
location.reload();
}
});
}
});
$(document).on('click', '#deactivate_selected_alias', function(e) {
e.preventDefault();
if (Object.keys(selected_aliases).length !== 0) {
$.ajax({
type: "POST",
dataType: "json",
data: { "address": JSON.stringify(selected_aliases), "active": "0" },
url: '/api/v1/edit/alias/post',
jsonp: false,
complete: function (data) {
location.reload();
}
});
}
});
$(document).on('click', '#delete_selected_alias', function(e) {
e.preventDefault();
if (Object.keys(selected_aliases).length !== 0) {
$.ajax({
type: "POST",
dataType: "json",
data: { "address": JSON.stringify(selected_aliases) },
url: '/api/v1/delete/alias/post',
jsonp: false,
complete: function (data) {
location.reload();
}
});
}
});
} }
}); });
}); });