forked from External/greenlight
Add paging to Recordings Table (GRN2-26) (#512)
* Add translations for the validation messages * Add translations for next/prev button * Add paging to recordings * sync * Fix line endings
This commit is contained in:
committed by
Jesus Federico
parent
d8f6c3f872
commit
23abdb52ee
@ -41,32 +41,6 @@ $(document).on('turbolinks:load', function(){
|
||||
location.reload()
|
||||
});
|
||||
});
|
||||
|
||||
// Submit search if the user hits enter
|
||||
$("#search-input").keypress(function(key) {
|
||||
var keyPressed = key.which
|
||||
if (keyPressed == 13) {
|
||||
searchPage()
|
||||
}
|
||||
})
|
||||
|
||||
// Add listeners for sort
|
||||
$("th[data-order]").click(function(data){
|
||||
var header_elem = $(data.target)
|
||||
|
||||
if(header_elem.data('order') === 'asc'){ // asc
|
||||
header_elem.data('order', 'desc');
|
||||
}
|
||||
else if(header_elem.data('order') === 'desc'){ // desc
|
||||
header_elem.data('order', 'none');
|
||||
}
|
||||
else{ // none
|
||||
header_elem.data('order', 'asc');
|
||||
}
|
||||
|
||||
var search = $("#search-input").val()
|
||||
window.location.replace(window.location.pathname + "?page=1&search=" + search + "&column=" + header_elem.data("header") + "&direction="+ header_elem.data('order'))
|
||||
})
|
||||
}
|
||||
|
||||
// Only run on the admins edit user page.
|
||||
@ -76,8 +50,8 @@ $(document).on('turbolinks:load', function(){
|
||||
if (!url.endsWith("/")) {
|
||||
url += "/"
|
||||
}
|
||||
|
||||
url += "admins?setting=" + data.target.id
|
||||
|
||||
window.location.href = url
|
||||
})
|
||||
}
|
||||
@ -88,15 +62,3 @@ function changeBrandingImage(path) {
|
||||
var url = $("#branding-url").val()
|
||||
$.post(path, {url: url})
|
||||
}
|
||||
|
||||
// Searches the user table for the given string
|
||||
function searchPage() {
|
||||
var search = $("#search-input").val()
|
||||
|
||||
window.location.replace(window.location.pathname + "?page=1&search=" + search)
|
||||
}
|
||||
|
||||
// Clears the search bar
|
||||
function clearSearch() {
|
||||
window.location.replace(window.location.pathname + "?page=1")
|
||||
}
|
||||
|
@ -18,36 +18,81 @@ $(document).on('turbolinks:load', function(){
|
||||
var controller = $("body").data('controller');
|
||||
var action = $("body").data('action');
|
||||
|
||||
if(controller == "rooms" && action == "show" || controller == "rooms" && action == "update"){
|
||||
var search_input = $('#search_bar');
|
||||
if ((controller == "admins" && action == "index") ||
|
||||
(controller == "rooms" && action == "show") ||
|
||||
(controller == "rooms" && action == "update") ||
|
||||
(controller == "rooms" && action == "join") ||
|
||||
(controller == "users" && action == "recordings")) {
|
||||
// Submit search if the user hits enter
|
||||
$("#search-input").keypress(function(key) {
|
||||
var keyPressed = key.which
|
||||
if (keyPressed == 13) {
|
||||
searchPage()
|
||||
}
|
||||
})
|
||||
|
||||
search_input.bind("keyup", function(){
|
||||
// Add listeners for sort
|
||||
$("th[data-order]").click(function(data){
|
||||
var header_elem = $(data.target)
|
||||
var controller = $("body").data('controller');
|
||||
var action = $("body").data('action');
|
||||
|
||||
// Retrieve the current search query
|
||||
var search_query = search_input.find(".form-control").val();
|
||||
if(header_elem.data('order') === 'asc'){ // asc
|
||||
header_elem.data('order', 'desc');
|
||||
}
|
||||
else if(header_elem.data('order') === 'desc'){ // desc
|
||||
header_elem.data('order', 'none');
|
||||
}
|
||||
else{ // none
|
||||
header_elem.data('order', 'asc');
|
||||
}
|
||||
|
||||
//Search for recordings and display them based on name match
|
||||
var recordings_found = 0;
|
||||
var search = $("#search-input").val();
|
||||
|
||||
var recordings = $('#recording-table').find('tr');
|
||||
|
||||
recordings.each(function(){
|
||||
if($(this).find('text').text().toLowerCase().includes(search_query.toLowerCase())){
|
||||
recordings_found = recordings_found + 1;
|
||||
$(this).show();
|
||||
}
|
||||
else{
|
||||
$(this).hide();
|
||||
}
|
||||
});
|
||||
|
||||
// Show "No recordings match your search" if no recordings found
|
||||
if(recordings_found === 0){
|
||||
$('#no_recordings_found').show();
|
||||
if(controller === "rooms" && action === "show"){
|
||||
window.location.replace(window.location.pathname + "?page=1&search=" + search +
|
||||
"&column=" + header_elem.data("header") + "&direction="+ header_elem.data('order') +
|
||||
"#recordings-table");
|
||||
}
|
||||
else{
|
||||
$('#no_recordings_found').hide();
|
||||
window.location.replace(window.location.pathname + "?page=1&search=" + search +
|
||||
"&column=" + header_elem.data("header") + "&direction="+ header_elem.data('order'));
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
if(controller === "rooms" && action === "show"){
|
||||
$(".page-item > a").each(function(){
|
||||
if(!$(this).attr('href').endsWith("#")){
|
||||
$(this).attr('href', $(this).attr('href') + "#recordings-table")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
// Searches the user table for the given string
|
||||
function searchPage() {
|
||||
var search = $("#search-input").val();
|
||||
|
||||
var controller = $("body").data('controller');
|
||||
var action = $("body").data('action');
|
||||
|
||||
if(controller === "rooms" && action === "show"){
|
||||
window.location.replace(window.location.pathname + "?page=1&search=" + search + "#recordings-table");
|
||||
} else{
|
||||
window.location.replace(window.location.pathname + "?page=1&search=" + search);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Clears the search bar
|
||||
function clearSearch() {
|
||||
var controller = $("body").data('controller');
|
||||
var action = $("body").data('action');
|
||||
|
||||
if(controller === "rooms" && action === "show"){
|
||||
window.location.replace(window.location.pathname + "?page=1" + "#recordings-table");
|
||||
} else{
|
||||
window.location.replace(window.location.pathname + "?page=1");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user