Skip to content

Commit

Permalink
FIX: Url filtering issue in block listing
Browse files Browse the repository at this point in the history
  • Loading branch information
nithinjohn22 committed Dec 26, 2024
1 parent d038428 commit ab1e440
Show file tree
Hide file tree
Showing 7 changed files with 2,130 additions and 16 deletions.
887 changes: 886 additions & 1 deletion blocks/build/index-rtl.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion blocks/build/index.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-server-side-render'), 'version' => '578da28cf0a1eeb580d5');
<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-server-side-render'), 'version' => '433675ab56dc3fb8c616');
774 changes: 773 additions & 1 deletion blocks/build/style-index-rtl.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion blocks/build/view.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array(), 'version' => '6de16102ce61bdc5fdfe');
<?php return array('dependencies' => array(), 'version' => 'a75d07c7a107b68260a6');
443 changes: 442 additions & 1 deletion blocks/build/view.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions blocks/build/view.js.map

Large diffs are not rendered by default.

37 changes: 26 additions & 11 deletions blocks/src/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,24 @@ jQuery(function($) {
var hide_expired_jobs = $wrapper.data('awsm-hide-expired-jobs');
var other_options = $wrapper.data('awsm-other-options');
/* end */

$rootWrapper.find('.awsm-b-filter-item').each(function() {
var currentLoopSpec = $(this).data('filter');
console.log($(this).data('filter'));

var searchParams = new URLSearchParams(document.location.search);
var currentSpecQueryVal = searchParams.get(currentLoopSpec);
var $currentOption = $(this).find('.awsm-b-filter-option');

if ($currentOption.val().length === 0 && currentSpecQueryVal && currentSpecQueryVal.length > 0) {
formData.forEach(function(item) {
if (item.name === $currentOption.attr('name')) {
item.value = '-1';
}
});
}
});

formData.push({
name: 'listings_per_page',
value: listings
Expand Down Expand Up @@ -151,17 +169,6 @@ jQuery(function($) {
awsmJobFilters($rootWrapper);
}

if ($(rootWrapperSelector).length > 0) {
$(rootWrapperSelector).each(function() {
var $currentWrapper = $(this);
var $filterForm = $currentWrapper.find(filterSelector + ' form');
if (awsmJobsPublic.is_search.length > 0 || filterCheck($filterForm)) {
triggerFilter = true;
awsmJobFilters($currentWrapper);
}
});
}

var updateQuery = function(key, value, url) {
url = typeof url !== 'undefined' ? url : currentUrl;
url = url.split('?')[0];
Expand Down Expand Up @@ -200,13 +207,21 @@ jQuery(function($) {
}
};

if ($('.awsm-job-no-more-jobs-get').length > 0) {
$('.awsm-b-job-listings').hide();
$('.awsm-job-no-more-jobs-get').slice(1).hide();
}

$(filterSelector + ' .awsm-b-filter-option').on('change', function(e) {
e.preventDefault();
var $elem = $(this);
var $selected = $elem.find('option:selected');
var $rootWrapper = $elem.parents(rootWrapperSelector);
var currentSpec = $elem.parents('.awsm-b-filter-item').data('filter');
var slug = $selected.data('slug');
if ($('.awsm-b-job-listings').length > 0) {
$rootWrapper.find('.awsm-job-no-more-jobs-get').hide();
}
slug = typeof slug !== 'undefined' ? slug : '';
setPaginationBase($rootWrapper, currentSpec, slug);
if (awsmJobsPublic.deep_linking.spec) {
Expand Down

0 comments on commit ab1e440

Please sign in to comment.