From c05ea636039531aa9cfae34b381a074ffdea9544 Mon Sep 17 00:00:00 2001 From: prashant-webkul Date: Wed, 17 Oct 2018 12:30:48 +0530 Subject: [PATCH] Before Merge --- .../Admin/src/DataGrids/OrderDataGrid.php | 180 ++++++++++++++++++ .../Shop/src/Resources/assets/sass/icons.scss | 2 - packages/Webkul/Ui/src/DataGrid/DataGrid.php | 3 +- public/themes/default/assets/css/shop.css | 2 - 4 files changed, 181 insertions(+), 6 deletions(-) create mode 100644 packages/Webkul/Admin/src/DataGrids/OrderDataGrid.php diff --git a/packages/Webkul/Admin/src/DataGrids/OrderDataGrid.php b/packages/Webkul/Admin/src/DataGrids/OrderDataGrid.php new file mode 100644 index 000000000..18868b4ea --- /dev/null +++ b/packages/Webkul/Admin/src/DataGrids/OrderDataGrid.php @@ -0,0 +1,180 @@ + @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(); + + } +} \ No newline at end of file diff --git a/packages/Webkul/Shop/src/Resources/assets/sass/icons.scss b/packages/Webkul/Shop/src/Resources/assets/sass/icons.scss index b0eacb07b..fdac4be74 100644 --- a/packages/Webkul/Shop/src/Resources/assets/sass/icons.scss +++ b/packages/Webkul/Shop/src/Resources/assets/sass/icons.scss @@ -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 { diff --git a/packages/Webkul/Ui/src/DataGrid/DataGrid.php b/packages/Webkul/Ui/src/DataGrid/DataGrid.php index c61c7c5aa..9cc49cabd 100644 --- a/packages/Webkul/Ui/src/DataGrid/DataGrid.php +++ b/packages/Webkul/Ui/src/DataGrid/DataGrid.php @@ -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]); diff --git a/public/themes/default/assets/css/shop.css b/public/themes/default/assets/css/shop.css index e0ddf3162..ffa85e69f 100644 --- a/public/themes/default/assets/css/shop.css +++ b/public/themes/default/assets/css/shop.css @@ -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 {