Skip to content

Commit

Permalink
Merge branch 'development' into 4129-new-findaproject-performance
Browse files Browse the repository at this point in the history
  • Loading branch information
WillNigel23 committed Nov 18, 2024
2 parents cdc3fae + 7213f0d commit 57ba7af
Show file tree
Hide file tree
Showing 169 changed files with 7,538 additions and 270,049 deletions.
14 changes: 7 additions & 7 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ GEM
method_source (1.1.0)
mini_magick (4.12.0)
mini_mime (1.1.5)
mini_portile2 (2.8.6)
mini_portile2 (2.8.7)
minitest (5.22.3)
msgpack (1.7.2)
multi_json (1.15.0)
Expand All @@ -367,7 +367,7 @@ GEM
net-smtp (0.5.0)
net-protocol
net-ssh (7.2.3)
newrelic_rpm (9.9.0)
newrelic_rpm (9.13.0)
nio4r (2.7.1)
nokogiri (1.15.6)
mini_portile2 (~> 2.8.2)
Expand Down Expand Up @@ -396,9 +396,9 @@ GEM
omniauth-oauth2 (1.7.3)
oauth2 (>= 1.4, < 3)
omniauth (>= 1.9, < 3)
omniauth-saml (1.10.3)
omniauth-saml (1.10.5)
omniauth (~> 1.3, >= 1.3.2)
ruby-saml (~> 1.9)
ruby-saml (~> 1.17)
onebox (2.2.19)
addressable (~> 2.8.0)
htmlentities (~> 4.3)
Expand Down Expand Up @@ -431,7 +431,7 @@ GEM
nio4r (~> 2.0)
pundit (2.3.1)
activesupport (>= 3.0.0)
racc (1.7.3)
racc (1.8.1)
rack (2.2.9)
rack-attack (6.7.0)
rack (>= 1.0, < 4)
Expand Down Expand Up @@ -493,7 +493,7 @@ GEM
responders (3.1.1)
actionpack (>= 5.2)
railties (>= 5.2)
rexml (3.2.6)
rexml (3.3.7)
rinku (2.0.6)
rmagick (5.5.0)
observer (~> 0.1)
Expand Down Expand Up @@ -522,7 +522,7 @@ GEM
event_stream_parser (>= 0.3.0, < 2.0.0)
faraday (>= 1)
faraday-multipart (>= 1)
ruby-saml (1.16.0)
ruby-saml (1.17.0)
nokogiri (>= 1.13.10)
rexml
ruby-vips (2.2.1)
Expand Down
8 changes: 8 additions & 0 deletions app/assets/images/symbols.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,9 @@ $(function() {

$('[data-select-all]').selectAll();

// Filterable table
$('[data-filterable-table]').filterableTable();

// Category tree expand/collapse
$('.tree-bullet').on('click', function(e) {
e.preventDefault();
Expand Down
69 changes: 69 additions & 0 deletions app/assets/javascripts/plugins/filterable-table.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* Author: willnigeldejesus@gmail.com
* Date: 22th Oct 2024
*/

(function($) {

$.fn.filterableTable = function(options) {

const selector = this.attr('data-filterable-table-selector');

const $form = this;
const $table = this.find(`#${selector}`);

$form.on('keydown', 'input', function(event) {
if (event.key === 'Enter') {
event.preventDefault();
$(this).trigger('change');
}
});

$form.on('change', function() {
$('html').addClass('page-busy');

const formData = $form.serialize();
const queryParams = new URLSearchParams(formData).toString();
const newUrl = `${window.location.pathname}?${queryParams}`;
history.pushState(null, '', newUrl);

$.ajax({
url: $form.attr('action'),
method: $form.attr('method'),
data: formData,
success: function(response) {
$table.html(response)
bindSortingClickEvent($table, $form);
$table.find('.dataTables_empty').attr('colspan', $table.find('th').length);
$table.find('.dataTables_empty').css('display', '');

$('html').removeClass('page-busy');
},
error: function(jqXHR, textStatus, errorThrown) {
console.error('Error:', textStatus, errorThrown);

$('html').removeClass('page-busy');
}
});
});

bindSortingClickEvent($table, $form);
$table.find('.dataTables_empty').attr('colspan', $table.find('th').length);
$table.find('.dataTables_empty').css('display', '');

function bindSortingClickEvent($table, $form) {
$table.off('click', '.sorting');
$table.on('click', '.sorting', function(event) {
const $sortElement = $(this);
const sortParam = $sortElement.attr('data-sort');
const order = $sortElement.hasClass('sorting_asc') ? 'desc' : 'asc';

$form.find('#sort').val(sortParam);
$form.find('#order').val(order);

$form.trigger('change');
});
}
}

})(jQuery);
Loading

0 comments on commit 57ba7af

Please sign in to comment.