making and removing of filter tags is now working
This commit is contained in:
parent
8c1f72a9a1
commit
efa1e8b716
|
|
@ -138,33 +138,38 @@ class DataGridController extends Controller
|
||||||
'filterable' => [
|
'filterable' => [
|
||||||
[
|
[
|
||||||
'column' => 'a.id',
|
'column' => 'a.id',
|
||||||
'type' => 'integer'
|
'type' => 'integer',
|
||||||
|
'label' => 'Admin ID'
|
||||||
], [
|
], [
|
||||||
'column' => 'a.email',
|
'column' => 'a.email',
|
||||||
'type' => 'string'
|
'type' => 'string',
|
||||||
|
'label' => 'Admin E-Mail',
|
||||||
], [
|
], [
|
||||||
'column' => 'a.first_name',
|
'column' => 'a.first_name',
|
||||||
'type' => 'string'
|
'type' => 'string',
|
||||||
|
'label' => 'Admin Name',
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
'searchables' =>[
|
'searchables' =>[
|
||||||
[
|
[
|
||||||
'name' => 'a.id',
|
'name' => 'a.id',
|
||||||
'label' => 'ID'
|
'label' => 'ID',
|
||||||
|
'label' => 'Admin ID',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'name' => 'a.name',
|
'name' => 'a.name',
|
||||||
'label' => 'Name'
|
'label' => 'Name',
|
||||||
|
'label' => 'Admin Name',
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
'join' => [
|
'join' => [
|
||||||
[
|
// [
|
||||||
'join' => 'leftjoin',
|
// 'join' => 'leftjoin',
|
||||||
'table' => 'posts as p',
|
// 'table' => 'posts as p',
|
||||||
'primaryKey' => 'a.id',
|
// 'primaryKey' => 'a.id',
|
||||||
'condition' => '=',
|
// 'condition' => '=',
|
||||||
'secondaryKey' => 'p.author_id',
|
// 'secondaryKey' => 'p.author_id',
|
||||||
]
|
// ]
|
||||||
],
|
],
|
||||||
'columns' => [
|
'columns' => [
|
||||||
[
|
[
|
||||||
|
|
@ -181,13 +186,13 @@ class DataGridController extends Controller
|
||||||
'sortable' => true,
|
'sortable' => true,
|
||||||
'filterable' => true
|
'filterable' => true
|
||||||
],
|
],
|
||||||
[
|
// [
|
||||||
'name' => 'p.content',
|
// 'name' => 'p.content as pp',
|
||||||
'type' => 'string',
|
// 'type' => 'string',
|
||||||
'label' => 'Content',
|
// 'label' => 'Content',
|
||||||
'sortable' => true,
|
// 'sortable' => true,
|
||||||
'filterable' => false,
|
// 'filterable' => false,
|
||||||
],
|
// ],
|
||||||
[
|
[
|
||||||
'name' => 'a.first_name',
|
'name' => 'a.first_name',
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@
|
||||||
<select class="control filter-condition-select-string">
|
<select class="control filter-condition-select-string">
|
||||||
<option selected disabled>Select Condition</option>
|
<option selected disabled>Select Condition</option>
|
||||||
<option value="like">Contains</option>
|
<option value="like">Contains</option>
|
||||||
<option value="not like">Does not contains</option>
|
<option value="nlike">Does not contains</option>
|
||||||
<option value="eq">Is equal to</option>
|
<option value="eq">Is equal to</option>
|
||||||
<option value="neqs">Is not equal to</option>
|
<option value="neqs">Is not equal to</option>
|
||||||
</select>
|
</select>
|
||||||
|
|
@ -159,294 +159,301 @@
|
||||||
</div>
|
</div>
|
||||||
@section('javascript')
|
@section('javascript')
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
// var allFilters = [];
|
var allFilters1 = [];
|
||||||
var allFilters1 = [];
|
var filter_value;
|
||||||
var filter_value;
|
var filter_column;
|
||||||
var filter_column;
|
var filter_condition;
|
||||||
var filter_condition;
|
var filter_range;
|
||||||
var filter_range;
|
var filt = '';
|
||||||
var filt = '';
|
var count_filters = parseInt(0);
|
||||||
var count_filters = parseInt(0);
|
var url;
|
||||||
var url;
|
var array_start = '[';
|
||||||
var array_start = '[';
|
var array_end = ']';
|
||||||
var array_end = ']';
|
var typeValue;
|
||||||
var typeValue;
|
var selectedColumn = '';
|
||||||
var selectedColumn = '';
|
var myURL = document.location;
|
||||||
var myURL = document.location;
|
let params;
|
||||||
let params;
|
$(document).ready(function(){
|
||||||
$(document).ready(function(){
|
|
||||||
|
|
||||||
params = (new URL(document.location)).search;
|
params = (new URL(document.location)).search;
|
||||||
|
|
||||||
if(params.length>0){
|
if(params.length>0){
|
||||||
// makeFilterTags(params);
|
if(allFilters1.length == 0){
|
||||||
console.log(params.slice(1,params.length));
|
//call reverse url function
|
||||||
if(allFilters1.length == 0){
|
arrayFromUrl(params.slice(1,params.length));
|
||||||
//call reverse url function
|
|
||||||
arrayFromUrl(params.slice(1,params.length));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$('.search-btn').click(function(){
|
|
||||||
filter_value = $(".search-field").val();
|
|
||||||
});
|
|
||||||
$('.grid_head').on('click', function(){
|
|
||||||
|
|
||||||
var column = $(this).data('column-name');
|
|
||||||
var currentSort = $(this).data('column-sort');
|
|
||||||
|
|
||||||
if(currentSort == "asc"){
|
|
||||||
formURL(column,'sort','desc',params);
|
|
||||||
}else{
|
|
||||||
formURL(column,'sort','asc',params);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
$('select.filter-column-select').change(function() {
|
|
||||||
typeValue = $('select.filter-column-select').find(':selected').data('type');
|
|
||||||
selectedColumn = $('select.filter-column-select').find(':selected').val();
|
|
||||||
if(typeValue == 'string'){
|
|
||||||
//default behaviour for strings
|
|
||||||
$('.filter-condition-dropdown-number').css('display','none');
|
|
||||||
$('.filter-condition-dropdown-datetime').css('display','none');
|
|
||||||
$('.filter-response-number').css('display','none');
|
|
||||||
$('.filter-response-datetime').css('display','none');
|
|
||||||
$('.filter-response-boolean').css('display','none');
|
|
||||||
|
|
||||||
//show the two wanted
|
|
||||||
$('.filter-condition-dropdown-string').css('display','inherit');
|
|
||||||
$('.filter-response-string').css('display','inherit');
|
|
||||||
}
|
|
||||||
else if(typeValue == 'boolean'){
|
|
||||||
//hide unwanted
|
|
||||||
$('.filter-condition-dropdown-string').css('display','none');
|
|
||||||
$('.filter-condition-dropdown-number').css('display','none');
|
|
||||||
$('.filter-condition-dropdown-datetime').css('display','none');
|
|
||||||
$('.filter-response-string').css('display','none');
|
|
||||||
$('.filter-response-number').css('display','none');
|
|
||||||
$('.filter-response-datetime').css('display','none');
|
|
||||||
|
|
||||||
//only true or false for that column is needed as input
|
|
||||||
$('.filter-response-boolean').css('display','inherit');
|
|
||||||
}
|
|
||||||
else if(typeValue == 'datetime'){
|
|
||||||
//hide unwanted
|
|
||||||
$('.filter-condition-dropdown-string').css('display','none');
|
|
||||||
$('.filter-condition-dropdown-number').css('display','none');
|
|
||||||
$('.filter-response-string').css('display','none');
|
|
||||||
$('.filter-response-number').css('display','none');
|
|
||||||
$('.filter-response-boolean').css('display','none');
|
|
||||||
|
|
||||||
//show what is wanted
|
|
||||||
$('.filter-condition-dropdown-datetime').css('display','inherit');
|
|
||||||
$('.filter-response-datetime').css('display','inherit');
|
|
||||||
}
|
|
||||||
else if(typeValue == 'number'){
|
|
||||||
//hide unwanted
|
|
||||||
$('.filter-condition-dropdown-string').css('display','none');
|
|
||||||
$('.filter-condition-dropdown-datetime').css('display','none');
|
|
||||||
$('.filter-response-string').css('display','none');
|
|
||||||
$('.filter-response-datetime').css('display','none');
|
|
||||||
$('.filter-response-boolean').css('display','none');
|
|
||||||
|
|
||||||
//show what is wanted
|
|
||||||
$('.filter-condition-dropdown-number').css('display','inherit');
|
|
||||||
$('.filter-response-number').css('display','inherit');
|
|
||||||
|
|
||||||
}
|
|
||||||
$('.apply-filter').on('click',function(){
|
|
||||||
|
|
||||||
params = (new URL(document.location)).search;
|
|
||||||
if(typeValue == 'number'){
|
|
||||||
var conditionUsed = $('.filter-condition-dropdown-number').find(':selected').val();
|
|
||||||
var response = $('.response-number').val();
|
|
||||||
formURL(selectedColumn,conditionUsed,response,params);
|
|
||||||
}
|
}
|
||||||
if(typeValue == 'string'){
|
}
|
||||||
var conditionUsed = $('.filter-condition-dropdown-string').find(':selected').val();
|
$('.search-btn').click(function(){
|
||||||
var response = $('.response-string').val();
|
filter_value = $(".search-field").val();
|
||||||
formURL(selectedColumn,conditionUsed,response,params);
|
});
|
||||||
|
$('.grid_head').on('click', function(){
|
||||||
|
|
||||||
}
|
var column = $(this).data('column-name');
|
||||||
if(typeValue == 'datetime'){
|
var currentSort = $(this).data('column-sort');
|
||||||
var conditionUsed = $('.filter-condition-dropdown-datetime').find(':selected').val();
|
|
||||||
var response = $('.response-datetime').val();
|
if(currentSort == "asc"){
|
||||||
formURL(selectedColumn,conditionUsed,response,params);
|
formURL(column,'sort','desc',params);
|
||||||
}
|
}else{
|
||||||
if(typeValue == 'boolean'){
|
formURL(column,'sort','asc',params);
|
||||||
console.log('boolean');
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
$('select.filter-column-select').change(function() {
|
||||||
});
|
typeValue = $('select.filter-column-select').find(':selected').data('type');
|
||||||
|
selectedColumn = $('select.filter-column-select').find(':selected').val();
|
||||||
|
if(typeValue == 'string') {
|
||||||
|
//default behaviour for strings
|
||||||
|
$('.filter-condition-dropdown-number').css('display','none');
|
||||||
|
$('.filter-condition-dropdown-datetime').css('display','none');
|
||||||
|
$('.filter-response-number').css('display','none');
|
||||||
|
$('.filter-response-datetime').css('display','none');
|
||||||
|
$('.filter-response-boolean').css('display','none');
|
||||||
|
|
||||||
//function to parse the allfilters array for creating the filter tags
|
//show the two wanted
|
||||||
//and parse the saved filters and resume the state of the grid
|
$('.filter-condition-dropdown-string').css('display','inherit');
|
||||||
|
$('.filter-response-string').css('display','inherit');
|
||||||
function makeFilterTags(taggedFilters) {
|
|
||||||
console.log("from make tags",taggedFilters);
|
|
||||||
}
|
|
||||||
|
|
||||||
//this function is only to barrayFromUrle used when there is search param and the allFilter is empty in order to repopulate
|
|
||||||
// and make the filter or sort tags again
|
|
||||||
function arrayFromUrl(x){
|
|
||||||
console.log(allFilters1);
|
|
||||||
console.log(x);
|
|
||||||
t = x.slice(1,x.length);
|
|
||||||
splitted = [];
|
|
||||||
moreSplitted = [];
|
|
||||||
splitted = t.split('&');
|
|
||||||
for(i=0;i<splitted.length;i++){
|
|
||||||
moreSplitted.push(splitted[i].split('='));
|
|
||||||
}
|
|
||||||
for(i=0;i<moreSplitted.length;i++){
|
|
||||||
temp = moreSplitted[i];
|
|
||||||
// console.log(moreSplitted[i][2]); //use this for response
|
|
||||||
var pos1 = temp[1].indexOf("[");
|
|
||||||
var pos2 = temp[1].indexOf("]");
|
|
||||||
column_name = temp[1].slice(0,pos1);
|
|
||||||
condition_name = temp[1].slice(pos1+1,pos2);
|
|
||||||
// console.log(column_name.trim(),"and",condition_name.trim()); // we got the column name and condition
|
|
||||||
// console.log('column =', column_name.trim());
|
|
||||||
// console.log('condition =', condition_name.trim());
|
|
||||||
// console.log('filter value =', moreSplitted[i][2]);
|
|
||||||
var tmp = {};
|
|
||||||
tmp[column_name.trim()] ={
|
|
||||||
[condition_name.trim()]:moreSplitted[i][2]
|
|
||||||
};
|
|
||||||
allFilters1.push(tmp);
|
|
||||||
}
|
|
||||||
console.log('Array from URL = ',allFilters1);
|
|
||||||
makeTagsTestPrior();
|
|
||||||
}
|
|
||||||
|
|
||||||
function makeTagsTestPrior() {
|
|
||||||
var filterRepeat = 0;
|
|
||||||
//make sure the filter or sort param is not duplicate before pushing it into the all filters array
|
|
||||||
if(allFilters1.length!=0)
|
|
||||||
for(var i = 0;i<allFilters1.length;i++){
|
|
||||||
// console.log(allFilters1[i]);
|
|
||||||
for(j in allFilters1[i]){
|
|
||||||
// console.log(allFilters1[i][j],j);
|
|
||||||
for(k in allFilters1[i][j])
|
|
||||||
{
|
|
||||||
// console.log('column = ',j);
|
|
||||||
// console.log('condition = ',k);
|
|
||||||
// console.log('value = ',allFilters1[i][j][k]);
|
|
||||||
var filter_card = '<span class="filter-one"><span class="filter-name">'+ j +'</span><span class="filter-value">'+allFilters1[i][j][k] +'<span class="icon cross-icon"></span></span></span>';
|
|
||||||
$('.filter-row-two').append(filter_card);
|
|
||||||
}
|
}
|
||||||
|
else if(typeValue == 'boolean') {
|
||||||
|
//hide unwanted
|
||||||
|
$('.filter-condition-dropdown-string').css('display','none');
|
||||||
|
$('.filter-condition-dropdown-number').css('display','none');
|
||||||
|
$('.filter-condition-dropdown-datetime').css('display','none');
|
||||||
|
$('.filter-response-string').css('display','none');
|
||||||
|
$('.filter-response-number').css('display','none');
|
||||||
|
$('.filter-response-datetime').css('display','none');
|
||||||
|
|
||||||
|
//only true or false for that column is needed as input
|
||||||
|
$('.filter-response-boolean').css('display','inherit');
|
||||||
|
}
|
||||||
|
else if(typeValue == 'datetime') {
|
||||||
|
//hide unwanted
|
||||||
|
$('.filter-condition-dropdown-string').css('display','none');
|
||||||
|
$('.filter-condition-dropdown-number').css('display','none');
|
||||||
|
$('.filter-response-string').css('display','none');
|
||||||
|
$('.filter-response-number').css('display','none');
|
||||||
|
$('.filter-response-boolean').css('display','none');
|
||||||
|
|
||||||
|
//show what is wanted
|
||||||
|
$('.filter-condition-dropdown-datetime').css('display','inherit');
|
||||||
|
$('.filter-response-datetime').css('display','inherit');
|
||||||
|
}
|
||||||
|
else if(typeValue == 'number'){
|
||||||
|
//hide unwanted
|
||||||
|
$('.filter-condition-dropdown-string').css('display','none');
|
||||||
|
$('.filter-condition-dropdown-datetime').css('display','none');
|
||||||
|
$('.filter-response-string').css('display','none');
|
||||||
|
$('.filter-response-datetime').css('display','none');
|
||||||
|
$('.filter-response-boolean').css('display','none');
|
||||||
|
|
||||||
|
//show what is wanted
|
||||||
|
$('.filter-condition-dropdown-number').css('display','inherit');
|
||||||
|
$('.filter-response-number').css('display','inherit');
|
||||||
|
|
||||||
|
}
|
||||||
|
$('.apply-filter').on('click',function(){
|
||||||
|
|
||||||
|
params = (new URL(document.location)).search;
|
||||||
|
if(typeValue == 'number'){
|
||||||
|
var conditionUsed = $('.filter-condition-dropdown-number').find(':selected').val();
|
||||||
|
var response = $('.response-number').val();
|
||||||
|
formURL(selectedColumn,conditionUsed,response,params);
|
||||||
|
}
|
||||||
|
if(typeValue == 'string'){
|
||||||
|
var conditionUsed = $('.filter-condition-dropdown-string').find(':selected').val();
|
||||||
|
var response = $('.response-string').val();
|
||||||
|
formURL(selectedColumn,conditionUsed,response,params);
|
||||||
|
|
||||||
|
}
|
||||||
|
if(typeValue == 'datetime'){
|
||||||
|
var conditionUsed = $('.filter-condition-dropdown-datetime').find(':selected').val();
|
||||||
|
var response = $('.response-datetime').val();
|
||||||
|
formURL(selectedColumn,conditionUsed,response,params);
|
||||||
|
}
|
||||||
|
if(typeValue == 'boolean'){
|
||||||
|
console.log('boolean');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
$('.remove-filter').on('click', function(){
|
||||||
|
console.log('removing');
|
||||||
|
var id = $(this).parents('.filter-one').attr('id');
|
||||||
|
console.log(allFilters1.length);
|
||||||
|
|
||||||
|
if(allFilters1.length == 1){
|
||||||
|
allFilters1.pop();
|
||||||
|
var uri = window.location.href.toString();
|
||||||
|
if (uri.indexOf("?") > 0) {
|
||||||
|
var clean_uri = uri.substring(0, uri.indexOf("?"));
|
||||||
|
// window.history.replaceState({}, document.title, clean_uri);
|
||||||
|
document.location = clean_uri;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
allFilters1.splice(id,1);
|
||||||
|
makeURL(allFilters1);
|
||||||
|
}
|
||||||
|
console.log(allFilters1);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
//this function is only to barrayFromUrle used when there is search param and the allFilter is empty in order to repopulate
|
||||||
|
// and make the filter or sort tags again
|
||||||
|
function arrayFromUrl(x){
|
||||||
|
// console.log(allFilters1);
|
||||||
|
// console.log(x);
|
||||||
|
t = x.slice(1,x.length);
|
||||||
|
splitted = [];
|
||||||
|
moreSplitted = [];
|
||||||
|
splitted = t.split('&');
|
||||||
|
for(i=0;i<splitted.length;i++){
|
||||||
|
moreSplitted.push(splitted[i].split('='));
|
||||||
}
|
}
|
||||||
|
for(i=0;i<moreSplitted.length;i++){
|
||||||
|
temp = moreSplitted[i];
|
||||||
|
// console.log(moreSplitted[i][2]); //use this for response
|
||||||
|
var pos1 = temp[1].indexOf("[");
|
||||||
|
var pos2 = temp[1].indexOf("]");
|
||||||
|
column_name = temp[1].slice(0,pos1);
|
||||||
|
condition_name = temp[1].slice(pos1+1,pos2);
|
||||||
|
var tmp = {};
|
||||||
|
tmp[column_name.trim()] ={
|
||||||
|
[condition_name.trim()]:moreSplitted[i][2]
|
||||||
|
};
|
||||||
|
allFilters1.push(tmp);
|
||||||
|
}
|
||||||
|
console.log('Array from URL = ',allFilters1);
|
||||||
|
makeTagsTestPrior();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
function makeTagsTest(column, condition, response, urlparams) {
|
function makeTagsTestPrior() {
|
||||||
|
var filterRepeat = 0;
|
||||||
var tmp = {};
|
//make sure the filter or sort param is not duplicate before pushing it into the all filters array
|
||||||
tmp[column] ={
|
if(allFilters1.length!=0)
|
||||||
[condition]:response
|
for(var i = 0;i<allFilters1.length;i++){
|
||||||
};
|
// console.log(allFilters1[i]);
|
||||||
var filterRepeat = 0;
|
for(j in allFilters1[i]){
|
||||||
//make sure the filter or sort param is not duplicate before pushing it into the all filters array
|
// console.log(allFilters1[i][j],j);
|
||||||
if(allFilters1.length!=0)
|
for(k in allFilters1[i][j])
|
||||||
for(var i = 0;i<allFilters1.length;i++){
|
{
|
||||||
for(j in allFilters1[i]){
|
// console.log('column = ',j);
|
||||||
for(k in allFilters1[i][j])
|
// console.log('condition = ',k);
|
||||||
{
|
// console.log('value = ',allFilters1[i][j][k]);
|
||||||
if(column == j && condition == k && response == allFilters1[i][j][k]){
|
var filter_card = '<span class="filter-one" id="'+ i +'"><span class="filter-name">'+ j +'</span><span class="filter-value">'+allFilters1[i][j][k] +'<span class="icon cross-icon remove-filter"></span></span></span>';
|
||||||
filterRepeat = 1;
|
$('.filter-row-two').append(filter_card);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(filterRepeat == 0)
|
|
||||||
{
|
|
||||||
allFilters1.push(tmp);
|
|
||||||
// console.log(allFilters1);
|
|
||||||
var filter_card = '<span class="filter-one"><span class="filter-name">'+ column +'</span><span class="filter-value">'+response +'<span class="icon cross-icon"></span></span></span>';
|
|
||||||
$('.filter-row-two').append(filter_card);
|
|
||||||
makeURL(allFilters1);
|
|
||||||
count_filters++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
alert("This filter is already applied");
|
|
||||||
}
|
|
||||||
|
|
||||||
//prepare URL from the all filters array
|
function makeTagsTest(column, condition, response, urlparams) {
|
||||||
function makeURL(x) {
|
|
||||||
var y,k,z,c,d;
|
|
||||||
|
|
||||||
var filt_url = '';
|
|
||||||
|
|
||||||
for(y in x){
|
|
||||||
k = x[y];
|
|
||||||
for(z in k){
|
|
||||||
c = k[z];
|
|
||||||
for(d in c){
|
|
||||||
console.log(y); //first element of per which will make the url filter or sort
|
|
||||||
console.log(z); //name of the column which is needed to be filtered or sorted
|
|
||||||
console.log(d); //any condition or just sort
|
|
||||||
console.log(c[d]); //filter value or response
|
|
||||||
|
|
||||||
|
var tmp = {};
|
||||||
|
tmp[column] ={
|
||||||
|
[condition]:response
|
||||||
|
};
|
||||||
|
var filterRepeat = 0;
|
||||||
|
//make sure the filter or sort param is not duplicate before pushing it into the all filters array
|
||||||
|
if(allFilters1.length!=0)
|
||||||
|
for(var i = 0;i<allFilters1.length;i++){
|
||||||
|
for(j in allFilters1[i]){
|
||||||
|
for(k in allFilters1[i][j])
|
||||||
|
{
|
||||||
|
if(column == j && condition == k && response == allFilters1[i][j][k]){
|
||||||
|
filterRepeat = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(y==0)
|
if(filterRepeat == 0)
|
||||||
filt_url = filt_url + '?' + y + '=' + z + '[' + d + ']' + '=' + c[d];
|
{
|
||||||
|
allFilters1.push(tmp);
|
||||||
|
// console.log(allFilters1);
|
||||||
|
var filter_card = '<span class="filter-one"><span class="filter-name">'+ column +'</span><span class="filter-value">'+ response +'<span class="icon cross-icon"></span></span></span>';
|
||||||
|
$('.filter-row-two').append(filter_card);
|
||||||
|
makeURL(allFilters1);
|
||||||
|
count_filters++;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
filt_url = filt_url + '&' + y + '=' + z + '[' + d + ']' + '=' + c[d];
|
alert("This filter is already applied");
|
||||||
}
|
}
|
||||||
console.log(filt_url);
|
|
||||||
console.log(count_filters);
|
|
||||||
// return false;
|
|
||||||
document.location = filt_url;
|
|
||||||
}
|
|
||||||
|
|
||||||
//obselete
|
//prepare URL from the all filters array
|
||||||
function formURL(column, condition, response, urlparams) {
|
function makeURL(x) {
|
||||||
makeTagsTest(column, condition, response, urlparams);
|
var y,k,z,c,d;
|
||||||
// var pos = params.lastIndexOf("&");
|
|
||||||
// var pos1 = params.lastIndexOf("?");
|
|
||||||
|
|
||||||
// //detect the url state
|
var filt_url = '';
|
||||||
// if(pos == -1 && pos1!=-1){
|
|
||||||
// count_filters = parseInt(params.slice(1,2).trim());
|
|
||||||
// console.log('use count for ?',parseInt(count_filters));
|
|
||||||
// }
|
|
||||||
// else if(pos == -1 && pos1 == -1){
|
|
||||||
// count_filters = parseInt(0);
|
|
||||||
// console.log('no search params found');
|
|
||||||
// }
|
|
||||||
// else if(pos!= -1 && pos1!= -1){
|
|
||||||
// count_filters = parseInt(params.slice(pos+1,pos+2).trim());
|
|
||||||
// console.log('both & and ? present so using index=',count_filters);
|
|
||||||
// }
|
|
||||||
// else{
|
|
||||||
// count_filters = parseInt(params.slice(pos+1,pos+2).trim());
|
|
||||||
// console.log(count_filters);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// //act on url state
|
for(y in x){
|
||||||
// if(count_filters==0 && pos == -1 && pos1!=-1)
|
k = x[y];
|
||||||
// {
|
for(z in k){
|
||||||
// filt = filt + '&' + parseInt(count_filters+1) + '=' + column + array_start + condition + array_end + '=' + response;
|
c = k[z];
|
||||||
// makeTagsTest(column, condition, response, urlparams,parseInt(count_filters));
|
for(d in c){
|
||||||
// // document.location = myURL + filt;
|
console.log(y); //first element of per which will make the url filter or sort
|
||||||
// }
|
console.log(z); //name of the column which is needed to be filtered or sorted
|
||||||
// else if(count_filters==0 && pos==-1 && pos1==-1)
|
console.log(d); //any condition or just sort
|
||||||
// {
|
console.log(c[d]); //filter value or response
|
||||||
// filt = '?' + parseInt(count_filters+1) + '=' + column + array_start + condition + array_end + '=' + response;
|
|
||||||
// makeTagsTest(column, condition, response, urlparams,parseInt(count_filters));
|
}
|
||||||
// // document.location = myURL + filt;
|
}
|
||||||
// }
|
if(y==0)
|
||||||
// else if(count_filters>0 && pos!=-1 && pos1!=-1){
|
filt_url = filt_url + '?' + y + '=' + z + '[' + d + ']' + '=' + c[d];
|
||||||
// filt = filt + '&' + parseInt(count_filters+1) + '=' + column + array_start + condition + array_end + '=' + response;
|
else
|
||||||
// makeTagsTest(column, condition, response, urlparams,parseInt(count_filters));
|
filt_url = filt_url + '&' + y + '=' + z + '[' + d + ']' + '=' + c[d];
|
||||||
// // document.location = myURL + filt;
|
}
|
||||||
// }
|
console.log(filt_url);
|
||||||
// else{
|
console.log(count_filters);
|
||||||
// filt = '?' + parseInt(count_filters) + '=' + column + array_start + condition + array_end + '=' + response;
|
// return false;
|
||||||
// makeTagsTest(column, condition, response, urlparams,parseInt(count_filters));
|
document.location = filt_url;
|
||||||
// // document.location = myURL + filt;
|
}
|
||||||
// }
|
|
||||||
}
|
//obselete
|
||||||
|
function formURL(column, condition, response, urlparams) {
|
||||||
|
makeTagsTest(column, condition, response, urlparams);
|
||||||
|
// var pos = params.lastIndexOf("&");
|
||||||
|
// var pos1 = params.lastIndexOf("?");
|
||||||
|
|
||||||
|
// //detect the url state
|
||||||
|
// if(pos == -1 && pos1!=-1){
|
||||||
|
// count_filters = parseInt(params.slice(1,2).trim());
|
||||||
|
// console.log('use count for ?',parseInt(count_filters));
|
||||||
|
// }
|
||||||
|
// else if(pos == -1 && pos1 == -1){
|
||||||
|
// count_filters = parseInt(0);
|
||||||
|
// console.log('no search params found');
|
||||||
|
// }
|
||||||
|
// else if(pos!= -1 && pos1!= -1){
|
||||||
|
// count_filters = parseInt(params.slice(pos+1,pos+2).trim());
|
||||||
|
// console.log('both & and ? present so using index=',count_filters);
|
||||||
|
// }
|
||||||
|
// else{
|
||||||
|
// count_filters = parseInt(params.slice(pos+1,pos+2).trim());
|
||||||
|
// console.log(count_filters);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //act on url state
|
||||||
|
// if(count_filters==0 && pos == -1 && pos1!=-1)
|
||||||
|
// {
|
||||||
|
// filt = filt + '&' + parseInt(count_filters+1) + '=' + column + array_start + condition + array_end + '=' + response;
|
||||||
|
// makeTagsTest(column, condition, response, urlparams,parseInt(count_filters));
|
||||||
|
// // document.location = myURL + filt;
|
||||||
|
// }
|
||||||
|
// else if(count_filters==0 && pos==-1 && pos1==-1)
|
||||||
|
// {
|
||||||
|
// filt = '?' + parseInt(count_filters+1) + '=' + column + array_start + condition + array_end + '=' + response;
|
||||||
|
// makeTagsTest(column, condition, response, urlparams,parseInt(count_filters));
|
||||||
|
// // document.location = myURL + filt;
|
||||||
|
// }
|
||||||
|
// else if(count_filters>0 && pos!=-1 && pos1!=-1){
|
||||||
|
// filt = filt + '&' + parseInt(count_filters+1) + '=' + column + array_start + condition + array_end + '=' + response;
|
||||||
|
// makeTagsTest(column, condition, response, urlparams,parseInt(count_filters));
|
||||||
|
// // document.location = myURL + filt;
|
||||||
|
// }
|
||||||
|
// else{
|
||||||
|
// filt = '?' + parseInt(count_filters) + '=' + column + array_start + condition + array_end + '=' + response;
|
||||||
|
// makeTagsTest(column, condition, response, urlparams,parseInt(count_filters));
|
||||||
|
// // document.location = myURL + filt;
|
||||||
|
// }
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
@endsection
|
@endsection
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue