From eb373d7ecbffd2fb4dec5864d48831fc83bc2865 Mon Sep 17 00:00:00 2001 From: Prashant Singh Date: Thu, 17 Jan 2019 15:24:58 +0530 Subject: [PATCH] More changes in datagrid, regarding implementation of wrapper columns --- README.md | 12 +- .../Admin/src/DataGrids/AttributeDataGrid.php | 12 +- .../src/DataGrids/AttributeFamilyDataGrid.php | 18 -- .../Admin/src/DataGrids/CategoryDataGrid.php | 24 ++- .../Admin/src/DataGrids/CustomerDataGrid.php | 34 +--- .../src/DataGrids/CustomerReviewDataGrid.php | 21 ++- .../src/DataGrids/ExchangeRatesDataGrid.php | 30 +--- .../DataGrids/InventorySourcesDataGrid.php | 2 +- .../src/DataGrids/NewsLetterDataGrid.php | 4 +- .../Admin/src/DataGrids/OrderDataGrid.php | 31 +--- .../src/DataGrids/OrderInvoicesDataGrid.php | 11 +- .../src/DataGrids/OrderShipmentsDataGrid.php | 22 ++- .../Admin/src/DataGrids/ProductDataGrid.php | 26 ++- .../Admin/src/DataGrids/SliderDataGrid.php | 29 +-- .../Admin/src/DataGrids/UserDataGrid.php | 34 +--- .../src/Providers/EventServiceProvider.php | 2 +- .../Http/Controllers/AttributeController.php | 2 +- packages/Webkul/Ui/src/DataGrid/DataGrid.php | 2 +- .../Ui/src/DataGrid/Facades/ProductGrid.php | 18 -- .../src/DataGrid/Helpers/AbstractFillable.php | 108 ----------- .../Webkul/Ui/src/DataGrid/Helpers/Column.php | 169 ------------------ .../Webkul/Ui/src/DataGrid/Helpers/Css.php | 36 ---- .../Ui/src/DataGrid/Helpers/MassAction.php | 36 ---- .../Ui/src/DataGrid/Helpers/Pagination.php | 37 ---- .../Resources/views/datagrid/body.blade.php | 6 +- .../Resources/views/datagrid/head.blade.php | 14 -- .../Resources/views/datagrid/table.blade.php | 12 +- 27 files changed, 104 insertions(+), 648 deletions(-) delete mode 100755 packages/Webkul/Ui/src/DataGrid/Facades/ProductGrid.php delete mode 100755 packages/Webkul/Ui/src/DataGrid/Helpers/AbstractFillable.php delete mode 100755 packages/Webkul/Ui/src/DataGrid/Helpers/Column.php delete mode 100755 packages/Webkul/Ui/src/DataGrid/Helpers/Css.php delete mode 100755 packages/Webkul/Ui/src/DataGrid/Helpers/MassAction.php delete mode 100755 packages/Webkul/Ui/src/DataGrid/Helpers/Pagination.php delete mode 100644 packages/Webkul/Ui/src/Resources/views/datagrid/head.blade.php diff --git a/README.md b/README.md index 05e7dc95e..9a1651d96 100755 --- a/README.md +++ b/README.md @@ -132,20 +132,20 @@ Bagisto is a truly opensource E-Commerce framework which will always be free und ### 6. Miscellaneous : -## Contributors +#### Contributors This project exists thanks to all the people who contribute. -## Backers +#### Backers Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/bagisto#backer)] -## Sponsors +#### Sponsors Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/bagisto#sponsor)] @@ -158,8 +158,4 @@ Support this project by becoming a sponsor. Your logo will show up here with a l - - - -### Coming Soon: --> API support for core packages and numerous fixes. + \ No newline at end of file diff --git a/packages/Webkul/Admin/src/DataGrids/AttributeDataGrid.php b/packages/Webkul/Admin/src/DataGrids/AttributeDataGrid.php index 8fa4f484c..9875ed3f1 100755 --- a/packages/Webkul/Admin/src/DataGrids/AttributeDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/AttributeDataGrid.php @@ -20,7 +20,9 @@ class AttributeDataGrid extends DataGrid public function prepareQueryBuilder() { - $queryBuilder = DB::table('attributes')->select('id')->addSelect('id', 'code', 'admin_name', 'type', 'is_required', 'is_unique', 'value_per_locale', 'value_per_channel'); + $queryBuilder = DB::table('attributes') + ->select('id') + ->addSelect('id', 'code', 'admin_name', 'type', 'is_required', 'is_unique', 'value_per_locale', 'value_per_channel'); $this->setQueryBuilder($queryBuilder); } @@ -71,7 +73,7 @@ class AttributeDataGrid extends DataGrid 'searchable' => false, 'width' => '100px', 'wrapper' => function($value) { - if ($value == 1) + if ($value->is_required == 1) return 'True'; else return 'False'; @@ -86,7 +88,7 @@ class AttributeDataGrid extends DataGrid 'searchable' => false, 'width' => '100px', 'wrapper' => function($value) { - if ($value == 1) + if ($value->is_unique == 1) return 'True'; else return 'False'; @@ -101,7 +103,7 @@ class AttributeDataGrid extends DataGrid 'searchable' => false, 'width' => '100px', 'wrapper' => function($value) { - if ($value == 1) + if ($value->value_per_locale == 1) return 'True'; else return 'False'; @@ -116,7 +118,7 @@ class AttributeDataGrid extends DataGrid 'searchable' => false, 'width' => '100px', 'wrapper' => function($value) { - if ($value == 1) + if ($value->value_per_channel == 1) return 'True'; else return 'False'; diff --git a/packages/Webkul/Admin/src/DataGrids/AttributeFamilyDataGrid.php b/packages/Webkul/Admin/src/DataGrids/AttributeFamilyDataGrid.php index 7077cef41..b531b1bd6 100755 --- a/packages/Webkul/Admin/src/DataGrids/AttributeFamilyDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/AttributeFamilyDataGrid.php @@ -68,22 +68,4 @@ class AttributeFamilyDataGrid extends DataGrid 'icon' => 'icon trash-icon' ]); } - - // public function prepareMassActions() { - // // $this->prepareMassAction([ - // // 'type' => 'delete', - // // 'action' => route('admin.catalog.familites.massdelete'), - // // 'method' => 'DELETE' - // // ]); - - // // $this->prepareMassAction([ - // // 'type' => 'update', - // // 'action' => route('admin.catalog.familites.massupdate'), - // // 'method' => 'PUT', - // // 'options' => [ - // // 0 => true, - // // 1 => false, - // // ] - // // ]); - // } } \ No newline at end of file diff --git a/packages/Webkul/Admin/src/DataGrids/CategoryDataGrid.php b/packages/Webkul/Admin/src/DataGrids/CategoryDataGrid.php index dd263d2e9..7d8263c98 100755 --- a/packages/Webkul/Admin/src/DataGrids/CategoryDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/CategoryDataGrid.php @@ -17,13 +17,11 @@ class CategoryDataGrid extends DataGrid public function prepareQueryBuilder() { - $queryBuilder = DB::table('categories as cat')->select('cat.id as category_id', 'ct.name as category_name', 'cat.position as category_position', 'cat.status as category_status', 'ct.locale as category_locale')->leftJoin('category_translations as ct', 'cat.id', '=', 'ct.category_id'); + $queryBuilder = DB::table('categories as cat') + ->select('cat.id as category_id', 'ct.name', 'cat.position', 'cat.status', 'ct.locale') + ->leftJoin('category_translations as ct', 'cat.id', '=', 'ct.category_id'); - $this->addFilters('category_id', 'custs.id'); - $this->addFilters('category_name', 'ct.name'); - $this->addFilters('category_position', 'cat.position'); - $this->addFilters('category_status', 'cat.status'); - $this->addFilters('category_locale', 'ct.locale'); + $this->addFilter('category_id', 'cat.id'); $this->setQueryBuilder($queryBuilder); } @@ -40,7 +38,7 @@ class CategoryDataGrid extends DataGrid ]); $this->addColumn([ - 'index' => 'category_name', + 'index' => 'name', 'label' => trans('admin::app.datagrid.name'), 'type' => 'string', 'searchable' => true, @@ -49,23 +47,23 @@ class CategoryDataGrid extends DataGrid ]); $this->addColumn([ - 'index' => 'category_position', + 'index' => 'position', 'label' => trans('admin::app.datagrid.position'), 'type' => 'string', - 'searchable' => true, + 'searchable' => false, 'sortable' => true, 'width' => '100px' ]); $this->addColumn([ - 'index' => 'category_status', + 'index' => 'status', 'label' => trans('admin::app.datagrid.status'), 'type' => 'boolean', 'sortable' => true, 'searchable' => true, 'width' => '100px', 'wrapper' => function($value) { - if ($value == 1) + if ($value->status == 1) return 'Active'; else return 'Inactive'; @@ -73,11 +71,11 @@ class CategoryDataGrid extends DataGrid ]); $this->addColumn([ - 'index' => 'category_locale', + 'index' => 'locale', 'label' => trans('admin::app.datagrid.locale'), 'type' => 'boolean', 'sortable' => true, - 'searchable' => false, + 'searchable' => true, 'width' => '100px' ]); } diff --git a/packages/Webkul/Admin/src/DataGrids/CustomerDataGrid.php b/packages/Webkul/Admin/src/DataGrids/CustomerDataGrid.php index 5e4423cba..919959b32 100755 --- a/packages/Webkul/Admin/src/DataGrids/CustomerDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/CustomerDataGrid.php @@ -19,12 +19,12 @@ class CustomerDataGrid extends DataGrid public function prepareQueryBuilder() { - $queryBuilder = DB::table('customers as custs')->addSelect('custs.id as customer_id', 'custs.email as customer_email', 'cg.name as cust_grp_name')->addSelect(DB::raw('CONCAT(custs.first_name, " ", custs.last_name) as full_name'))->leftJoin('customer_groups as cg', 'custs.customer_group_id', '=', 'cg.id'); + $queryBuilder = DB::table('customers as custs') + ->addSelect('custs.id as customer_id', 'custs.email', 'cg.name') + ->addSelect(DB::raw('CONCAT(custs.first_name, " ", custs.last_name) as full_name'))->leftJoin('customer_groups as cg', 'custs.customer_group_id', '=', 'cg.id'); - $this->addFilters('customer_id', 'custs.id'); - $this->addFilters('customer_email', 'custs.email'); - $this->addFilters('cust_grp_name', 'cg.name'); - $this->addFilters('full_name', DB::raw('CONCAT(custs.first_name, " ", custs.last_name)')); + $this->addFilter('customer_id', 'custs.id'); + $this->addFilter('full_name', DB::raw('CONCAT(custs.first_name, " ", custs.last_name)')); $this->setQueryBuilder($queryBuilder); } @@ -35,7 +35,7 @@ class CustomerDataGrid extends DataGrid 'index' => 'customer_id', 'label' => trans('admin::app.datagrid.id'), 'type' => 'number', - 'searchable' => true, + 'searchable' => false, 'sortable' => true, 'width' => '40px' ]); @@ -50,7 +50,7 @@ class CustomerDataGrid extends DataGrid ]); $this->addColumn([ - 'index' => 'customer_email', + 'index' => 'email', 'label' => trans('admin::app.datagrid.email'), 'type' => 'string', 'searchable' => true, @@ -59,7 +59,7 @@ class CustomerDataGrid extends DataGrid ]); $this->addColumn([ - 'index' => 'cust_grp_name', + 'index' => 'name', 'label' => trans('admin::app.datagrid.group'), 'type' => 'string', 'searchable' => false, @@ -81,22 +81,4 @@ class CustomerDataGrid extends DataGrid 'icon' => 'icon trash-icon' ]); } - - public function prepareMassActions() { - // $this->prepareMassAction([ - // 'type' => 'delete', - // 'action' => route('admin.catalog.products.massdelete'), - // 'method' => 'DELETE' - // ]); - - // $this->prepareMassAction([ - // 'type' => 'update', - // 'action' => route('admin.catalog.products.massupdate'), - // 'method' => 'PUT', - // 'options' => [ - // 0 => true, - // 1 => false, - // ] - // ]); - } } \ No newline at end of file diff --git a/packages/Webkul/Admin/src/DataGrids/CustomerReviewDataGrid.php b/packages/Webkul/Admin/src/DataGrids/CustomerReviewDataGrid.php index 7e83e179c..021d1da99 100755 --- a/packages/Webkul/Admin/src/DataGrids/CustomerReviewDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/CustomerReviewDataGrid.php @@ -17,13 +17,12 @@ class CustomerReviewDataGrid extends DataGrid public function prepareQueryBuilder() { - $queryBuilder = DB::table('product_reviews as pr')->addSelect('pr.id as product_review_id', 'pr.title as product_review_title', 'pr.comment as product_review_comment', 'pg.name as product_name', 'pr.status as product_review_status')->leftjoin('products_grid as pg', 'pr.product_id', '=', 'pg.id'); + $queryBuilder = DB::table('product_reviews as pr') + ->leftjoin('products_grid as pg', 'pr.product_id', '=', 'pg.id') + ->addSelect('pr.id as product_review_id', 'pr.title', 'pr.comment', 'pg.name', 'pr.status as product_review_status'); - $this->addFilters('product_review_id', 'pr.id'); - $this->addFilters('product_review_title', 'pr.title'); - $this->addFilters('product_review_comment', 'pr.comment'); - $this->addFilters('product_name', 'pg.name'); - $this->addFilters('product_review_status', 'pr.status'); + $this->addFilter('product_review_id', 'pr.id'); + $this->addFilter('product_review_status', 'pr.status'); $this->setQueryBuilder($queryBuilder); } @@ -40,7 +39,7 @@ class CustomerReviewDataGrid extends DataGrid ]); $this->addColumn([ - 'index' => 'product_review_title', + 'index' => 'title', 'label' => trans('admin::app.datagrid.title'), 'type' => 'string', 'searchable' => true, @@ -49,7 +48,7 @@ class CustomerReviewDataGrid extends DataGrid ]); $this->addColumn([ - 'index' => 'product_review_comment', + 'index' => 'comment', 'label' => trans('admin::app.datagrid.comment'), 'type' => 'string', 'searchable' => true, @@ -58,7 +57,7 @@ class CustomerReviewDataGrid extends DataGrid ]); $this->addColumn([ - 'index' => 'product_name', + 'index' => 'name', 'label' => trans('admin::app.datagrid.product-name'), 'type' => 'string', 'searchable' => true, @@ -69,13 +68,13 @@ class CustomerReviewDataGrid extends DataGrid $this->addColumn([ 'index' => 'product_review_status', 'label' => trans('admin::app.datagrid.status'), - 'type' => 'boolean', + 'type' => 'string', 'searchable' => true, 'sortable' => true, 'width' => '100px', 'closure' => true, 'wrapper' => function ($value) { - if ($value == 'approved') + if ($value->product_review_status == 'approved') return 'Approved'; else if ($value == "pending") return 'Pending'; diff --git a/packages/Webkul/Admin/src/DataGrids/ExchangeRatesDataGrid.php b/packages/Webkul/Admin/src/DataGrids/ExchangeRatesDataGrid.php index 60e0d3eae..b6e4b33a1 100755 --- a/packages/Webkul/Admin/src/DataGrids/ExchangeRatesDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/ExchangeRatesDataGrid.php @@ -17,11 +17,9 @@ class ExchangeRatesDataGrid extends DataGrid public function prepareQueryBuilder() { - $queryBuilder = DB::table('currency_exchange_rates as cer')->addSelect('cer.id as currency_exch_id', 'curr.name as currency_exch_name', 'cer.rate as currency_exch_rate')->leftJoin('currencies as curr', 'cer.target_currency', '=', 'curr.id'); + $queryBuilder = DB::table('currency_exchange_rates as cer')->addSelect('cer.id as currency_exch_id', 'curr.name', 'cer.rate')->leftJoin('currencies as curr', 'cer.target_currency', '=', 'curr.id'); - $this->addFilters('currency_exch_id', 'cer.id'); - $this->addFilters('currency_exch_name', 'curr.name'); - $this->addFilters('currency_exch_rate', 'cer.rate'); + $this->addFilter('currency_exch_id', 'cer.id'); $this->setQueryBuilder($queryBuilder); } @@ -38,7 +36,7 @@ class ExchangeRatesDataGrid extends DataGrid ]); $this->addColumn([ - 'index' => 'currency_exch_name', + 'index' => 'name', 'label' => trans('admin::app.datagrid.currency-name'), 'type' => 'string', 'searchable' => true, @@ -47,9 +45,9 @@ class ExchangeRatesDataGrid extends DataGrid ]); $this->addColumn([ - 'index' => 'currency_exch_rate', + 'index' => 'rate', 'label' => trans('admin::app.datagrid.exch-rate'), - 'type' => 'string', + 'type' => 'number', 'searchable' => true, 'sortable' => true, 'width' => '100px' @@ -70,22 +68,4 @@ class ExchangeRatesDataGrid extends DataGrid 'icon' => 'icon trash-icon' ]); } - - public function prepareMassActions() { - // $this->prepareMassAction([ - // 'type' => 'delete', - // 'action' => route('admin.catalog.products.massdelete'), - // 'method' => 'DELETE' - // ]); - - // $this->prepareMassAction([ - // 'type' => 'update', - // 'action' => route('admin.catalog.products.massupdate'), - // 'method' => 'PUT', - // 'options' => [ - // 0 => true, - // 1 => false, - // ] - // ]); - } } \ No newline at end of file diff --git a/packages/Webkul/Admin/src/DataGrids/InventorySourcesDataGrid.php b/packages/Webkul/Admin/src/DataGrids/InventorySourcesDataGrid.php index 56334ad3d..14bf2f630 100755 --- a/packages/Webkul/Admin/src/DataGrids/InventorySourcesDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/InventorySourcesDataGrid.php @@ -68,7 +68,7 @@ class InventorySourcesDataGrid extends DataGrid 'sortable' => true, 'width' => '100px', 'wrapper' => function($value) { - if ($value == 1) + if ($value->status == 1) return 'Active'; else return 'Inactive'; diff --git a/packages/Webkul/Admin/src/DataGrids/NewsLetterDataGrid.php b/packages/Webkul/Admin/src/DataGrids/NewsLetterDataGrid.php index c90738484..462f1e715 100755 --- a/packages/Webkul/Admin/src/DataGrids/NewsLetterDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/NewsLetterDataGrid.php @@ -37,11 +37,11 @@ class NewsLetterDataGrid extends DataGrid 'index' => 'is_subscribed', 'label' => trans('admin::app.datagrid.subscribed'), 'type' => 'string', - 'searchable' => true, + 'searchable' => false, 'sortable' => true, 'width' => '100px', 'wrapper' => function($value) { - if ($value == 1) + if ($value->is_subscribed == 1) return 'True'; else return 'False'; diff --git a/packages/Webkul/Admin/src/DataGrids/OrderDataGrid.php b/packages/Webkul/Admin/src/DataGrids/OrderDataGrid.php index cc9fa1afb..adc8eabdd 100755 --- a/packages/Webkul/Admin/src/DataGrids/OrderDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/OrderDataGrid.php @@ -19,7 +19,7 @@ class OrderDataGrid extends DataGrid { $queryBuilder = DB::table('orders')->select('id', 'base_grand_total', 'grand_total', 'created_at', 'channel_name', 'status')->addSelect(DB::raw('CONCAT(customer_first_name, " ", customer_last_name) as full_name')); - $this->addFilters('full_name', DB::raw('CONCAT(customer_first_name, " ", customer_last_name)')); + $this->addFilter('full_name', DB::raw('CONCAT(customer_first_name, " ", customer_last_name)')); $this->setQueryBuilder($queryBuilder); } @@ -42,22 +42,15 @@ class OrderDataGrid extends DataGrid 'searchable' => false, 'sortable' => true, 'width' => '100px', - // 'wrapper' => function ($value) { - // return core()->formatBasePrice($value); - // } ]); $this->addColumn([ 'index' => 'grand_total', 'label' => trans('admin::app.datagrid.grand-total'), 'type' => 'price', - 'currencyCode' => 'JOD', 'searchable' => false, 'sortable' => true, 'width' => '100px', - // 'wrapper' => function ($value) { - // return core()->formatBasePrice($value); - // } ]); $this->addColumn([ @@ -87,19 +80,19 @@ class OrderDataGrid extends DataGrid 'width' => '100px', 'closure' => true, 'wrapper' => function ($value) { - if ($value == 'processing') + if ($value->status == 'processing') return 'Processing'; - else if ($value == 'completed') + else if ($value->status == 'completed') return 'Completed'; - else if ($value == "canceled") + else if ($value->status == "canceled") return 'Canceled'; - else if ($value == "closed") + else if ($value->status == "closed") return 'Closed'; - else if ($value == "pending") + else if ($value->status == "pending") return 'Pending'; - else if ($value == "pending_payment") + else if ($value->status == "pending_payment") return 'Pending Payment'; - else if ($value == "fraud") + else if ($value->status == "fraud") return 'Fraud'; } ]); @@ -121,12 +114,4 @@ class OrderDataGrid extends DataGrid 'icon' => 'icon eye-icon' ]); } - - public function prepareMassActions() { - // $this->addMassAction([ - // 'type' => 'delete', - // 'action' => route('admin.catalog.attributes.massdelete'), - // 'method' => 'DELETE' - // ]); - } } \ No newline at end of file diff --git a/packages/Webkul/Admin/src/DataGrids/OrderInvoicesDataGrid.php b/packages/Webkul/Admin/src/DataGrids/OrderInvoicesDataGrid.php index 7b70429de..bc1c5f1f2 100755 --- a/packages/Webkul/Admin/src/DataGrids/OrderInvoicesDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/OrderInvoicesDataGrid.php @@ -37,7 +37,7 @@ class OrderInvoicesDataGrid extends DataGrid 'index' => 'order_id', 'label' => trans('admin::app.datagrid.order-id'), 'type' => 'number', - 'searchable' => false, + 'searchable' => true, 'sortable' => true, 'width' => '100px' ]); @@ -46,7 +46,6 @@ class OrderInvoicesDataGrid extends DataGrid 'index' => 'grand_total', 'label' => trans('admin::app.datagrid.grand-total'), 'type' => 'price', - // 'currencyCode' => 'JOD', 'searchable' => true, 'sortable' => true, 'width' => '100px', @@ -69,12 +68,4 @@ class OrderInvoicesDataGrid extends DataGrid 'icon' => 'icon eye-icon' ]); } - - public function prepareMassActions() { - // $this->addMassAction([ - // 'type' => 'delete', - // 'action' => route('admin.catalog.attributes.massdelete'), - // 'method' => 'DELETE' - // ]); - } } \ No newline at end of file diff --git a/packages/Webkul/Admin/src/DataGrids/OrderShipmentsDataGrid.php b/packages/Webkul/Admin/src/DataGrids/OrderShipmentsDataGrid.php index 9842cc5f8..3049b6782 100755 --- a/packages/Webkul/Admin/src/DataGrids/OrderShipmentsDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/OrderShipmentsDataGrid.php @@ -17,15 +17,19 @@ class OrderShipmentsDataGrid extends DataGrid public function prepareQueryBuilder() { - $queryBuilder = DB::table('shipments as ship')->select('ship.id as shipment_id', 'ship.order_id as shipment_order_id', 'ship.total_qty as shipment_total_qty', 'is.name as inventory_source_name', 'ors.created_at as orderdate', 'ship.created_at as shipment_created_at')->addSelect(DB::raw('CONCAT(ors.customer_first_name, " ", ors.customer_last_name) as custname'))->leftJoin('orders as ors', 'ship.order_id', '=', 'ors.id')->leftJoin('inventory_sources as is', 'ship.inventory_source_id', '=', 'is.id'); + $queryBuilder = DB::table('shipments as ship') + ->leftJoin('orders as ors', 'ship.order_id', '=', 'ors.id') + ->leftJoin('inventory_sources as is', 'ship.inventory_source_id', '=', 'is.id') + ->select('ship.id as shipment_id', 'ship.order_id as shipment_order_id', 'ship.total_qty as shipment_total_qty', 'is.name as inventory_source_name', 'ors.created_at as orderdate', 'ship.created_at as shipment_created_at') + ->addSelect(DB::raw('CONCAT(ors.customer_first_name, " ", ors.customer_last_name) as custname')); - $this->addFilters('shipment_id', 'ship.id'); - $this->addFilters('shipment_order_id', 'ship.order_id'); - $this->addFilters('shipment_total_qty', 'ship.total_qty'); - $this->addFilters('inventory_source_name', 'is.name'); - $this->addFilters('orderdate', 'ors.created_at'); - $this->addFilters('shipment_created_at', 'ship.created_at'); - $this->addFilters('custname', DB::raw('CONCAT(ors.customer_first_name, " ", ors.customer_last_name)')); + $this->addFilter('shipment_id', 'ship.id'); + $this->addFilter('shipment_order_id', 'ship.order_id'); + $this->addFilter('shipment_total_qty', 'ship.total_qty'); + $this->addFilter('inventory_source_name', 'is.name'); + $this->addFilter('orderdate', 'ors.created_at'); + $this->addFilter('shipment_created_at', 'ship.created_at'); + $this->addFilter('custname', DB::raw('CONCAT(ors.customer_first_name, " ", ors.customer_last_name)')); $this->setQueryBuilder($queryBuilder); } @@ -36,7 +40,7 @@ class OrderShipmentsDataGrid extends DataGrid 'index' => 'shipment_id', 'label' => trans('admin::app.datagrid.id'), 'type' => 'number', - 'searchable' => true, + 'searchable' => false, 'sortable' => true, 'width' => '40px' ]); diff --git a/packages/Webkul/Admin/src/DataGrids/ProductDataGrid.php b/packages/Webkul/Admin/src/DataGrids/ProductDataGrid.php index d14e1f052..2b2795986 100644 --- a/packages/Webkul/Admin/src/DataGrids/ProductDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/ProductDataGrid.php @@ -17,15 +17,13 @@ class ProductDataGrid extends DataGrid public function prepareQueryBuilder() { - $queryBuilder = DB::table('products_grid as pg')->addSelect('pg.product_id as product_id', 'pg.sku as product_sku', 'pg.name as product_name', 'pr.type as product_type', 'pg.status as product_status', 'pg.price as product_price', 'pg.quantity as product_qty')->leftJoin('products as pr', 'pg.product_id', '=', 'pr.id'); + $queryBuilder = DB::table('products_grid as pg') + ->leftJoin('products as pr', 'pg.product_id', '=', 'pr.id') + ->addSelect('pg.product_id as product_id', 'pg.sku as product_sku', 'pg.name', 'pr.type as product_type', 'pg.status', 'pg.price', 'pg.quantity'); - $this->addFilters('product_id', 'pg.product_id'); - $this->addFilters('product_sku', 'pg.sku'); - $this->addFilters('product_name', 'pg.name'); - $this->addFilters('product_type', 'pr.type'); - $this->addFilters('product_status', 'pg.status'); - $this->addFilters('product_price', 'pg.price'); - $this->addFilters('product_qty', 'pg.quantity'); + $this->addFilter('product_id', 'pg.product_id'); + $this->addFilter('product_sku', 'pg.sku'); + $this->addFilter('product_type', 'pr.type'); $this->setQueryBuilder($queryBuilder); } @@ -51,7 +49,7 @@ class ProductDataGrid extends DataGrid ]); $this->addColumn([ - 'index' => 'product_name', + 'index' => 'name', 'label' => trans('admin::app.datagrid.name'), 'type' => 'string', 'searchable' => true, @@ -69,14 +67,14 @@ class ProductDataGrid extends DataGrid ]); $this->addColumn([ - 'index' => 'product_status', + 'index' => 'status', 'label' => trans('admin::app.datagrid.status'), 'type' => 'boolean', 'sortable' => true, 'searchable' => false, 'width' => '100px', 'wrapper' => function($value) { - if ($value == 1) + if ($value->status == 1) return 'Active'; else return 'Inactive'; @@ -84,16 +82,16 @@ class ProductDataGrid extends DataGrid ]); $this->addColumn([ - 'index' => 'product_price', + 'index' => 'price', 'label' => trans('admin::app.datagrid.price'), 'type' => 'price', 'sortable' => true, 'searchable' => false, - 'width' => '100px', + 'width' => '100px' ]); $this->addColumn([ - 'index' => 'product_qty', + 'index' => 'quantity', 'label' => trans('admin::app.datagrid.qty'), 'type' => 'number', 'sortable' => true, diff --git a/packages/Webkul/Admin/src/DataGrids/SliderDataGrid.php b/packages/Webkul/Admin/src/DataGrids/SliderDataGrid.php index 2d30bc533..3de2579bd 100755 --- a/packages/Webkul/Admin/src/DataGrids/SliderDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/SliderDataGrid.php @@ -17,12 +17,11 @@ class SliderDataGrid extends DataGrid public function prepareQueryBuilder() { - $queryBuilder = DB::table('sliders as sl')->addSelect('sl.id as slider_id', 'sl.title as slider_title', 'ch.name as channel_name')->leftJoin('channels as ch', 'sl.channel_id', '=', + $queryBuilder = DB::table('sliders as sl')->addSelect('sl.id as slider_id', 'sl.title', 'ch.name')->leftJoin('channels as ch', 'sl.channel_id', '=', 'ch.id'); - $this->addFilters('slider_id', 'sl.id'); - $this->addFilters('slider_title', 'sl.title'); - $this->addFilters('channel_name', 'ch.name'); + $this->addFilter('slider_id', 'sl.id'); + $this->addFilter('channel_name', 'ch.name'); $this->setQueryBuilder($queryBuilder); } @@ -39,7 +38,7 @@ class SliderDataGrid extends DataGrid ]); $this->addColumn([ - 'index' => 'slider_title', + 'index' => 'title', 'label' => trans('admin::app.datagrid.title'), 'type' => 'string', 'searchable' => true, @@ -48,7 +47,7 @@ class SliderDataGrid extends DataGrid ]); $this->addColumn([ - 'index' => 'channel_name', + 'index' => 'name', 'label' => trans('admin::app.datagrid.channel-name'), 'type' => 'string', 'searchable' => true, @@ -70,22 +69,4 @@ class SliderDataGrid extends DataGrid 'icon' => 'icon trash-icon' ]); } - - public function prepareMassActions() { - // $this->prepareMassAction([ - // 'type' => 'delete', - // 'action' => route('admin.catalog.products.massdelete'), - // 'method' => 'DELETE' - // ]); - - // $this->prepareMassAction([ - // 'type' => 'update', - // 'action' => route('admin.catalog.products.massupdate'), - // 'method' => 'PUT', - // 'options' => [ - // 0 => true, - // 1 => false, - // ] - // ]); - } } \ No newline at end of file diff --git a/packages/Webkul/Admin/src/DataGrids/UserDataGrid.php b/packages/Webkul/Admin/src/DataGrids/UserDataGrid.php index 02c2d0f81..dc1477e11 100755 --- a/packages/Webkul/Admin/src/DataGrids/UserDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/UserDataGrid.php @@ -17,13 +17,11 @@ class UserDataGrid extends DataGrid public function prepareQueryBuilder() { - $queryBuilder = DB::table('admins as u')->addSelect('u.id as user_id', 'u.name as user_name', 'u.status as user_status', 'u.email as user_email', 'ro.name as role_name')->leftJoin('roles as ro', 'u.role_id', '=', 'ro.id'); + $queryBuilder = DB::table('admins as u')->addSelect('u.id as user_id', 'u.name as user_name', 'u.status', 'u.email', 'ro.name as role_name')->leftJoin('roles as ro', 'u.role_id', '=', 'ro.id'); - $this->addFilters('user_id', 'u.id'); - $this->addFilters('user_name', 'u.name'); - $this->addFilters('user_status', 'u.status'); - $this->addFilters('user_email', 'u.email'); - $this->addFilters('role_name', 'ro.name'); + $this->addFilter('user_id', 'u.id'); + $this->addFilter('user_name', 'u.name'); + $this->addFilter('role_name', 'ro.name'); $this->setQueryBuilder($queryBuilder); } @@ -49,14 +47,14 @@ class UserDataGrid extends DataGrid ]); $this->addColumn([ - 'index' => 'user_status', + 'index' => 'status', 'label' => trans('admin::app.datagrid.status'), 'type' => 'boolean', 'searchable' => true, 'sortable' => true, 'width' => '100px', 'wrapper' => function($value) { - if ($value == 1) { + if ($value->status == 1) { return 'Active'; } else { return 'Inactive'; @@ -65,7 +63,7 @@ class UserDataGrid extends DataGrid ]); $this->addColumn([ - 'index' => 'user_email', + 'index' => 'email', 'label' => trans('admin::app.datagrid.email'), 'type' => 'string', 'searchable' => true, @@ -90,22 +88,4 @@ class UserDataGrid extends DataGrid 'icon' => 'icon pencil-lg-icon' ]); } - - public function prepareMassActions() { - // $this->prepareMassAction([ - // 'type' => 'delete', - // 'action' => route('admin.catalog.products.massdelete'), - // 'method' => 'DELETE' - // ]); - - // $this->prepareMassAction([ - // 'type' => 'update', - // 'action' => route('admin.catalog.products.massupdate'), - // 'method' => 'PUT', - // 'options' => [ - // 0 => true, - // 1 => false, - // ] - // ]); - } } \ No newline at end of file diff --git a/packages/Webkul/Admin/src/Providers/EventServiceProvider.php b/packages/Webkul/Admin/src/Providers/EventServiceProvider.php index e0d91e87a..779401228 100755 --- a/packages/Webkul/Admin/src/Providers/EventServiceProvider.php +++ b/packages/Webkul/Admin/src/Providers/EventServiceProvider.php @@ -28,6 +28,6 @@ class EventServiceProvider extends ServiceProvider Event::listen('catalog.product.update.after', 'Webkul\Admin\Listeners\Product@afterProductUpdate'); - Event::listen('after.attribute.update', 'Webkul\Admin\Listeners\Product@updateColumnBasedOnAttribute'); + // Event::listen('after.attribute.update', 'Webkul\Admin\Listeners\Product@updateColumnBasedOnAttribute'); } } \ No newline at end of file diff --git a/packages/Webkul/Attribute/src/Http/Controllers/AttributeController.php b/packages/Webkul/Attribute/src/Http/Controllers/AttributeController.php index 6a9355caf..afdd4af03 100755 --- a/packages/Webkul/Attribute/src/Http/Controllers/AttributeController.php +++ b/packages/Webkul/Attribute/src/Http/Controllers/AttributeController.php @@ -112,7 +112,7 @@ class AttributeController extends Controller $attribute = $this->attribute->update(request()->all(), $id); - Event::fire('after.attribute.update', $attribute); + // Event::fire('after.attribute.update', $attribute); session()->flash('success', 'Attribute updated successfully.'); diff --git a/packages/Webkul/Ui/src/DataGrid/DataGrid.php b/packages/Webkul/Ui/src/DataGrid/DataGrid.php index 7d47d9c93..90d39828b 100644 --- a/packages/Webkul/Ui/src/DataGrid/DataGrid.php +++ b/packages/Webkul/Ui/src/DataGrid/DataGrid.php @@ -53,7 +53,7 @@ abstract class DataGrid * * @return void */ - public function addFilters($alias, $column) { + public function addFilter($alias, $column) { $this->filterMap[$alias] = $column; $this->enableFilterMap = true; diff --git a/packages/Webkul/Ui/src/DataGrid/Facades/ProductGrid.php b/packages/Webkul/Ui/src/DataGrid/Facades/ProductGrid.php deleted file mode 100755 index daf49ae5f..000000000 --- a/packages/Webkul/Ui/src/DataGrid/Facades/ProductGrid.php +++ /dev/null @@ -1,18 +0,0 @@ - @ysmnikhil - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ - -abstract class AbstractFillable -{ - const NO_RESULT = null; - - protected $fillable = []; - - abstract protected function setFillable(); - - public function __construct($args) - { - $error = false; - $this->setFillable(); - - foreach ($args as $key => $value) { - $this->{$key} = $value; - // switch($value) { - // case (in_array(gettype($value), ["array", "object", "function"])): - // $error = $this->fieldValidate( - // $key, - // $value, - // [$this->fillable[$key]['allowed']] - // ); - // break; - // default: - // $error = $this->fieldValidate( - // $key, - // $value - // ); - // } - // if ($error) throw new \Exception($error); - } - // foreach ($this->fillable as $fill) { - // if (isset($args[$fill])) { - // $this->{$fill} = [$args[$fill]]; - // } - // } - } - - private function fieldValidate($key, $value, $allowed = ['string', 'integer', 'float', "boolean"], $merge = false) - { - $error = false; - if ( in_array($key, $this->fillable) || - array_filter( - array_keys($this->fillable) , function($value) { - return gettype($value) === "string"; - } - ) - ) { - if (in_array(gettype($value), $allowed)) { - // if ($merge) { - // if (! $this->{$key}) $this->{$key} = []; - // $this->{$key}[] = $value; - // } else - // $this->{$key} = $value; - } else { - dump(gettype($value)); - dump($value); - $error = 'Allowed params are not valid as per allowed condition! Key - ' . $key; - } - } else { - dump(in_array($key, $this->fillable)); - dump($value); - $error = 'Not Allowed field! Key - ' . $key; - } - - return $error ?: false; - } - - public function __set($key, $value) - { - $error = false; - switch('$value') { //no need to match this - case (in_array(gettype($value), ["array", "object", "function"])): - $error = $this->fieldValidate( - $key, - $value, - [$this->fillable[$key]['allowed']] - ); - break; - default: - $error = $this->fieldValidate( - $key, - $value - ); - break; - } - - if ($error) throw new \Exception($error); - $this->{$key} = $value; - } - - public function __get($key) { - if (in_array($key, $this->fillable)) { - return property_exists($this, $key) ? $this->{$key} : false; - } else - return self::NO_RESULT; - } -} diff --git a/packages/Webkul/Ui/src/DataGrid/Helpers/Column.php b/packages/Webkul/Ui/src/DataGrid/Helpers/Column.php deleted file mode 100755 index a222219e0..000000000 --- a/packages/Webkul/Ui/src/DataGrid/Helpers/Column.php +++ /dev/null @@ -1,169 +0,0 @@ - @ysmnikhil - * & - * @author Prashant Singh @prashant-webkul - * - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ - -class Column extends AbstractFillable -{ - const SORT = 'sort'; - const ORDER_DESC = 'DESC'; - const ORDER_ASC = 'ASC'; - - private $request = null; - private $readableName = false; - private $aliasing = false; - private $value = false; - private $sortHtml = '%s'; - - /** - * Without Array it will treat it like string - * - * [ - * 'name', - * 'Name', - * true, - * filter => [ - * 'function' => 'where', // andwhere - * 'condition' => ['u.user_id', '=', '1'] // multiarray - * ], - * attributes => [ - * 'class' => 'class-a, class-b', - * 'data-attr' => 'whatever you want', - * 'onlclick' => "window.alert('alert from datagrid column')" - * ], - * wrapper => function($value) { - * return 'Nikhil'; - * }, - * ] - */ - protected function setFillable() - { - $this->fillable = [ - 'name', - 'type', - 'label', - 'sortable', - 'searchable', - 'filterable', - 'massoperations' => [ - 'allowed' => 'array' - ], - 'actions' => [ - 'allowed' => 'array' - ], - 'filter' => [ - 'allowed' => 'array', - ], - 'attributes' => [ - 'allowed' => 'array', - 'validation' => 'FUTURE' - ], - 'wrapper' => [ - // 'allowed' => 'function' - 'allowed' => 'object' - ], - 'callback' => [ - 'allowed' => 'function' - ] - ]; - } - - public function __construct($args, $request = null) - { - parent::__construct($args); - $this->request = $request ?: Request::capture(); - } - - public function correctFilterSorting() - { - $return = $this->name; - $as = explode('as', $this->name); - if (count($as) > 1) { - $return = trim(current($as)); - } - - return $return; - } - - public function correctDotOnly() - { - $col_name = explode('.', $this->name); - if (isset($col_name)) { - $col_name = trim($col_name[1]); - return $col_name; - } - } - - public function correct($tillDot = true) - { - $as = explode('as', $this->name); - if (count($as) > 1) { - return trim(end($as)); - } - - if (! $tillDot) { - return $this->name; - } - - $dot = explode('.', $this->name); - if ($dot) { - return trim(end($dot)); - } - } - - private function wrap($obj) - { - if ($this->wrapper && is_callable($this->wrapper)) { - $this->value = call_user_func($this->wrapper, $this->value, $obj); - } - } - private function sortingUrl() - { - $query = ['sort' => $this->correct(false)]; - - if (($sort = $this->request->offsetGet('sort')) && $sort == $this->correct(false)) { - if (! $order = $this->request->offsetGet('order')) { - $query['order'] = self::ORDER_DESC; - } else { - $query['order'] = ($order == self::ORDER_DESC ? self::ORDER_ASC : self::ORDER_DESC); - } - } else { - $query['order'] = self::ORDER_DESC; - } - - return '?'.http_build_query(array_merge($this->request->query->all(), $query)); - } - - /** - * need to process css check on properties like label shouln't include - */ - public function sorting() - { - return $this->label; - if ($this->sortable) { - return vsprintf($this->sortHtml, [$this->sortingUrl(), $this->label]); - } else { - return $this->label; - } - } - - public function render($obj) - { - if (property_exists($obj, ($this->aliasing = $this->alias))) { - $this->value = $obj->{$this->aliasing}; - $this->wrap($obj); - } - return $this->value; - - } -} diff --git a/packages/Webkul/Ui/src/DataGrid/Helpers/Css.php b/packages/Webkul/Ui/src/DataGrid/Helpers/Css.php deleted file mode 100755 index c88a5fc47..000000000 --- a/packages/Webkul/Ui/src/DataGrid/Helpers/Css.php +++ /dev/null @@ -1,36 +0,0 @@ - @ysmnikhil - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ - -class Css extends AbstractFillable -{ - const NO_RESULT = 'no-class'; - - protected $datagrid = 'datagrid'; - protected $table = 'table'; - protected $thead = 'thead'; - protected $thead_td = 'thead_td'; - protected $tbody = 'tbody'; - protected $tbody_td = 'tbody_td'; - - public function __construct($args) { - parent::__construct($args); - } - - protected function setFillable() { - $this->fillable = [ - 'datagrid', - 'table', - 'thead', - 'thead_td', - 'tbody', - 'tbody_td', - ]; - } -} diff --git a/packages/Webkul/Ui/src/DataGrid/Helpers/MassAction.php b/packages/Webkul/Ui/src/DataGrid/Helpers/MassAction.php deleted file mode 100755 index 924446e92..000000000 --- a/packages/Webkul/Ui/src/DataGrid/Helpers/MassAction.php +++ /dev/null @@ -1,36 +0,0 @@ - @prashant-webkul - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ - -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'); - } - } -} diff --git a/packages/Webkul/Ui/src/DataGrid/Helpers/Pagination.php b/packages/Webkul/Ui/src/DataGrid/Helpers/Pagination.php deleted file mode 100755 index 003a42e9c..000000000 --- a/packages/Webkul/Ui/src/DataGrid/Helpers/Pagination.php +++ /dev/null @@ -1,37 +0,0 @@ - @ysmnikhil - * & - * @author Prashant Singh @prashant-webkul - * - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ - -class Pagination extends Paginator -{ - const LIMIT = 10; - const OFFSET = 0; - const VIEW = ''; - - public function __construct( - int $limit = null, - int $offset = null, - int $view = null - ) { - $this->limit = $limit ?: self::LIMIT; - $this->offset = $offset ?: self::OFFSET; - $this->view = $view ?: self::VIEW; - - parent::__construct([ - - ], 20); - } -} diff --git a/packages/Webkul/Ui/src/Resources/views/datagrid/body.blade.php b/packages/Webkul/Ui/src/Resources/views/datagrid/body.blade.php index b09641667..8645199b4 100644 --- a/packages/Webkul/Ui/src/Resources/views/datagrid/body.blade.php +++ b/packages/Webkul/Ui/src/Resources/views/datagrid/body.blade.php @@ -17,15 +17,13 @@ $columnIndex = explode('.', $column['index']); $columnIndex = end($columnIndex); - - // dd($columnIndex); @endphp @if (isset($column['wrapper'])) @if (isset($column['closure']) && $column['closure'] == true) - {!! $column['wrapper']($record->{$columnIndex}) !!} + {!! $column['wrapper']($record) !!} @else - {{ $column['wrapper']($record->{$columnIndex}) }} + {{ $column['wrapper']($record) }} @endif @else @if($column['type'] == 'price') diff --git a/packages/Webkul/Ui/src/Resources/views/datagrid/head.blade.php b/packages/Webkul/Ui/src/Resources/views/datagrid/head.blade.php deleted file mode 100644 index d88375d15..000000000 --- a/packages/Webkul/Ui/src/Resources/views/datagrid/head.blade.php +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - @foreach ($columns as $key => $column) - {{ $column['label'] }} - @endforeach - - \ No newline at end of file diff --git a/packages/Webkul/Ui/src/Resources/views/datagrid/table.blade.php b/packages/Webkul/Ui/src/Resources/views/datagrid/table.blade.php index 5869dc75c..8033cf583 100644 --- a/packages/Webkul/Ui/src/Resources/views/datagrid/table.blade.php +++ b/packages/Webkul/Ui/src/Resources/views/datagrid/table.blade.php @@ -1,15 +1,15 @@
- + @if (config('datagrid.paginate')) @include('ui::datagrid.pagination', ['results' => $results['records']]) @endif @push('scripts') -