Before Merge

This commit is contained in:
prashant-webkul 2018-10-17 12:30:48 +05:30
parent ddc57abdfa
commit c05ea63603
4 changed files with 181 additions and 6 deletions

View File

@ -0,0 +1,180 @@
<?php
namespace Webkul\Admin\DataGrids;
use Illuminate\View\View;
use Webkul\Ui\DataGrid\Facades\DataGrid;
/**
* Order DataGrid
*
* @author Prashant Singh <prashant.singh852@webkul.com> @prashant-webkul
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/
class OrderDataGrid
{
/**
* The Data Grid implementation.
*
* @var AttributeDataGrid
* for countries
*/
public function createCategoryDataGrid()
{
return DataGrid::make([
'name' => 'Categories',
'table' => 'categories as cat',
'select' => 'cat.id',
'perpage' => 10,
'aliased' => true, //use this with false as default and true in case of joins
'massoperations' =>[
[
'route' => route('admin.datagrid.delete'),
'method' => 'DELETE',
'label' => 'Delete',
'type' => 'button',
],
],
'actions' => [
[
'type' => 'Edit',
'route' => route('admin.datagrid.delete'),
'confirm_text' => 'Do you really want to do this?',
'icon' => 'icon pencil-lg-icon',
], [
'type' => 'Delete',
'route' => route('admin.datagrid.delete'),
'confirm_text' => 'Do you really want to do this?',
'icon' => 'icon trash-icon',
],
],
'join' => [
[
'join' => 'leftjoin',
'table' => 'category_translations as ct',
'primaryKey' => 'cat.id',
'condition' => '=',
'secondaryKey' => 'ct.category_id',
], [
'join' => 'leftjoin',
'table' => 'category_translations as cta',
'primaryKey' => 'cat.parent_id',
'condition' => '=',
'secondaryKey' => 'cta.category_id',
],
],
//use aliasing on secodary columns if join is performed
'columns' => [
[
'name' => 'cat.id',
'alias' => 'catID',
'type' => 'number',
'label' => 'Category ID',
'sortable' => true,
], [
'name' => 'ct.name',
'alias' => 'catName',
'type' => 'string',
'label' => 'Category Name',
'sortable' => false,
], [
'name' => 'cat.position',
'alias' => 'catPosition',
'type' => 'string',
'label' => 'Category Position',
'sortable' => false,
], [
'name' => 'cta.name',
'alias' => 'parentName',
'type' => 'string',
'label' => 'Parent Name',
'sortable' => true,
], [
'name' => 'cat.status',
'alias' => 'catStatus',
'type' => 'string',
'label' => 'Visible in Menu',
'sortable' => true,
'wrapper' => function ($value) {
if($value == 0)
return "False";
else
return "True";
},
],
],
'filterable' => [
[
'column' => 'cat.id',
'alias' => 'catID',
'type' => 'number',
'label' => 'Category ID',
], [
'column' => 'ct.name',
'alias' => 'catName',
'type' => 'string',
'label' => 'Category Name',
], [
'column' => 'cta.name',
'alias' => 'parentName',
'type' => 'string',
'label' => 'Parent Name',
], [
'column' => 'cat.status',
'alias' => 'catStatus',
'type' => 'string',
'label' => 'Visible in Menu',
],
],
//don't use aliasing in case of searchables
'searchable' => [
[
'column' => 'cat.id',
'type' => 'number',
'label' => 'Category ID',
], [
'column' => 'ct.name',
'type' => 'string',
'label' => 'Category Name',
], [
'column' => 'cat.status',
'type' => 'string',
'label' => 'Visible in Menu',
]
],
//list of viable operators that will be used
'operators' => [
'eq' => "=",
'lt' => "<",
'gt' => ">",
'lte' => "<=",
'gte' => ">=",
'neqs' => "<>",
'neqn' => "!=",
'like' => "like",
'nlike' => "not like",
],
// 'css' => []
]);
}
public function render()
{
return $this->createCategoryDataGrid()->render();
}
}

View File

@ -15,8 +15,6 @@
background-image:URL('../images/icon-menu-close.svg');
width: 24px;
height: 24px;
margin-left:auto;
margin-bottom: 2px;
}
.grid-view-icon {

View File

@ -689,7 +689,6 @@ class DataGrid
$parsed = $this->parse();
if ($this->aliased==true) {
//flags
$table_alias = false;
$join_table_alias = false;
@ -710,7 +709,7 @@ class DataGrid
//check whether exploded string still has same table name
if ($exploded[0]==$this->table) {
$table_alias = false;
} else { // (isset($exploded))
} else {
$table_alias = true;
$table_name = trim($exploded[0]);
$table_alias = trim($exploded[1]);

View File

@ -15,8 +15,6 @@
background-image: URL("../images/icon-menu-close.svg");
width: 24px;
height: 24px;
margin-left: auto;
margin-bottom: 2px;
}
.grid-view-icon {