primary offering filter updated
This commit is contained in:
@@ -13,7 +13,7 @@ class HandpickedInvestmentController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
|
||||
|
||||
$urlCategories = $this->decode_arr(request()->categories) ?? null;
|
||||
$assetType = request()->assetType ?? null;
|
||||
$geographicFocus = request()->geographicFocus ?? null;
|
||||
@@ -32,11 +32,11 @@ class HandpickedInvestmentController extends Controller
|
||||
|
||||
function fetchData(Request $request)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
if ($request->ajax()) {
|
||||
$products = $this->filterData($request->get('query'), $request->get('categories'), $request->get('assetType'), $request->get('geographicFocus'));
|
||||
|
||||
|
||||
// $productsWithCategories = $this->filterData($request->get('query'), $request->get('categories'), $request->get('assetType'), $request->get('geographicFocus'));
|
||||
return view('Frontend.Pages.handpicked-investment.pagination', compact('products'))->render();
|
||||
}
|
||||
@@ -44,7 +44,7 @@ class HandpickedInvestmentController extends Controller
|
||||
|
||||
public function filterData($query, $categories, $assetType, $geographicFocus)
|
||||
{
|
||||
// dd($query,$categories,$assetType,$geographicFocus);
|
||||
// dd($query, $categories, $assetType, $geographicFocus);
|
||||
if (!is_array($categories) && $categories)
|
||||
$categories = explode(',', $categories);
|
||||
$faCategoriesArr = [
|
||||
@@ -112,7 +112,7 @@ class HandpickedInvestmentController extends Controller
|
||||
$query->where('categories.status', true);
|
||||
})
|
||||
->paginate(6);
|
||||
// dd($categories);
|
||||
// dd($query, $categories);
|
||||
$products->appends(['search' => $query, 'categories' => $this->encode_arr($categories)]);
|
||||
|
||||
return $products->withPath('/primary-investment');
|
||||
|
||||
@@ -69,6 +69,7 @@
|
||||
<script>
|
||||
var firstTime = true;
|
||||
$(document).ready(function() {
|
||||
$(`#financial-assets`).addClass('active');
|
||||
listCategories();
|
||||
// $('.category-checkbox').on('click', filter);
|
||||
});
|
||||
@@ -76,22 +77,39 @@
|
||||
// $('.category-checkbox').click(filter);
|
||||
// });
|
||||
|
||||
// Call listCategories function when Asset type or Geographic Focus changes
|
||||
$('#financial-assets, #real-assets, #india, #global').on('click', function() {
|
||||
listCategories();
|
||||
});
|
||||
|
||||
|
||||
function listCategories() {
|
||||
// alert(firstTime);
|
||||
// Clear the existing content only if no checkbox is selected
|
||||
if ($("input[type='checkbox'][name='categories']:checked").length === 0) {
|
||||
$('#categories_list').empty();
|
||||
}
|
||||
|
||||
// Append new checkboxes if no checkbox is selected or it's the first time
|
||||
if (firstTime || true) {
|
||||
if ($('#financial-assets , #real-assets').hasClass('active') || $('#india , #global').hasClass(
|
||||
'active') || firstTime) {
|
||||
// alert('hello');
|
||||
if (!$('input[type=checkbox]').is(':checked') || $('#financial-assets , #real-assets')
|
||||
// if ($('#financial-assets , #real-assets')
|
||||
.hasClass('active') || $('#india , #global').hasClass(
|
||||
'active')) {
|
||||
|
||||
$('#categories_list').html('').html($('#categories_new_list').html());
|
||||
if ($('#financial-assets, #real-assets').hasClass('active') || $('#india, #global').hasClass('active') ||
|
||||
firstTime) {
|
||||
if (!$('input[type=checkbox]').is(':checked') || $('#financial-assets, #real-assets').hasClass(
|
||||
'active') || $('#india, #global').hasClass('active')) {
|
||||
// Append only unchecked checkboxes
|
||||
$('#categories_new_list .inp-oppt').each(function() {
|
||||
var checkboxValue = $(this).find("input[type='checkbox']").val();
|
||||
if (!$('#categories_list').find("input[type='checkbox'][value='" + checkboxValue + "']")
|
||||
.length) {
|
||||
$('#categories_list').append($(this).clone());
|
||||
}
|
||||
});
|
||||
|
||||
firstTime = false;
|
||||
}
|
||||
// $('#categories_list').html('').html($('#categories_new_list').html());
|
||||
}
|
||||
} else {
|
||||
// Uncheck selected category checkboxes when changing Asset type or Geographic Focus
|
||||
$('#categories_list input[type="checkbox"]').prop('checked', false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,6 +118,8 @@
|
||||
// $('#categories_list').html('').html($('#categories_new_list').html());
|
||||
// $('#categories_list').addClass('d-none');
|
||||
|
||||
$('#categories_list input[type="checkbox"]').prop('checked', false);
|
||||
|
||||
listCategories();
|
||||
if (id == 'financial-assets' || id == 'real-assets') {
|
||||
$(`#financial-assets , #real-assets`).removeClass('active');
|
||||
@@ -113,7 +133,7 @@
|
||||
|
||||
$(`#${id}`).addClass('active');
|
||||
|
||||
console.log("parent filter called");
|
||||
// console.log("parent filter called");
|
||||
})
|
||||
|
||||
$(function() {
|
||||
@@ -126,7 +146,7 @@
|
||||
function fetch_data(page, query, categories, assetType, geographicFocus) {
|
||||
$.ajax({
|
||||
type: 'get',
|
||||
url: "http://localhost/my-freeu/primary-investment/fetch_data?page=" +
|
||||
url: "/primary-investment/fetch_data?page=" +
|
||||
page +
|
||||
"&query=" + query + "&categories=" + categories + "&assetType=" +
|
||||
assetType +
|
||||
@@ -141,7 +161,8 @@
|
||||
}
|
||||
|
||||
$('#serach').on('keyup', filter);
|
||||
$('.category-checkbox').on('click', filter);
|
||||
// $('.category-checkbox').on('click', filter);
|
||||
$(document.body).on('click', '.category-checkbox', filter);
|
||||
|
||||
function filter() {
|
||||
|
||||
@@ -160,54 +181,5 @@
|
||||
fetch_data(page, query = '', categories, assetType, geographicFocus);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
function fetch_dataNew(page, query, categories, assetType, geographicFocus) {
|
||||
$.ajax({
|
||||
type: 'get',
|
||||
url: "http://localhost/my-freeu/primary-investment/fetch_data?page=" +
|
||||
page +
|
||||
"&query=" + query + "&categories=" + categories + "&assetType=" +
|
||||
assetType +
|
||||
"&geographicFocus=" + geographicFocus,
|
||||
success: function(data) {
|
||||
// console.log(data);
|
||||
// $('.pagination').html('');
|
||||
$('.display-products').html('').html(data);
|
||||
listCategories();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function hello(id) {
|
||||
var categories = [];
|
||||
|
||||
console.log("hello called");
|
||||
// Iterate over each checked checkbox and store their IDs in the categories array
|
||||
$("input:checkbox[name=categories]:checked").each(function() {
|
||||
categories.push($(this).val());
|
||||
});
|
||||
|
||||
console.log("categories", categories);
|
||||
|
||||
|
||||
var page = $('#hidden_page').val();
|
||||
var assetType = $('#asset_type').val();
|
||||
var geographicFocus = $('#geographic_focus').val();
|
||||
// listCategories();
|
||||
fetch_dataNew(page, '', [categories], assetType, geographicFocus);
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
$(".clear").click(function() {
|
||||
$('input[type=checkbox]').prop('checked', false);
|
||||
location.reload();
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
// $('.checkbox-effect').click(function() {
|
||||
// alert('hello');
|
||||
// });
|
||||
</script>
|
||||
@endsection
|
||||
|
||||
@@ -6,13 +6,13 @@
|
||||
</div> --}}
|
||||
@if(!in_array($product->category_id,$category))
|
||||
<div class="inp-oppt">
|
||||
{{-- <input class="category-checkbox checkbox-effect checkbox-effect-1" id="product{{ $product->category_id }}"
|
||||
type="checkbox" value="{{ $product->category_id }}" name="categories" {{ $checked ?? '' }}/> --}}
|
||||
|
||||
<input class="checkbox-effect checkbox-effect-1" id="product{{ $product->category_id }}"
|
||||
type="checkbox" value="{{ $product->category_id }}" name="categories"
|
||||
{{ $checked ?? '' }} onclick="hello(this)" />
|
||||
<input class="category-checkbox checkbox-effect checkbox-effect-1" id="product{{ $product->category_id }}"
|
||||
type="checkbox" value="{{ $product->category_id }}" name="categories" {{ $checked ?? '' }}/>
|
||||
<label for="product{{ $product->category_id }}">{{ $product->category_name }}</label><br>
|
||||
|
||||
{{-- <input class="checkbox-effect checkbox-effect-1" id="product{{ $product->category_id }}"
|
||||
type="checkbox" value="{{ $product->category_id }}" name="categories"
|
||||
{{ $checked ?? '' }} onclick="hello(this)" /> --}}
|
||||
</div>
|
||||
@php(array_push($category,$product->category_id))
|
||||
@endif
|
||||
|
||||
Reference in New Issue
Block a user