Mass actions remaining, underlying structure for customer package is ready
This commit is contained in:
parent
d68954a0e5
commit
a7081205f8
|
|
@ -3,11 +3,13 @@ namespace Webkul\Ui\DataGrid;
|
|||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Validate;
|
||||
use Illuminate\Pagination\Paginator;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Webkul\Ui\DataGrid\Helpers\Column;
|
||||
use Webkul\Ui\DataGrid\Helpers\Pagination;
|
||||
use Webkul\Ui\DataGrid\Helpers\Css;
|
||||
use Webkul\Ui\DataGrid\Helpers\MassAction;
|
||||
|
||||
class DataGrid
|
||||
{
|
||||
|
|
@ -63,6 +65,11 @@ class DataGrid
|
|||
*/
|
||||
protected $css;
|
||||
|
||||
/**
|
||||
* URL parse $parsed
|
||||
* @var parse
|
||||
*/
|
||||
protected $parsed;
|
||||
/*
|
||||
public function __construct(
|
||||
$name = null ,
|
||||
|
|
@ -124,6 +131,21 @@ class DataGrid
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make Mass Action
|
||||
*
|
||||
*/
|
||||
public function makeMassAction($attributes)
|
||||
{
|
||||
$result = new MassAction();
|
||||
|
||||
if ($result->validateSchemaMassAction($attributes)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Name.
|
||||
*
|
||||
|
|
@ -270,7 +292,8 @@ class DataGrid
|
|||
|
||||
/**
|
||||
* Add ColumnMultiple.
|
||||
*
|
||||
* Currently is not
|
||||
* of any use.
|
||||
* @return $this
|
||||
*/
|
||||
|
||||
|
|
@ -332,6 +355,34 @@ class DataGrid
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the URL
|
||||
* and get it ready
|
||||
* 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 = [];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Used for selecting
|
||||
* the columns got in
|
||||
* make from controller.
|
||||
* @return $this
|
||||
*/
|
||||
private function getSelect()
|
||||
{
|
||||
$select = [];
|
||||
|
|
@ -346,6 +397,7 @@ class DataGrid
|
|||
|
||||
/**
|
||||
* ->join('contacts', 'users.id', '=', 'contacts.user_id')
|
||||
* @return $this->query
|
||||
*/
|
||||
|
||||
private function getQueryWithJoin()
|
||||
|
|
@ -382,20 +434,19 @@ class DataGrid
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to get the filter
|
||||
* params from the Url
|
||||
* 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
|
||||
if (isset($_SERVER['QUERY_STRING'])) {
|
||||
$qr = $_SERVER['QUERY_STRING'];
|
||||
$parsed;
|
||||
parse_str($qr, $parsed);
|
||||
}
|
||||
foreach ($parsed as $k=>$v) {
|
||||
parse_str($v, $parsed[$k]);
|
||||
}
|
||||
$parsed = $this->parse();
|
||||
// dump($parsed);
|
||||
foreach ($parsed as $key => $value) {
|
||||
foreach ($value as $column => $filter) {
|
||||
|
|
@ -411,13 +462,11 @@ class DataGrid
|
|||
array_values($filter)[0]
|
||||
);
|
||||
} elseif ($column == "search") {
|
||||
$this->query->where(function ($query) use ($filter){
|
||||
$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),
|
||||
|
|
@ -428,15 +477,7 @@ class DataGrid
|
|||
}
|
||||
}
|
||||
} else {
|
||||
if (isset($_SERVER['QUERY_STRING'])) {
|
||||
$qr = $_SERVER['QUERY_STRING'];
|
||||
$parsed;
|
||||
parse_str($qr, $parsed);
|
||||
}
|
||||
|
||||
foreach ($parsed as $k=>$v) {
|
||||
parse_str($v, $parsed[$k]);
|
||||
}
|
||||
$parsed = $this->parse();
|
||||
foreach ($parsed as $key => $value) {
|
||||
foreach ($value as $column => $filter) {
|
||||
if (array_keys($filter)[0]=="like") {
|
||||
|
|
@ -445,6 +486,12 @@ class DataGrid
|
|||
$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,
|
||||
|
|
@ -459,11 +506,12 @@ class DataGrid
|
|||
|
||||
private function getDbQueryResults()
|
||||
{
|
||||
if (isset($_SERVER['QUERY_STRING'])) {
|
||||
$qr = $_SERVER['QUERY_STRING'];
|
||||
$parsed;
|
||||
parse_str($qr, $parsed);
|
||||
}
|
||||
// if (isset($_SERVER['QUERY_STRING'])) {
|
||||
// $qr = $_SERVER['QUERY_STRING'];
|
||||
// $parsed;
|
||||
// parse_str($qr, $parsed);
|
||||
// }
|
||||
$parsed = $this->parse();
|
||||
|
||||
|
||||
if ($this->aliased==true) {
|
||||
|
|
@ -561,11 +609,13 @@ class DataGrid
|
|||
$this->getQueryWithColumnFilters();
|
||||
|
||||
//Run this if there are filters or sort params or range params in the urls
|
||||
if (isset($_SERVER['QUERY_STRING'])) {
|
||||
$qr = $_SERVER['QUERY_STRING'];
|
||||
$parsed;
|
||||
parse_str($qr, $parsed);
|
||||
}
|
||||
// if (isset($_SERVER['QUERY_STRING'])) {
|
||||
// $qr = $_SERVER['QUERY_STRING'];
|
||||
// $parsed;
|
||||
// parse_str($qr, $parsed);
|
||||
// }
|
||||
$parsed = $this->parse();
|
||||
|
||||
if (!empty($parsed)) {
|
||||
$this->getQueryWithFilters();
|
||||
} else {
|
||||
|
|
@ -580,11 +630,12 @@ class DataGrid
|
|||
$this->getSelect();
|
||||
}
|
||||
$this->getQueryWithColumnFilters();
|
||||
if (isset($_SERVER['QUERY_STRING'])) {
|
||||
$qr = $_SERVER['QUERY_STRING'];
|
||||
$parsed;
|
||||
parse_str($qr, $parsed);
|
||||
}
|
||||
// if (isset($_SERVER['QUERY_STRING'])) {
|
||||
// $qr = $_SERVER['QUERY_STRING'];
|
||||
// $parsed;
|
||||
// parse_str($qr, $parsed);
|
||||
// }
|
||||
$parsed = $this->parse();
|
||||
if (!empty($parsed)) {
|
||||
$this->getQueryWithFilters();
|
||||
} else {
|
||||
|
|
@ -596,6 +647,19 @@ class DataGrid
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Render mass
|
||||
* action instance
|
||||
* @return view
|
||||
*/
|
||||
|
||||
private function renderMassAction(array $attributes)
|
||||
{
|
||||
|
||||
//probably render some view when mass action is needed
|
||||
//the rendered view will have the needed javascript also.
|
||||
}
|
||||
|
||||
/**
|
||||
* @return view
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
namespace Webkul\Ui\DataGrid\Helpers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class MassAction
|
||||
{
|
||||
public function validateSchemaMassAction($attributes)
|
||||
{
|
||||
$operations_validated = false;
|
||||
$columns_validated = true;
|
||||
foreach ($attributes['operations'] as $operation) {
|
||||
if (array_key_exists('route', $operation) && array_key_exists('method', $operation) && array_key_exists('label', $operation) && array_key_exists('columns', $operation)) {
|
||||
$operations_validated = true;
|
||||
}
|
||||
if ($operations_validated) {
|
||||
foreach ($operation['columns'] as $column) {
|
||||
if (array_key_exists('name', $operation) && array_key_exists('label', $operation) && array_key_exists('type', $operation)) {
|
||||
$columns_validated = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($columns_validated && $operations_validated) {
|
||||
return true;
|
||||
} else {
|
||||
throw new \Exception('Schema is invalid for mass actions');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="24px" height="24px" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<!-- Generator: Sketch 51 (57462) - http://www.bohemiancoding.com/sketch -->
|
||||
<title>Checkbox-Dash</title>
|
||||
<desc>Created with Sketch.</desc>
|
||||
<defs></defs>
|
||||
<g id="Checkbox-Dash" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<rect id="Base" stroke="#0041FF" stroke-width="2" fill="#FFFFFF" x="1" y="1" width="22" height="22" rx="2"></rect>
|
||||
<path d="M6,12 L17.215332,12" id="Path-8" stroke="#0041FF" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 721 B |
|
|
@ -600,20 +600,89 @@ h2 {
|
|||
.more-filters {
|
||||
margin-right: 5px;
|
||||
|
||||
.control {
|
||||
.dropdown-toggle {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-family: "montserrat", sans-serif;
|
||||
padding-left: 5px;
|
||||
height: 36px;
|
||||
width: 150px;
|
||||
border: 2px solid $control-border-color;
|
||||
border-radius: 3px;
|
||||
background-color: white;
|
||||
color: #8e8e8e;
|
||||
font-size: 14px;
|
||||
|
||||
.dropdown-header {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
|
||||
.arrow-down-icon {
|
||||
margin-right: 5px;
|
||||
}
|
||||
}
|
||||
}
|
||||
.dropdown-list {
|
||||
.dropdown-container {
|
||||
ul {
|
||||
li.filter-column-dropdown {
|
||||
.filter-column-select {
|
||||
background: #fff;
|
||||
border: 2px solid #c7c7c7;
|
||||
border-radius: 3px;
|
||||
height: 36px;
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
-webkit-transition: 0.2s
|
||||
cubic-bezier(0.4, 0, 0.2, 1);
|
||||
transition: 0.2s
|
||||
cubic-bezier(0.4, 0, 0.2, 1);
|
||||
padding: 0px 5px;
|
||||
font-family: "montserrat", sans-serif;
|
||||
margin-top: 10px;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
}
|
||||
li {
|
||||
select {
|
||||
background: #fff;
|
||||
border: 2px solid #c7c7c7;
|
||||
border-radius: 3px;
|
||||
height: 36px;
|
||||
max-width: 100%;
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
-webkit-transition: 0.2s
|
||||
cubic-bezier(0.4, 0, 0.2, 1);
|
||||
transition: 0.2s
|
||||
cubic-bezier(0.4, 0, 0.2, 1);
|
||||
padding: 0px 5px;
|
||||
font-family: "montserrat", sans-serif;
|
||||
margin-top: 10px;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
input {
|
||||
background: #fff;
|
||||
border: 2px solid #c7c7c7;
|
||||
border-radius: 3px;
|
||||
height: 36px;
|
||||
max-width: 100%;
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
-webkit-transition: 0.2s
|
||||
cubic-bezier(0.4, 0, 0.2, 1);
|
||||
transition: 0.2s
|
||||
cubic-bezier(0.4, 0, 0.2, 1);
|
||||
padding: 0px 5px;
|
||||
font-family: "montserrat", sans-serif;
|
||||
margin-top: 10px;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
}
|
||||
.filter-condition-dropdown-string {
|
||||
display: none;
|
||||
}
|
||||
|
|
@ -623,6 +692,7 @@ h2 {
|
|||
.filter-condition-dropdown-datetime {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.filter-response-string {
|
||||
display: none;
|
||||
}
|
||||
|
|
@ -645,8 +715,8 @@ h2 {
|
|||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
margin-top: 15px;
|
||||
margin-bottom: 15px;
|
||||
margin-top: 6px;
|
||||
margin-bottom: 6px;
|
||||
|
||||
.filter-one {
|
||||
margin-right: 10px;
|
||||
|
|
@ -674,6 +744,63 @@ h2 {
|
|||
}
|
||||
}
|
||||
}
|
||||
.table {
|
||||
.mass-action {
|
||||
display: none;
|
||||
padding-left: 10px;
|
||||
|
||||
.mass-action-block {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
|
||||
.mass-action-remove {
|
||||
margin-right: 15px;
|
||||
margin-top: 8px;
|
||||
}
|
||||
.mass-action-dropdown {
|
||||
height: 36px;
|
||||
padding-top: 4px;
|
||||
padding-bottom: 4px;
|
||||
min-width: 160px;
|
||||
max-width: 250px;
|
||||
|
||||
.dropdown-toggle {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-family: "montserrat", sans-serif;
|
||||
padding-left: 5px;
|
||||
height: 36px;
|
||||
width: 150px;
|
||||
border: 2px solid $control-border-color;
|
||||
background-color: white;
|
||||
color: #8e8e8e;
|
||||
font-size: 14px;
|
||||
|
||||
.dropdown-header {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
|
||||
.arrow-down-icon {
|
||||
margin-right: 5px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.dropdown-list {
|
||||
margin-top: 10px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* DataGrid css ends in here */
|
||||
|
|
|
|||
|
|
@ -116,6 +116,12 @@
|
|||
height: 24px;
|
||||
}
|
||||
|
||||
.checkbox-dash-icon {
|
||||
background-image: url("../images/Checkbox-Dash.svg");
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
}
|
||||
|
||||
.active {
|
||||
.dashboard-icon {
|
||||
background-image: url("../images/Icon-Dashboard-Active.svg");
|
||||
|
|
|
|||
|
|
@ -0,0 +1,123 @@
|
|||
<div class="{{ $css->filter }}filter-wrapper">
|
||||
{{-- for loading the filters from another file --}}
|
||||
<div class="filter-row-one">
|
||||
<div class="search-filter" style="display: inline-flex; align-items: center;">
|
||||
<input type="search" class="control search-field" placeholder="Search Users" value="" />
|
||||
<div class="ic-wrapper">
|
||||
<span class="icon search-icon search-btn"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="dropdown-filters">
|
||||
<div class="column-filter">
|
||||
{{--
|
||||
<div class="dropdown-toggle">
|
||||
<div style="display: inline-block; vertical-align: middle;">
|
||||
<span class="name">Columns</span>
|
||||
</div>
|
||||
<i class="icon arrow-down-icon active"></i>
|
||||
</div> --}}
|
||||
<div class="dropdown-list bottom-right" style="display: none;">
|
||||
<div class="dropdown-container">
|
||||
<ul>
|
||||
@foreach($columns as $column)
|
||||
<li data-name="{{ $column->name }}">
|
||||
{{ $column->label }}
|
||||
<span class="checkbox"><input type="checkbox" id="{{ $column->id }}" name="checkbox1[]"> <label for="checkbox1" class="checkbox-view"></label></span>
|
||||
</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="more-filters">
|
||||
<div class="dropdown-toggle">
|
||||
<div class="dropdown-header">
|
||||
<span class="name">Filter</span> {{-- <span class="role">Filter</span> --}}
|
||||
<i class="icon arrow-down-icon active"></i>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="dropdown-list bottom-right" style="display: none;">
|
||||
<div class="dropdown-container">
|
||||
<ul>
|
||||
<li class="filter-column-dropdown">
|
||||
<select class="filter-column-select">
|
||||
<option selected disabled>Select Column</option>
|
||||
@foreach($filterable as $fcol)
|
||||
<option value="{{ $fcol['column'] }}" data-type="{{ $fcol['type'] }}">{{ $fcol['label'] }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</li>
|
||||
{{-- suitable for string columns --}}
|
||||
<li class="filter-condition-dropdown-string">
|
||||
<select class="control filter-condition-select-string">
|
||||
<option selected disabled>Select Condition</option>
|
||||
<option value="like">Contains</option>
|
||||
<option value="nlike">Does not contains</option>
|
||||
<option value="eq">Is equal to</option>
|
||||
<option value="neqs">Is not equal to</option>
|
||||
</select>
|
||||
</li>
|
||||
{{-- suitable for numeric columns --}}
|
||||
<li class="filter-condition-dropdown-number">
|
||||
<select class="control filter-condition-select-number">
|
||||
<option selected disabled>Select Condition</option>
|
||||
<option value="eq">Is equal to</option>
|
||||
<option value="neqs">Is not equal to</option>
|
||||
<option value="gt">Greater than</option>
|
||||
<option value="lt">Less than</option>
|
||||
<option value="gte">Greater than equals to</option>
|
||||
<option value="lte">Less than equals to</option>
|
||||
</select>
|
||||
</li>
|
||||
{{-- suitable for date/time columns --}}
|
||||
<li class="filter-condition-dropdown-datetime">
|
||||
<select class="control filter-condition-select-datetime">
|
||||
<option selected disabled>Select Condition</option>
|
||||
<option value="eq">Is equal to</option>
|
||||
<option value="neqs">Is not equal to</option>
|
||||
<option value="gt">Greater than</option>
|
||||
<option value="lt">Less than</option>
|
||||
<option value="gte">Greater than equals to</option>
|
||||
<option value="lte">Less than equals to</option>
|
||||
{{-- <option value="btw">Is Between</option> --}}
|
||||
</select>
|
||||
</li>
|
||||
{{-- Response fields based on the type of columns to be filtered --}}
|
||||
<li class="filter-response-string">
|
||||
<input type="text" class="control response-string" placeholder="Value here" />
|
||||
</li>
|
||||
<li class="filter-response-boolean">
|
||||
<select class="control select-boolean">
|
||||
<option value="true">Is True</option>
|
||||
<option value="false">Is False</option>
|
||||
</select>
|
||||
</li>
|
||||
<li class="filter-response-datetime">
|
||||
<input type="datetime-local" class="control response-datetime" placeholder="Value here" />
|
||||
</li>
|
||||
<li class="filter-response-number">
|
||||
<input type="text" class="control response-number" placeholder="Value here" />
|
||||
</li>
|
||||
<li>
|
||||
<button class="btn btn-sm btn-primary apply-filter">Apply</button>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="filter-row-two">
|
||||
{{-- <span class="filter-one">
|
||||
<span class="filter-name">
|
||||
Stock
|
||||
</span>
|
||||
<span class="filter-value">
|
||||
Available
|
||||
<span class="icon cross-icon"></span>
|
||||
</span>
|
||||
</span> --}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
@ -1,160 +1,12 @@
|
|||
<div class="grid-container{{-- $css->datagrid --}}">
|
||||
<div class="{{ $css->filter }}filter-wrapper">
|
||||
<div class="filter-row-one">
|
||||
<div class="search-filter" style="display: inline-flex; align-items: center;">
|
||||
<input type="search" class="control search-field" placeholder="Search Users" value=""/>
|
||||
<div class="ic-wrapper">
|
||||
<span class="icon search-icon search-btn"></span>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="dropdown-filters">
|
||||
<div class="column-filter">
|
||||
{{-- <div class="dropdown-toggle">
|
||||
<div style="display: inline-block; vertical-align: middle;">
|
||||
<span class="name">Columns</span>
|
||||
</div>
|
||||
<i class="icon arrow-down-icon active"></i>
|
||||
</div> --}}
|
||||
<div class="dropdown-list bottom-right" style="display: none;">
|
||||
<div class="dropdown-container">
|
||||
<ul>
|
||||
@foreach($columns as $column)
|
||||
<li data-name="{{ $column->name }}">
|
||||
{{ $column->label }}
|
||||
<span class="checkbox"><input type="checkbox" id="{{ $column->id }}" name="checkbox1[]"> <label for="checkbox1" class="checkbox-view"></label></span>
|
||||
</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="more-filters">
|
||||
<div class="dropdown-toggle">
|
||||
<div style="display: inline-block; vertical-align: middle;">
|
||||
<span class="name">Filter</span>
|
||||
{{-- <span class="role">Filter</span> --}}
|
||||
</div>
|
||||
<i class="icon arrow-down-icon active"></i>
|
||||
</div>
|
||||
<div class="dropdown-list bottom-right" style="display: none;">
|
||||
<div class="dropdown-container">
|
||||
<ul>
|
||||
<li class="filter-column-dropdown">
|
||||
<select class="control filter-column-select">
|
||||
<option selected disabled>Select Column</option>
|
||||
@foreach($filterable as $fcol)
|
||||
<option value="{{ $fcol['column'] }}" data-type="{{ $fcol['type'] }}">{{ $fcol['label'] }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</li>
|
||||
{{-- suitable for string columns --}}
|
||||
<li class="filter-condition-dropdown-string">
|
||||
<select class="control filter-condition-select-string">
|
||||
<option selected disabled>Select Condition</option>
|
||||
<option value="like">Contains</option>
|
||||
<option value="nlike">Does not contains</option>
|
||||
<option value="eq">Is equal to</option>
|
||||
<option value="neqs">Is not equal to</option>
|
||||
</select>
|
||||
</li>
|
||||
{{-- suitable for numeric columns --}}
|
||||
<li class="filter-condition-dropdown-number">
|
||||
<select class="control filter-condition-select-number">
|
||||
<option selected disabled>Select Condition</option>
|
||||
<option value="eq">Is equal to</option>
|
||||
<option value="neqs">Is not equal to</option>
|
||||
<option value="gt">Greater than</option>
|
||||
<option value="lt">Less than</option>
|
||||
<option value="gte">Greater than equals to</option>
|
||||
<option value="lte">Less than equals to</option>
|
||||
</select>
|
||||
</li>
|
||||
{{-- suitable for date/time columns --}}
|
||||
<li class="filter-condition-dropdown-datetime">
|
||||
<select class="control filter-condition-select-datetime">
|
||||
<option selected disabled>Select Condition</option>
|
||||
<option value="eq">Is equal to</option>
|
||||
<option value="neqs">Is not equal to</option>
|
||||
<option value="gt">Greater than</option>
|
||||
<option value="lt">Less than</option>
|
||||
<option value="gte">Greater than equals to</option>
|
||||
<option value="lte">Less than equals to</option>
|
||||
<option value="btw">Is Between</option>
|
||||
</select>
|
||||
</li>
|
||||
{{-- Response fields based on the type of columns to be filtered --}}
|
||||
<li class="filter-response-string">
|
||||
<input type="text" class="control response-string" placeholder="Value here" />
|
||||
</li>
|
||||
<li class="filter-response-boolean">
|
||||
<select class="control select-boolean">
|
||||
<option value="true">Is True</option>
|
||||
<option value="false">Is False</option>
|
||||
</select>
|
||||
</li>
|
||||
<li class="filter-response-datetime">
|
||||
<input type="datetime-local" class="control response-datetime" placeholder="Value here" />
|
||||
</li>
|
||||
<li class="filter-response-number">
|
||||
<input type="text" class="control response-number" placeholder="Value here" />
|
||||
</li>
|
||||
<li>
|
||||
<button class="btn btn-sm btn-primary apply-filter">Apply</button>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="filter-row-two">
|
||||
{{-- <span class="filter-one">
|
||||
<span class="filter-name">
|
||||
Stock
|
||||
</span>
|
||||
<span class="filter-value">
|
||||
Available
|
||||
<span class="icon cross-icon"></span>
|
||||
</span>
|
||||
</span> --}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="table">
|
||||
<table class="{{ $css->table }}">
|
||||
<thead class="{{-- $css->thead --}}">
|
||||
<tr>
|
||||
<th class="{{-- $css->thead_td --}}">Mass Action</th>
|
||||
@foreach ($columns as $column)
|
||||
{{-- {{ dd($column->sortable) }} --}}
|
||||
@if($column->sortable == "true")
|
||||
<th class="$css->thead_td grid_head" data-column-name ={{ $column->name }} data-column-sort="asc">{!! $column->sorting() !!}<span class="icon sort-down-icon"></span></th>
|
||||
@else
|
||||
<th class="$css->thead_td grid_head">{!! $column->sorting() !!}</th>
|
||||
@endif
|
||||
@endforeach
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="{{ $css->tbody }}">
|
||||
{{-- For loading the filters from includes directory file --}}
|
||||
@include('ui::datagrid.filters.default')
|
||||
|
||||
@foreach ($results as $result)
|
||||
<tr>
|
||||
<td class="{{-- $css->tbody_td --}}">
|
||||
<span class="checkbox">
|
||||
<input type="checkbox" id="{{ $result->id }}" name="checkbox[]">
|
||||
<label class="checkbox-view" for="checkbox1"></label>
|
||||
</span>
|
||||
</td>
|
||||
{{-- for generating the table and its content --}}
|
||||
@include('ui::datagrid.table.default')
|
||||
|
||||
@foreach ($columns as $column)
|
||||
<td class="{{-- $css->tbody_td --}}">{!! $column->render($result) !!}</td>
|
||||
@endforeach
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
{{-- @include('ui::partials.pagination') --}}
|
||||
</div>
|
||||
{{-- Section for datagrid javascript --}}
|
||||
@section('javascript')
|
||||
<script type="text/javascript">
|
||||
var allFilters1 = [];
|
||||
|
|
@ -255,7 +107,6 @@
|
|||
}
|
||||
|
||||
$('.apply-filter').on('click',function(){
|
||||
|
||||
params = (new URL(document.location)).search;
|
||||
if(typeValue == 'number'){
|
||||
var conditionUsed = $('.filter-condition-dropdown-number').find(':selected').val();
|
||||
|
|
@ -279,7 +130,7 @@
|
|||
});
|
||||
|
||||
});
|
||||
|
||||
//remove the filter and from clicking on cross icon on tag
|
||||
$('.remove-filter').on('click', function(){
|
||||
// console.log('removing');
|
||||
var id = $(this).parents('.filter-one').attr('id');
|
||||
|
|
@ -299,8 +150,45 @@
|
|||
makeURL(allFilters1);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
//Enable Mass Action Subsequency
|
||||
var id=[]; //for getting the id of the selected fields
|
||||
var y = parseInt(0);
|
||||
$("input[type=checkbox]").change(function() {
|
||||
if(this.checked){
|
||||
y = parseInt($(this).attr('id'));
|
||||
id.push(y);
|
||||
console.log(id);
|
||||
}
|
||||
else {
|
||||
y = parseInt($(this).attr('id'));
|
||||
var index = id.indexOf(y);
|
||||
id.splice(index,1);
|
||||
}
|
||||
if(id.length>0){
|
||||
$('.mass-action').css('display','inherit');
|
||||
$('.table-grid-header').css('display','none');
|
||||
}else if(id.length == 0){
|
||||
$('.mass-action').css('display','none');
|
||||
$('.table-grid-header').css('display','table-header-group');
|
||||
}
|
||||
});
|
||||
|
||||
//remove the mass action by clicking on the icon
|
||||
$('.mass-action-remove').on('click', function(){
|
||||
$("input[type=checkbox]").prop('checked',false);
|
||||
id = [];
|
||||
$('.mass-action').css('display','none'); $('.table-grid-header').css('display','table-header-group');
|
||||
});
|
||||
// $('.mass-delete').on('click',function(){
|
||||
// if(id.length>0){
|
||||
// url = 'datagrid/delete';
|
||||
// $.ajax({ type: "POST", url: url, data: id, success: function(result){
|
||||
// console.log(result);
|
||||
// } });
|
||||
// }
|
||||
// });
|
||||
});
|
||||
//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){
|
||||
|
|
@ -463,4 +351,5 @@
|
|||
}
|
||||
</script>
|
||||
@endsection
|
||||
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,67 @@
|
|||
<div class="table">
|
||||
<table class="{{ $css->table }}">
|
||||
<thead class="{{-- $css->thead --}} table-grid-header">
|
||||
<tr>
|
||||
<th class="{{-- $css->thead_td --}}">Mass Action</th>
|
||||
@foreach ($columns as $column) {{-- {{ dd($column->sortable) }} --}} @if($column->sortable == "true")
|
||||
<th class="$css->thead_td grid_head" data-column-name={{ $column->name }} data-column-sort="asc">{!! $column->sorting() !!}<span class="icon sort-down-icon"></span></th>
|
||||
@else
|
||||
<th class="$css->thead_td grid_head">{!! $column->sorting() !!}</th>
|
||||
@endif @endforeach
|
||||
</tr>
|
||||
</thead>
|
||||
<div class="mass-action">
|
||||
<div class="mass-action-block">
|
||||
<span class="icon checkbox-dash-icon mass-action-remove"></span>
|
||||
<div class="mass-action-dropdown">
|
||||
{{-- <select class="control">
|
||||
<option value="x">A</option>
|
||||
<option value="y">B</option>
|
||||
<option value="z">C</option>
|
||||
</select> --}}
|
||||
<div class="dropdown-toggle">
|
||||
<div class="dropdown-header">
|
||||
<span class="name">Actions</span> {{-- <span class="role">Filter</span> --}}
|
||||
<i class="icon arrow-down-icon active"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div class="dropdown-list bottom-left" style="display: none;">
|
||||
<div class="dropdown-container">
|
||||
<ul>
|
||||
{{-- <li class="mass-delete">Delete  <span class="btn btn-primary btn-sm">Apply</span></li> --}}
|
||||
<li>
|
||||
<form action="{{ route('admin.datagrid.delete') }}" method="post">
|
||||
{{ csrf_field() }}
|
||||
<input type="hidden" id="indexes" value="">
|
||||
<input type="Submit" class="btn btn-primary btn-sm">
|
||||
</form>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<tbody class="{{ $css->tbody }}">
|
||||
|
||||
@foreach ($results as $result)
|
||||
<tr>
|
||||
<td class="{{-- $css->tbody_td --}}">
|
||||
<span class="checkbox">
|
||||
<input type="checkbox" id="{{ $result->id }}" name="checkbox[]">
|
||||
<label class="checkbox-view" for="checkbox1"></label>
|
||||
</span>
|
||||
</td>
|
||||
|
||||
@foreach ($columns as $column)
|
||||
<td class="{{-- $css->tbody_td --}}">{!! $column->render($result) !!}</td>
|
||||
@endforeach
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
{{--
|
||||
@include('ui::partials.pagination') --}}
|
||||
</div>
|
||||
Loading…
Reference in New Issue