Data Grid bugs removed
This commit is contained in:
parent
fb1f042597
commit
586b1d9779
|
|
@ -37,10 +37,10 @@ class UserComposer
|
||||||
public function compose(View $view)
|
public function compose(View $view)
|
||||||
{
|
{
|
||||||
$datagrid = DataGrid::make([
|
$datagrid = DataGrid::make([
|
||||||
'name' => 'Users',
|
'name' => 'Admins',
|
||||||
'table' => 'admins as u',
|
'table' => 'admins as u',
|
||||||
'select' => 'u.id',
|
'select' => 'u.id',
|
||||||
'aliased' => true , //boolean to validate aliasing on the basis of this.
|
'aliased' => true, //boolean to validate aliasing on the basis of this.
|
||||||
'filterable' => [
|
'filterable' => [
|
||||||
[
|
[
|
||||||
'column' => 'u.email',
|
'column' => 'u.email',
|
||||||
|
|
@ -50,6 +50,10 @@ class UserComposer
|
||||||
'column' => 'u.name',
|
'column' => 'u.name',
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'label' => 'Admin Name'
|
'label' => 'Admin Name'
|
||||||
|
], [
|
||||||
|
'column' => 'u.id',
|
||||||
|
'type' => 'number',
|
||||||
|
'label' => 'Admin ID'
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
'searchable' => [
|
'searchable' => [
|
||||||
|
|
@ -83,13 +87,13 @@ class UserComposer
|
||||||
// ],
|
// ],
|
||||||
],
|
],
|
||||||
'join' => [
|
'join' => [
|
||||||
[
|
// [
|
||||||
'join' => 'leftjoin',
|
// 'join' => 'leftjoin',
|
||||||
'table' => 'roles as r',
|
// 'table' => 'roles as r',
|
||||||
'primaryKey' => 'u.role_id',
|
// 'primaryKey' => 'u.role_id',
|
||||||
'condition' => '=',
|
// 'condition' => '=',
|
||||||
'secondaryKey' => 'r.id',
|
// 'secondaryKey' => 'r.id',
|
||||||
]
|
// ]
|
||||||
],
|
],
|
||||||
'columns' => [
|
'columns' => [
|
||||||
[
|
[
|
||||||
|
|
@ -110,12 +114,12 @@ class UserComposer
|
||||||
'label' => 'Admin E-Mail',
|
'label' => 'Admin E-Mail',
|
||||||
'sortable' => true,
|
'sortable' => true,
|
||||||
],
|
],
|
||||||
[
|
// [
|
||||||
'name' => 'r.name as rolename',
|
// 'name' => 'r.name as rolename',
|
||||||
'type' => 'string',
|
// 'type' => 'string',
|
||||||
'label' => 'Role Name',
|
// 'label' => 'Role Name',
|
||||||
'sortable' => true,
|
// 'sortable' => true,
|
||||||
],
|
// ],
|
||||||
// [
|
// [
|
||||||
// 'name' => 'a.first_name',
|
// 'name' => 'a.first_name',
|
||||||
// 'type' => 'string',
|
// 'type' => 'string',
|
||||||
|
|
@ -147,6 +151,7 @@ class UserComposer
|
||||||
'neqs' => "<>",
|
'neqs' => "<>",
|
||||||
'neqn' => "!=",
|
'neqn' => "!=",
|
||||||
'like' => "like",
|
'like' => "like",
|
||||||
|
'nlike' => "not like",
|
||||||
],
|
],
|
||||||
// 'css' => []
|
// 'css' => []
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -67,6 +67,9 @@
|
||||||
|
|
||||||
.dashboard-content {
|
.dashboard-content {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
border: 1px solid red;
|
||||||
margin-top: 5.5%;
|
margin-top: 5.5%;
|
||||||
margin-bottom: 5.5%;
|
margin-bottom: 5.5%;
|
||||||
|
|
||||||
|
|
@ -80,6 +83,8 @@
|
||||||
background: #ffffff;
|
background: #ffffff;
|
||||||
width: 25%;
|
width: 25%;
|
||||||
text-transform: capitalize;
|
text-transform: capitalize;
|
||||||
|
font-size: 16px;
|
||||||
|
color: #5e5e5e;
|
||||||
|
|
||||||
li {
|
li {
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
|
|
@ -104,4 +109,21 @@
|
||||||
border-bottom: none;
|
border-bottom: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.profile {
|
||||||
|
margin-left: 5.5%;
|
||||||
|
|
||||||
|
.section-heading {
|
||||||
|
height: 50px;
|
||||||
|
font-size: 28px;
|
||||||
|
color: #242424;
|
||||||
|
text-transform: capitalize;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.profile-content {
|
||||||
|
font-size: 16px;
|
||||||
|
color: #5e5e5e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,5 +8,40 @@
|
||||||
<li>Reviews</li>
|
<li>Reviews</li>
|
||||||
<li>Wishlist</li>
|
<li>Wishlist</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
<div class="profile">
|
||||||
|
<div class="section-heading">
|
||||||
|
Profile
|
||||||
|
</div>
|
||||||
|
<div class="profile-content">
|
||||||
|
<table>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>First Name</td>
|
||||||
|
<td>Prashant</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Last Name</td>
|
||||||
|
<td>Singh</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Gender Name</td>
|
||||||
|
<td>Male</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Date of Birth</td>
|
||||||
|
<td>1/1/1993</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Email Address</td>
|
||||||
|
<td>Prashant@webkul.com</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Mobile</td>
|
||||||
|
<td>+91-9988887744</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@endsection
|
@endsection
|
||||||
|
|
|
||||||
|
|
@ -391,19 +391,30 @@ class DataGrid
|
||||||
* to be used.
|
* to be used.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// private function parse()
|
||||||
|
// {
|
||||||
|
// //parse the url here
|
||||||
|
// if (isset($_SERVER['QUERY_STRING'])) {
|
||||||
|
// $qr = $_SERVER['QUERY_STRING'];
|
||||||
|
// parse_str($qr, $parsed);
|
||||||
|
// foreach ($parsed as $k=>$v) {
|
||||||
|
// parse_str($v, $parsed[$k]);
|
||||||
|
// }
|
||||||
|
// return $parsed;
|
||||||
|
// } else {
|
||||||
|
// return $parsed = [];
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
private function parse()
|
private function parse()
|
||||||
{
|
{
|
||||||
//parse the url here
|
$parsed = [];
|
||||||
if (isset($_SERVER['QUERY_STRING'])) {
|
$unparsed = $_SERVER['QUERY_STRING'];
|
||||||
$qr = $_SERVER['QUERY_STRING'];
|
if (isset($unparsed)) {
|
||||||
parse_str($qr, $parsed);
|
parse_str($unparsed, $parsed);
|
||||||
|
|
||||||
foreach ($parsed as $k=>$v) {
|
|
||||||
parse_str($v, $parsed[$k]);
|
|
||||||
}
|
|
||||||
return $parsed;
|
return $parsed;
|
||||||
} else {
|
} else {
|
||||||
return $parsed = [];
|
return $parsed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -470,77 +481,138 @@ class DataGrid
|
||||||
* and processed manually
|
* and processed manually
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// private function getQueryWithFilters()
|
||||||
|
// {
|
||||||
|
// // the only use case remaining is making and testing the full validation and testing of
|
||||||
|
// // aliased case with alias used in column names also.
|
||||||
|
// if ($this->aliased) {
|
||||||
|
// //n of joins can lead to n number of aliases for columns and neglect the as for columns
|
||||||
|
// $parsed = $this->parse();
|
||||||
|
// // dump($parsed);
|
||||||
|
// foreach ($parsed as $key => $value) {
|
||||||
|
// foreach ($value as $column => $filter) {
|
||||||
|
// if (array_keys($filter)[0]=="like") {
|
||||||
|
// $this->query->where(
|
||||||
|
// str_replace('_', '.', $column), //replace the logic of making the column name and consider the case for _ in column name already
|
||||||
|
// $this->operators[array_keys($filter)[0]],
|
||||||
|
// '%'.array_values($filter)[0].'%'
|
||||||
|
// );
|
||||||
|
// } elseif (array_keys($filter)[0]=="sort") {
|
||||||
|
// $this->query->orderBy(
|
||||||
|
// str_replace('_', '.', $column), //replace the logic of making the column name and consider the case for _
|
||||||
|
// array_values($filter)[0]
|
||||||
|
// );
|
||||||
|
// } elseif ($column == "search") {
|
||||||
|
// $this->query->where(function ($query) use ($filter) {
|
||||||
|
// foreach ($this->searchable as $search) {
|
||||||
|
// $query->orWhere($search['column'], 'like', '%'.array_values($filter)[0].'%');
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// } else {
|
||||||
|
// $this->query->where(
|
||||||
|
// str_replace('_', '.', $column),
|
||||||
|
// $this->operators[array_keys($filter)[0]],
|
||||||
|
// array_values($filter)[0]
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// $parsed = $this->parse();
|
||||||
|
// foreach ($parsed as $key => $value) {
|
||||||
|
// foreach ($value as $column => $filter) {
|
||||||
|
// if (array_keys($filter)[0]=="like") {
|
||||||
|
// $this->query->where(
|
||||||
|
// $column,
|
||||||
|
// $this->operators[array_keys($filter)[0]],
|
||||||
|
// '%'.array_values($filter)[0].'%'
|
||||||
|
// );
|
||||||
|
// } elseif ($column == "search") {
|
||||||
|
// $this->query->where(function ($query) use ($filter) {
|
||||||
|
// foreach ($this->searchable as $search) {
|
||||||
|
// $query->orWhere($search['column'], 'like', '%'.array_values($filter)[0].'%');
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// } else {
|
||||||
|
// $this->query->where(
|
||||||
|
// $column,
|
||||||
|
// $this->operators[array_keys($filter)[0]],
|
||||||
|
// array_values($filter)[0]
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
private function getQueryWithFilters()
|
private function getQueryWithFilters()
|
||||||
{
|
{
|
||||||
// the only use case remaining is making and testing the full validation and testing of
|
$parsed = $this->parse();
|
||||||
// aliased case with alias used in column names also.
|
// dd($parsed);
|
||||||
if ($this->aliased) {
|
if ($this->aliased) {
|
||||||
//n of joins can lead to n number of aliases for columns and neglect the as for columns
|
foreach ($parsed as $key=>$value) {
|
||||||
$parsed = $this->parse();
|
if ($key=="sort") {
|
||||||
// dump($parsed);
|
|
||||||
foreach ($parsed as $key => $value) {
|
//resolve the case with the column helper class
|
||||||
foreach ($value as $column => $filter) {
|
if (strpos($key, ' as ') !== false) {
|
||||||
if (array_keys($filter)[0]=="like") {
|
dd('This column cannot be sorted');
|
||||||
$this->query->where(
|
|
||||||
str_replace('_', '.', $column), //replace the logic of making the column name and consider the case for _ in column name already
|
|
||||||
$this->operators[array_keys($filter)[0]],
|
|
||||||
'%'.array_values($filter)[0].'%'
|
|
||||||
);
|
|
||||||
} elseif (array_keys($filter)[0]=="sort") {
|
|
||||||
$this->query->orderBy(
|
|
||||||
str_replace('_', '.', $column), //replace the logic of making the column name and consider the case for _
|
|
||||||
array_values($filter)[0]
|
|
||||||
);
|
|
||||||
} elseif ($column == "search") {
|
|
||||||
$this->query->where(function ($query) use ($filter) {
|
|
||||||
foreach ($this->searchable as $search) {
|
|
||||||
$query->orWhere($search['column'], 'like', '%'.array_values($filter)[0].'%');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
$this->query->where(
|
$column_name = str_replace('_', '.', $key);
|
||||||
str_replace('_', '.', $column),
|
}
|
||||||
$this->operators[array_keys($filter)[0]],
|
|
||||||
array_values($filter)[0]
|
//case that don't need any resolving
|
||||||
);
|
$count_keys = count(array_keys($value));
|
||||||
|
if ($count_keys==1) {
|
||||||
|
$this->query->orderBy(
|
||||||
|
str_replace('_', '.', array_keys($value)[0]),
|
||||||
|
array_values($value)[0]
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
dump('Sort on two columns cannot exist in backend');
|
||||||
|
}
|
||||||
|
} elseif ($key=="search") {
|
||||||
|
if (strpos($key, ' as ') !== false) {
|
||||||
|
dd('This column cannot be searched');
|
||||||
|
} else {
|
||||||
|
$column_name = str_replace('_', '.', $key);
|
||||||
|
}
|
||||||
|
$this->query->where(function ($query) use ($parsed) {
|
||||||
|
foreach ($this->searchable as $search) {
|
||||||
|
$query->orWhere($search['column'], 'like', '%'.$parsed['search']['all'].'%');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
if (strpos($key, ' as ') !== false) {
|
||||||
|
dd('This column cannot be filtered');
|
||||||
|
} else {
|
||||||
|
$column_name = str_replace('_', '.', $key);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (array_keys($value)[0]=="like" || array_keys($value)[0]=="nlike") {
|
||||||
|
foreach ($value as $condition => $filter_value) {
|
||||||
|
$this->query->where(
|
||||||
|
$column_name,
|
||||||
|
$this->operators[$condition],
|
||||||
|
'%'.$filter_value.'%'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
foreach ($value as $condition => $filter_value) {
|
||||||
|
$this->query->where(
|
||||||
|
$column_name,
|
||||||
|
$this->operators[$condition],
|
||||||
|
$filter_value
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$parsed = $this->parse();
|
dd('left to be run plainly');
|
||||||
foreach ($parsed as $key => $value) {
|
|
||||||
foreach ($value as $column => $filter) {
|
|
||||||
if (array_keys($filter)[0]=="like") {
|
|
||||||
$this->query->where(
|
|
||||||
$column,
|
|
||||||
$this->operators[array_keys($filter)[0]],
|
|
||||||
'%'.array_values($filter)[0].'%'
|
|
||||||
);
|
|
||||||
} elseif ($column == "search") {
|
|
||||||
$this->query->where(function ($query) use ($filter) {
|
|
||||||
foreach ($this->searchable as $search) {
|
|
||||||
$query->orWhere($search['column'], 'like', '%'.array_values($filter)[0].'%');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
$this->query->where(
|
|
||||||
$column,
|
|
||||||
$this->operators[array_keys($filter)[0]],
|
|
||||||
array_values($filter)[0]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getDbQueryResults()
|
private function getDbQueryResults()
|
||||||
{
|
{
|
||||||
// if (isset($_SERVER['QUERY_STRING'])) {
|
|
||||||
// $qr = $_SERVER['QUERY_STRING'];
|
|
||||||
// $parsed;
|
|
||||||
// parse_str($qr, $parsed);
|
|
||||||
// }
|
|
||||||
$parsed = $this->parse();
|
$parsed = $this->parse();
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -659,12 +731,9 @@ class DataGrid
|
||||||
if (!empty($this->select)) {
|
if (!empty($this->select)) {
|
||||||
$this->getSelect();
|
$this->getSelect();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->getQueryWithColumnFilters();
|
$this->getQueryWithColumnFilters();
|
||||||
// if (isset($_SERVER['QUERY_STRING'])) {
|
|
||||||
// $qr = $_SERVER['QUERY_STRING'];
|
|
||||||
// $parsed;
|
|
||||||
// parse_str($qr, $parsed);
|
|
||||||
// }
|
|
||||||
$parsed = $this->parse();
|
$parsed = $this->parse();
|
||||||
if (!empty($parsed)) {
|
if (!empty($parsed)) {
|
||||||
$this->getQueryWithFilters();
|
$this->getQueryWithFilters();
|
||||||
|
|
|
||||||
|
|
@ -631,6 +631,7 @@ h2 {
|
||||||
ul {
|
ul {
|
||||||
li.filter-column-dropdown {
|
li.filter-column-dropdown {
|
||||||
.filter-column-select {
|
.filter-column-select {
|
||||||
|
width: 100%;
|
||||||
background: #fff;
|
background: #fff;
|
||||||
border: 2px solid #c7c7c7;
|
border: 2px solid #c7c7c7;
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
|
|
@ -740,6 +741,7 @@ h2 {
|
||||||
margin: 5px;
|
margin: 5px;
|
||||||
height: 18px !important;
|
height: 18px !important;
|
||||||
width: 18px !important;
|
width: 18px !important;
|
||||||
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,6 @@
|
||||||
$(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){
|
||||||
if(allFilters1.length == 0) {
|
if(allFilters1.length == 0) {
|
||||||
//call reverse url function
|
//call reverse url function
|
||||||
|
|
@ -35,25 +34,19 @@
|
||||||
}
|
}
|
||||||
$('.search-btn').click(function() {
|
$('.search-btn').click(function() {
|
||||||
search_value = $(".search-field").val();
|
search_value = $(".search-field").val();
|
||||||
|
|
||||||
formURL('search','all',search_value,params); //format for search
|
formURL('search','all',search_value,params); //format for search
|
||||||
|
|
||||||
alert(search_value);
|
|
||||||
});
|
});
|
||||||
$('.grid_head').on('click', function() {
|
|
||||||
|
|
||||||
|
//controls for header when sorting is done
|
||||||
|
$('.grid_head').on('click', function() {
|
||||||
var column = $(this).data('column-name');
|
var column = $(this).data('column-name');
|
||||||
var currentSort = $(this).data('column-sort');
|
var currentSort = $(this).data('column-sort');
|
||||||
console.log(column, currentSort);
|
if(currentSort == "asc")
|
||||||
// return false;
|
formURL("sort",column,"desc",params);
|
||||||
if(currentSort == "asc") {
|
else if(currentSort == "desc")
|
||||||
$(this).data('column-name','desc');
|
formURL("sort",column,"asc",params);
|
||||||
formURL(column,'sort','desc',params);
|
|
||||||
}else{
|
|
||||||
$(this).data('column-name','asc');
|
|
||||||
formURL(column,'sort','asc',params);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$('select.filter-column-select').change(function() {
|
$('select.filter-column-select').change(function() {
|
||||||
typeValue = $('select.filter-column-select').find(':selected').data('type');
|
typeValue = $('select.filter-column-select').find(':selected').data('type');
|
||||||
selectedColumn = $('select.filter-column-select').find(':selected').val();
|
selectedColumn = $('select.filter-column-select').find(':selected').val();
|
||||||
|
|
@ -131,12 +124,10 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
//remove the filter and from clicking on cross icon on tag
|
//remove the filter and from clicking on cross icon on tag
|
||||||
$('.remove-filter').on('click', function(){
|
$('.remove-filter').on('click', function(){
|
||||||
// console.log('removing');
|
|
||||||
var id = $(this).parents('.filter-one').attr('id');
|
var id = $(this).parents('.filter-one').attr('id');
|
||||||
// console.log(allFilters1.length);
|
|
||||||
|
|
||||||
if(allFilters1.length == 1){
|
if(allFilters1.length == 1){
|
||||||
allFilters1.pop();
|
allFilters1.pop();
|
||||||
var uri = window.location.href.toString();
|
var uri = window.location.href.toString();
|
||||||
|
|
@ -218,203 +209,206 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
//remove the mass action by clicking on the icon
|
|
||||||
// $('.mass-action-remove').on('click', function() {
|
|
||||||
// $("input[type=checkbox]").prop('checked',false);
|
|
||||||
// id = [];
|
|
||||||
// $('#indexes').val('');
|
|
||||||
// $('.mass-action').css('display','none');
|
|
||||||
// $('.table-grid-header').css('display','');
|
|
||||||
// });
|
|
||||||
|
|
||||||
// $('.b-res').css('visibility','hidden');
|
|
||||||
// $('.t-res').css('visibility','hidden');
|
|
||||||
// $('.ma-action').css('visibility','hidden');
|
|
||||||
// var ma_selected_col;
|
|
||||||
// var ma_selected_type;
|
|
||||||
// var ma_selected_action;
|
|
||||||
// $('select.ma-col').change(function() {
|
|
||||||
// ma_selected_col = $('select.ma-col').find(':selected').val();
|
|
||||||
// ma_selected_type = $('select.ma-col').find(':selected').data('type');
|
|
||||||
// $('.ma-action').css('visibility','visible');
|
|
||||||
// console.log(ma_selected_col,ma_selected_type);
|
|
||||||
// });
|
|
||||||
// $('.ma-action').change(function(){
|
|
||||||
// ma_selected_action = $('select.ma-action').find(':selected').val();
|
|
||||||
// });
|
|
||||||
// if(ma_selected_action == "update") {
|
|
||||||
// if(ma_selected_type="boolean") {
|
|
||||||
// $('.b-res').css('visibility','visible');
|
|
||||||
// }
|
|
||||||
// } else if(ma_selected_action == "delete"){
|
|
||||||
// $('.b-res').css('visibility','visible');
|
|
||||||
// }
|
|
||||||
|
|
||||||
});
|
});
|
||||||
//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
|
//make the url from the array and redirect
|
||||||
function arrayFromUrl(x){
|
function makeURL() {
|
||||||
// console.log(allFilters1);
|
if(allFilters1.length>0)
|
||||||
// console.log(x);
|
{
|
||||||
t = x.slice(1,x.length);
|
for(i=0;i<allFilters1.length;i++) {
|
||||||
|
console.log(allFilters1[i]);
|
||||||
|
if(i==0){
|
||||||
|
url = '?' + allFilters1[i].column + '[' + allFilters1[i].cond + ']' + '=' + allFilters1[i].val;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
url = url + '&' + allFilters1[i].column + '[' + allFilters1[i].cond + ']' + '=' + allFilters1[i].val;
|
||||||
|
}
|
||||||
|
document.location = url;
|
||||||
|
} else {
|
||||||
|
var uri = window.location.href.toString();
|
||||||
|
var clean_uri = uri.substring(0, uri.indexOf("?"));
|
||||||
|
document.location = clean_uri;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//make the filter array from url after being redirected
|
||||||
|
function arrayFromUrl(x) {
|
||||||
|
var obj={};
|
||||||
|
t = x.slice(0,x.length);
|
||||||
splitted = [];
|
splitted = [];
|
||||||
moreSplitted = [];
|
moreSplitted = [];
|
||||||
splitted = t.split('&');
|
splitted = t.split('&');
|
||||||
for(i=0;i<splitted.length;i++){
|
for(i=0;i<splitted.length;i++) {
|
||||||
moreSplitted.push(splitted[i].split('='));
|
moreSplitted.push(splitted[i].split('='));
|
||||||
}
|
}
|
||||||
for(i=0;i<moreSplitted.length;i++){
|
for(i=0;i<moreSplitted.length;i++) {
|
||||||
temp = moreSplitted[i];
|
col = moreSplitted[i][0].replace(']','').split('[')[0];
|
||||||
// console.log(moreSplitted[i][2]); //use this for response
|
cond = moreSplitted[i][0].replace(']','').split('[')[1]
|
||||||
var pos1 = temp[1].indexOf("[");
|
val = moreSplitted[i][1];
|
||||||
var pos2 = temp[1].indexOf("]");
|
obj.column = col;
|
||||||
column_name = temp[1].slice(0,pos1);
|
obj.cond = cond;
|
||||||
condition_name = temp[1].slice(pos1+1,pos2);
|
obj.val = val;
|
||||||
var tmp = {};
|
allFilters1.push(obj);
|
||||||
tmp[column_name.trim()] ={
|
obj = {};
|
||||||
[condition_name.trim()]:moreSplitted[i][2]
|
|
||||||
};
|
|
||||||
allFilters1.push(tmp);
|
|
||||||
}
|
}
|
||||||
// console.log('Array from URL = ',allFilters1);
|
|
||||||
makeTagsTestPrior();
|
makeTagsTestPrior();
|
||||||
}
|
}
|
||||||
var label;
|
|
||||||
|
var label; //use the label to prevent the display of column name on the body
|
||||||
function makeTagsTestPrior() {
|
function makeTagsTestPrior() {
|
||||||
var filterRepeat = 0;
|
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)
|
if(allFilters1.length!=0)
|
||||||
for(var i = 0;i<allFilters1.length;i++) {
|
for(var i = 0;i<allFilters1.length;i++) {
|
||||||
// console.log(allFilters1[i]);
|
var filter_card = '<span class="filter-one" id="'+ i +'"><span class="filter-name">'+ allFilters1[i].column +'</span><span class="filter-value"><span class="f-value">'+ allFilters1[i].val +'</span><span class="icon cross-icon remove-filter"></span></span></span>';
|
||||||
for(j in allFilters1[i]) {
|
|
||||||
// console.log(allFilters1[i][j],j);
|
|
||||||
for(k in allFilters1[i][j])
|
|
||||||
{
|
|
||||||
console.log('column = ',j);
|
|
||||||
if($("th[data-column-name='" + j +"']")) {
|
|
||||||
label = $("th[data-column-name='" + j +"']").data('column-label');
|
|
||||||
console.log(label);
|
|
||||||
}
|
|
||||||
|
|
||||||
// console.log('label = ',label);
|
|
||||||
// console.log('condition = ',k);
|
|
||||||
// console.log('value = ',allFilters1[i][j][k]);
|
|
||||||
var filter_card = '<span class="filter-one" id="'+ i +'"><span class="filter-name">'+ label +'</span><span class="filter-value"><span class="f-value">'+allFilters1[i][j][k] +'</span><span class="icon cross-icon remove-filter"></span></span></span>';
|
|
||||||
$('.filter-row-two').append(filter_card);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function makeTagsTest(column, condition, response, urlparams) {
|
|
||||||
|
|
||||||
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(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"><span class="f-value">'+ response +'</span><span class="icon cross-icon"></span></span></span>';
|
|
||||||
$('.filter-row-two').append(filter_card);
|
$('.filter-row-two').append(filter_card);
|
||||||
makeURL(allFilters1);
|
|
||||||
count_filters++;
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
alert("This filter is already applied");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//prepare URL from the all filters array
|
//obselete or can be used for mediation control if necessary
|
||||||
function makeURL(x) {
|
function formURL(column, condition, response, urlparams) {
|
||||||
var y,k,z,c,d;
|
/*validate the conditions here and do the replacements and
|
||||||
|
push here in the all filters array*/
|
||||||
|
var obj1 = {};
|
||||||
|
/*
|
||||||
|
1. do check for repeated filter and just return false
|
||||||
|
2. do check for repeated sorting and toggle rempve it.
|
||||||
|
3. do check for search and replace the search value with
|
||||||
|
the new one
|
||||||
|
*/
|
||||||
|
|
||||||
var filt_url = '';
|
if(allFilters1.length>0) {
|
||||||
|
//case for repeated filter
|
||||||
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
|
|
||||||
|
|
||||||
|
if(column != "sort" && column != "search") {
|
||||||
|
filter_repeated = 0;
|
||||||
|
for(j=0;j<allFilters1.length;j++) {
|
||||||
|
if(allFilters1[j].column==column && allFilters1[j].cond==condition && allFilters1[j].val==response)
|
||||||
|
{
|
||||||
|
filter_repeated = 1;
|
||||||
|
alert('Filter is repeated');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(filter_repeated == 0) {
|
||||||
|
obj1.column = column;
|
||||||
|
obj1.cond = condition;
|
||||||
|
obj1.val = response;
|
||||||
|
allFilters1.push(obj1);
|
||||||
|
obj1 = {};
|
||||||
|
makeURL();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(column == "sort") {
|
||||||
|
alert('sort found');
|
||||||
|
sort_exists = 0;
|
||||||
|
for(j=0;j<allFilters1.length;j++) {
|
||||||
|
console.log(allFilters1[j].column);
|
||||||
|
if(allFilters1[j].column == "sort") {
|
||||||
|
|
||||||
if(y == 0)
|
allFilters1[j].column = column;
|
||||||
filt_url = filt_url + '?' + y + '=' + z + '[' + d + ']' + '=' + c[d];
|
allFilters1[j].cond = condition;
|
||||||
else
|
allFilters1[j].val = response;
|
||||||
filt_url = filt_url + '&' + y + '=' + z + '[' + d + ']' + '=' + c[d];
|
makeURL();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(column == "search") {
|
||||||
|
console.log(allFilters1);
|
||||||
|
search_found = 0;
|
||||||
|
for(j=0;j<allFilters1.length;j++) {
|
||||||
|
if(allFilters1[j].column == "search") {
|
||||||
|
allFilters1[j].column = column;
|
||||||
|
allFilters1[j].cond = condition;
|
||||||
|
allFilters1[j].val = response;
|
||||||
|
makeURL();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(j=0;j<allFilters1.length;j++) {
|
||||||
|
if(allFilters1[j].column == "search") {
|
||||||
|
search_found = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(search_found == 0) {
|
||||||
|
obj1.column = column;
|
||||||
|
obj1.cond = condition;
|
||||||
|
obj1.val = response;
|
||||||
|
allFilters1.push(obj1);
|
||||||
|
obj1 = {};
|
||||||
|
makeURL();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
obj1.column = column;
|
||||||
|
obj1.cond = condition;
|
||||||
|
obj1.val = response;
|
||||||
|
allFilters1.push(obj1);
|
||||||
|
obj1 = {};
|
||||||
|
makeURL();
|
||||||
}
|
}
|
||||||
// console.log(filt_url);
|
// if(allFilters1.length>0) {
|
||||||
// console.log(count_filters);
|
// for(i=0;i<allFilters1.length;i++) {
|
||||||
// return false;
|
|
||||||
document.location = filt_url;
|
|
||||||
}
|
|
||||||
|
|
||||||
//obselete
|
// if(allFilters1[i].column!="sort" && allFilters1[i].column==column && allFilters1[i].cond==condition && allFilters1[i].val==response) {
|
||||||
function formURL(column, condition, response, urlparams) {
|
|
||||||
makeTagsTest(column, condition, response, urlparams);
|
|
||||||
// var pos = params.lastIndexOf("&");
|
|
||||||
// var pos1 = params.lastIndexOf("?");
|
|
||||||
|
|
||||||
// //detect the url state
|
// return false;
|
||||||
// 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)
|
// else if(column == "sort") {
|
||||||
// {
|
|
||||||
// filt = filt + '&' + parseInt(count_filters+1) + '=' + column + array_start + condition + array_end + '=' + response;
|
// sort_repeated = 0;
|
||||||
// makeTagsTest(column, condition, response, urlparams,parseInt(count_filters));
|
// for(j=0;j<allFilters1.length;j++){
|
||||||
// // document.location = myURL + filt;
|
// if(allFilters1[j].column == column && allFilters1[j].cond == condition && allFilters1[j].val == response) {
|
||||||
|
|
||||||
|
// sort_repeated = 1;
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
// }
|
||||||
|
// if(sort_repeated==1) {
|
||||||
|
|
||||||
|
// console.log('sort repeated executing');
|
||||||
|
// from = parseInt(allFilters1.length);
|
||||||
|
// to = parseInt(allFilters1.length) + 1;
|
||||||
|
// allFilters1 = allFilters1.splice(from,to);
|
||||||
|
// sort_repeated = 0;
|
||||||
|
// console.log("xxxxxxxxxxxxxx");
|
||||||
|
// makeURL();
|
||||||
|
|
||||||
|
// } else if(sort_repeated==0){
|
||||||
|
|
||||||
|
// //this is the buggy case
|
||||||
|
// allFilters1[i].column = column;
|
||||||
|
// allFilters1[i].cond = condition;
|
||||||
|
// allFilters1[i].val = response;
|
||||||
|
// console.log("yyyyyyyyyyyyyy");
|
||||||
|
// makeURL();
|
||||||
|
// }
|
||||||
|
|
||||||
|
// } else {
|
||||||
|
|
||||||
|
// obj1.column=column;
|
||||||
|
// obj1.cond=condition;
|
||||||
|
// obj1.val=response;
|
||||||
|
// allFilters1.push(obj1);
|
||||||
|
// console.log("zzzzzzzzzzzz");
|
||||||
|
// makeURL();
|
||||||
|
// obj1={ };
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
// }
|
||||||
// }
|
// }
|
||||||
// else if(count_filters==0 && pos==-1 && pos1==-1)
|
// else {
|
||||||
// {
|
|
||||||
// filt = '?' + parseInt(count_filters+1) + '=' + column + array_start + condition + array_end + '=' + response;
|
// obj1.column=column;
|
||||||
// makeTagsTest(column, condition, response, urlparams,parseInt(count_filters));
|
// obj1.cond=condition;
|
||||||
// // document.location = myURL + filt;
|
// obj1.val=response;
|
||||||
// }
|
// allFilters1.push(obj1);
|
||||||
// else if(count_filters>0 && pos!=-1 && pos1!=-1){
|
// console.log("1111111111111");
|
||||||
// filt = filt + '&' + parseInt(count_filters+1) + '=' + column + array_start + condition + array_end + '=' + response;
|
// obj1={ };
|
||||||
// makeTagsTest(column, condition, response, urlparams,parseInt(count_filters));
|
// makeURL();
|
||||||
// // 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>
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@
|
||||||
</th>
|
</th>
|
||||||
@foreach ($columns as $column)
|
@foreach ($columns as $column)
|
||||||
@if($column->sortable == "true")
|
@if($column->sortable == "true")
|
||||||
<th class="labelled-col grid_head" data-column-name="{{ $column->name }}" data-column-label="{{ $column->label }}" data-column-sort="asc"> {!! $column->sorting() !!} <span class="icon sort-down-icon"></span>
|
<th class="labelled-col grid_head" data-column-name="{{ $column->name }}" data-column-label="{{ $column->label }}" data-column-sort="asc"> {!! $column->sorting() !!}<span class="icon sort-down-icon"></span>
|
||||||
</th>
|
</th>
|
||||||
@else
|
@else
|
||||||
<th class="labelled-col grid_head" data-column-name="{{ $column->name }}" data-column-label="{{ $column->label }}">{!! $column->sorting() !!}</th>
|
<th class="labelled-col grid_head" data-column-name="{{ $column->name }}" data-column-label="{{ $column->label }}">{!! $column->sorting() !!}</th>
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,14 @@
|
||||||
|
|
||||||
.dashboard-content {
|
.dashboard-content {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
display: -webkit-box;
|
||||||
|
display: -ms-flexbox;
|
||||||
|
display: flex;
|
||||||
|
-webkit-box-orient: horizontal;
|
||||||
|
-webkit-box-direction: normal;
|
||||||
|
-ms-flex-direction: row;
|
||||||
|
flex-direction: row;
|
||||||
|
border: 1px solid red;
|
||||||
margin-top: 5.5%;
|
margin-top: 5.5%;
|
||||||
margin-bottom: 5.5%;
|
margin-bottom: 5.5%;
|
||||||
}
|
}
|
||||||
|
|
@ -94,6 +102,8 @@
|
||||||
background: #ffffff;
|
background: #ffffff;
|
||||||
width: 25%;
|
width: 25%;
|
||||||
text-transform: capitalize;
|
text-transform: capitalize;
|
||||||
|
font-size: 16px;
|
||||||
|
color: #5e5e5e;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dashboard-content .dashboard-side-menu li {
|
.dashboard-content .dashboard-side-menu li {
|
||||||
|
|
@ -129,3 +139,20 @@
|
||||||
.dashboard-content .dashboard-side-menu li:last-child {
|
.dashboard-content .dashboard-side-menu li:last-child {
|
||||||
border-bottom: none;
|
border-bottom: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.dashboard-content .profile {
|
||||||
|
margin-left: 5.5%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dashboard-content .profile .section-heading {
|
||||||
|
height: 50px;
|
||||||
|
font-size: 28px;
|
||||||
|
color: #242424;
|
||||||
|
text-transform: capitalize;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dashboard-content .profile-content {
|
||||||
|
font-size: 16px;
|
||||||
|
color: #5e5e5e;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -900,6 +900,7 @@ h2 {
|
||||||
}
|
}
|
||||||
|
|
||||||
.grid-container .filter-wrapper .filter-row-one .dropdown-filters .more-filters .dropdown-list .dropdown-container ul li.filter-column-dropdown .filter-column-select {
|
.grid-container .filter-wrapper .filter-row-one .dropdown-filters .more-filters .dropdown-list .dropdown-container ul li.filter-column-dropdown .filter-column-select {
|
||||||
|
width: 100%;
|
||||||
background: #fff;
|
background: #fff;
|
||||||
border: 2px solid #c7c7c7;
|
border: 2px solid #c7c7c7;
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
|
|
@ -1014,6 +1015,7 @@ h2 {
|
||||||
margin: 5px;
|
margin: 5px;
|
||||||
height: 18px !important;
|
height: 18px !important;
|
||||||
width: 18px !important;
|
width: 18px !important;
|
||||||
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
.grid-container .table thead .xyz {
|
.grid-container .table thead .xyz {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue