More changes in datagrid, regarding implementation of wrapper columns

This commit is contained in:
Prashant Singh 2019-01-17 15:24:58 +05:30
parent 98858ee12a
commit eb373d7ecb
27 changed files with 104 additions and 648 deletions

View File

@ -132,20 +132,20 @@ Bagisto is a truly opensource E-Commerce framework which will always be free und
### 6. Miscellaneous <a name="#miscellaneous"></a>: ### 6. Miscellaneous <a name="#miscellaneous"></a>:
## Contributors #### Contributors
This project exists thanks to all the people who contribute. This project exists thanks to all the people who contribute.
<a href="https://github.com/bagisto/bagisto/graphs/contributors"><img src="https://opencollective.com/bagisto/contributors.svg?width=890&button=false" /></a> <a href="https://github.com/bagisto/bagisto/graphs/contributors"><img src="https://opencollective.com/bagisto/contributors.svg?width=890&button=false" /></a>
## Backers #### Backers
Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/bagisto#backer)] Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/bagisto#backer)]
<a href="https://opencollective.com/bagisto#backers" target="_blank"><img src="https://opencollective.com/bagisto/backers.svg?width=890"></a> <a href="https://opencollective.com/bagisto#backers" target="_blank"><img src="https://opencollective.com/bagisto/backers.svg?width=890"></a>
## 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)] 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
<a href="https://opencollective.com/bagisto/sponsor/6/website" target="_blank"><img src="https://opencollective.com/bagisto/sponsor/6/avatar.svg"></a> <a href="https://opencollective.com/bagisto/sponsor/6/website" target="_blank"><img src="https://opencollective.com/bagisto/sponsor/6/avatar.svg"></a>
<a href="https://opencollective.com/bagisto/sponsor/7/website" target="_blank"><img src="https://opencollective.com/bagisto/sponsor/7/avatar.svg"></a> <a href="https://opencollective.com/bagisto/sponsor/7/website" target="_blank"><img src="https://opencollective.com/bagisto/sponsor/7/avatar.svg"></a>
<a href="https://opencollective.com/bagisto/sponsor/8/website" target="_blank"><img src="https://opencollective.com/bagisto/sponsor/8/avatar.svg"></a> <a href="https://opencollective.com/bagisto/sponsor/8/website" target="_blank"><img src="https://opencollective.com/bagisto/sponsor/8/avatar.svg"></a>
<a href="https://opencollective.com/bagisto/sponsor/9/website" target="_blank"><img src="https://opencollective.com/bagisto/sponsor/9/avatar.svg"></a> <a href="https://opencollective.com/bagisto/sponsor/9/website" target="_blank"><img src="https://opencollective.com/bagisto/sponsor/9/avatar.svg"></a>
### Coming Soon:
-> API support for core packages and numerous fixes.

View File

@ -20,7 +20,9 @@ class AttributeDataGrid extends DataGrid
public function prepareQueryBuilder() 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); $this->setQueryBuilder($queryBuilder);
} }
@ -71,7 +73,7 @@ class AttributeDataGrid extends DataGrid
'searchable' => false, 'searchable' => false,
'width' => '100px', 'width' => '100px',
'wrapper' => function($value) { 'wrapper' => function($value) {
if ($value == 1) if ($value->is_required == 1)
return 'True'; return 'True';
else else
return 'False'; return 'False';
@ -86,7 +88,7 @@ class AttributeDataGrid extends DataGrid
'searchable' => false, 'searchable' => false,
'width' => '100px', 'width' => '100px',
'wrapper' => function($value) { 'wrapper' => function($value) {
if ($value == 1) if ($value->is_unique == 1)
return 'True'; return 'True';
else else
return 'False'; return 'False';
@ -101,7 +103,7 @@ class AttributeDataGrid extends DataGrid
'searchable' => false, 'searchable' => false,
'width' => '100px', 'width' => '100px',
'wrapper' => function($value) { 'wrapper' => function($value) {
if ($value == 1) if ($value->value_per_locale == 1)
return 'True'; return 'True';
else else
return 'False'; return 'False';
@ -116,7 +118,7 @@ class AttributeDataGrid extends DataGrid
'searchable' => false, 'searchable' => false,
'width' => '100px', 'width' => '100px',
'wrapper' => function($value) { 'wrapper' => function($value) {
if ($value == 1) if ($value->value_per_channel == 1)
return 'True'; return 'True';
else else
return 'False'; return 'False';

View File

@ -68,22 +68,4 @@ class AttributeFamilyDataGrid extends DataGrid
'icon' => 'icon trash-icon' '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,
// // ]
// // ]);
// }
} }

View File

@ -17,13 +17,11 @@ class CategoryDataGrid extends DataGrid
public function prepareQueryBuilder() 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->addFilter('category_id', 'cat.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->setQueryBuilder($queryBuilder); $this->setQueryBuilder($queryBuilder);
} }
@ -40,7 +38,7 @@ class CategoryDataGrid extends DataGrid
]); ]);
$this->addColumn([ $this->addColumn([
'index' => 'category_name', 'index' => 'name',
'label' => trans('admin::app.datagrid.name'), 'label' => trans('admin::app.datagrid.name'),
'type' => 'string', 'type' => 'string',
'searchable' => true, 'searchable' => true,
@ -49,23 +47,23 @@ class CategoryDataGrid extends DataGrid
]); ]);
$this->addColumn([ $this->addColumn([
'index' => 'category_position', 'index' => 'position',
'label' => trans('admin::app.datagrid.position'), 'label' => trans('admin::app.datagrid.position'),
'type' => 'string', 'type' => 'string',
'searchable' => true, 'searchable' => false,
'sortable' => true, 'sortable' => true,
'width' => '100px' 'width' => '100px'
]); ]);
$this->addColumn([ $this->addColumn([
'index' => 'category_status', 'index' => 'status',
'label' => trans('admin::app.datagrid.status'), 'label' => trans('admin::app.datagrid.status'),
'type' => 'boolean', 'type' => 'boolean',
'sortable' => true, 'sortable' => true,
'searchable' => true, 'searchable' => true,
'width' => '100px', 'width' => '100px',
'wrapper' => function($value) { 'wrapper' => function($value) {
if ($value == 1) if ($value->status == 1)
return 'Active'; return 'Active';
else else
return 'Inactive'; return 'Inactive';
@ -73,11 +71,11 @@ class CategoryDataGrid extends DataGrid
]); ]);
$this->addColumn([ $this->addColumn([
'index' => 'category_locale', 'index' => 'locale',
'label' => trans('admin::app.datagrid.locale'), 'label' => trans('admin::app.datagrid.locale'),
'type' => 'boolean', 'type' => 'boolean',
'sortable' => true, 'sortable' => true,
'searchable' => false, 'searchable' => true,
'width' => '100px' 'width' => '100px'
]); ]);
} }

View File

@ -19,12 +19,12 @@ class CustomerDataGrid extends DataGrid
public function prepareQueryBuilder() 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->addFilter('customer_id', 'custs.id');
$this->addFilters('customer_email', 'custs.email'); $this->addFilter('full_name', DB::raw('CONCAT(custs.first_name, " ", custs.last_name)'));
$this->addFilters('cust_grp_name', 'cg.name');
$this->addFilters('full_name', DB::raw('CONCAT(custs.first_name, " ", custs.last_name)'));
$this->setQueryBuilder($queryBuilder); $this->setQueryBuilder($queryBuilder);
} }
@ -35,7 +35,7 @@ class CustomerDataGrid extends DataGrid
'index' => 'customer_id', 'index' => 'customer_id',
'label' => trans('admin::app.datagrid.id'), 'label' => trans('admin::app.datagrid.id'),
'type' => 'number', 'type' => 'number',
'searchable' => true, 'searchable' => false,
'sortable' => true, 'sortable' => true,
'width' => '40px' 'width' => '40px'
]); ]);
@ -50,7 +50,7 @@ class CustomerDataGrid extends DataGrid
]); ]);
$this->addColumn([ $this->addColumn([
'index' => 'customer_email', 'index' => 'email',
'label' => trans('admin::app.datagrid.email'), 'label' => trans('admin::app.datagrid.email'),
'type' => 'string', 'type' => 'string',
'searchable' => true, 'searchable' => true,
@ -59,7 +59,7 @@ class CustomerDataGrid extends DataGrid
]); ]);
$this->addColumn([ $this->addColumn([
'index' => 'cust_grp_name', 'index' => 'name',
'label' => trans('admin::app.datagrid.group'), 'label' => trans('admin::app.datagrid.group'),
'type' => 'string', 'type' => 'string',
'searchable' => false, 'searchable' => false,
@ -81,22 +81,4 @@ class CustomerDataGrid extends DataGrid
'icon' => 'icon trash-icon' '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,
// ]
// ]);
}
} }

View File

@ -17,13 +17,12 @@ class CustomerReviewDataGrid extends DataGrid
public function prepareQueryBuilder() 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->addFilter('product_review_id', 'pr.id');
$this->addFilters('product_review_title', 'pr.title'); $this->addFilter('product_review_status', 'pr.status');
$this->addFilters('product_review_comment', 'pr.comment');
$this->addFilters('product_name', 'pg.name');
$this->addFilters('product_review_status', 'pr.status');
$this->setQueryBuilder($queryBuilder); $this->setQueryBuilder($queryBuilder);
} }
@ -40,7 +39,7 @@ class CustomerReviewDataGrid extends DataGrid
]); ]);
$this->addColumn([ $this->addColumn([
'index' => 'product_review_title', 'index' => 'title',
'label' => trans('admin::app.datagrid.title'), 'label' => trans('admin::app.datagrid.title'),
'type' => 'string', 'type' => 'string',
'searchable' => true, 'searchable' => true,
@ -49,7 +48,7 @@ class CustomerReviewDataGrid extends DataGrid
]); ]);
$this->addColumn([ $this->addColumn([
'index' => 'product_review_comment', 'index' => 'comment',
'label' => trans('admin::app.datagrid.comment'), 'label' => trans('admin::app.datagrid.comment'),
'type' => 'string', 'type' => 'string',
'searchable' => true, 'searchable' => true,
@ -58,7 +57,7 @@ class CustomerReviewDataGrid extends DataGrid
]); ]);
$this->addColumn([ $this->addColumn([
'index' => 'product_name', 'index' => 'name',
'label' => trans('admin::app.datagrid.product-name'), 'label' => trans('admin::app.datagrid.product-name'),
'type' => 'string', 'type' => 'string',
'searchable' => true, 'searchable' => true,
@ -69,13 +68,13 @@ class CustomerReviewDataGrid extends DataGrid
$this->addColumn([ $this->addColumn([
'index' => 'product_review_status', 'index' => 'product_review_status',
'label' => trans('admin::app.datagrid.status'), 'label' => trans('admin::app.datagrid.status'),
'type' => 'boolean', 'type' => 'string',
'searchable' => true, 'searchable' => true,
'sortable' => true, 'sortable' => true,
'width' => '100px', 'width' => '100px',
'closure' => true, 'closure' => true,
'wrapper' => function ($value) { 'wrapper' => function ($value) {
if ($value == 'approved') if ($value->product_review_status == 'approved')
return '<span class="badge badge-md badge-success">Approved</span>'; return '<span class="badge badge-md badge-success">Approved</span>';
else if ($value == "pending") else if ($value == "pending")
return '<span class="badge badge-md badge-warning">Pending</span>'; return '<span class="badge badge-md badge-warning">Pending</span>';

View File

@ -17,11 +17,9 @@ class ExchangeRatesDataGrid extends DataGrid
public function prepareQueryBuilder() 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->addFilter('currency_exch_id', 'cer.id');
$this->addFilters('currency_exch_name', 'curr.name');
$this->addFilters('currency_exch_rate', 'cer.rate');
$this->setQueryBuilder($queryBuilder); $this->setQueryBuilder($queryBuilder);
} }
@ -38,7 +36,7 @@ class ExchangeRatesDataGrid extends DataGrid
]); ]);
$this->addColumn([ $this->addColumn([
'index' => 'currency_exch_name', 'index' => 'name',
'label' => trans('admin::app.datagrid.currency-name'), 'label' => trans('admin::app.datagrid.currency-name'),
'type' => 'string', 'type' => 'string',
'searchable' => true, 'searchable' => true,
@ -47,9 +45,9 @@ class ExchangeRatesDataGrid extends DataGrid
]); ]);
$this->addColumn([ $this->addColumn([
'index' => 'currency_exch_rate', 'index' => 'rate',
'label' => trans('admin::app.datagrid.exch-rate'), 'label' => trans('admin::app.datagrid.exch-rate'),
'type' => 'string', 'type' => 'number',
'searchable' => true, 'searchable' => true,
'sortable' => true, 'sortable' => true,
'width' => '100px' 'width' => '100px'
@ -70,22 +68,4 @@ class ExchangeRatesDataGrid extends DataGrid
'icon' => 'icon trash-icon' '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,
// ]
// ]);
}
} }

View File

@ -68,7 +68,7 @@ class InventorySourcesDataGrid extends DataGrid
'sortable' => true, 'sortable' => true,
'width' => '100px', 'width' => '100px',
'wrapper' => function($value) { 'wrapper' => function($value) {
if ($value == 1) if ($value->status == 1)
return 'Active'; return 'Active';
else else
return 'Inactive'; return 'Inactive';

View File

@ -37,11 +37,11 @@ class NewsLetterDataGrid extends DataGrid
'index' => 'is_subscribed', 'index' => 'is_subscribed',
'label' => trans('admin::app.datagrid.subscribed'), 'label' => trans('admin::app.datagrid.subscribed'),
'type' => 'string', 'type' => 'string',
'searchable' => true, 'searchable' => false,
'sortable' => true, 'sortable' => true,
'width' => '100px', 'width' => '100px',
'wrapper' => function($value) { 'wrapper' => function($value) {
if ($value == 1) if ($value->is_subscribed == 1)
return 'True'; return 'True';
else else
return 'False'; return 'False';

View File

@ -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')); $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); $this->setQueryBuilder($queryBuilder);
} }
@ -42,22 +42,15 @@ class OrderDataGrid extends DataGrid
'searchable' => false, 'searchable' => false,
'sortable' => true, 'sortable' => true,
'width' => '100px', 'width' => '100px',
// 'wrapper' => function ($value) {
// return core()->formatBasePrice($value);
// }
]); ]);
$this->addColumn([ $this->addColumn([
'index' => 'grand_total', 'index' => 'grand_total',
'label' => trans('admin::app.datagrid.grand-total'), 'label' => trans('admin::app.datagrid.grand-total'),
'type' => 'price', 'type' => 'price',
'currencyCode' => 'JOD',
'searchable' => false, 'searchable' => false,
'sortable' => true, 'sortable' => true,
'width' => '100px', 'width' => '100px',
// 'wrapper' => function ($value) {
// return core()->formatBasePrice($value);
// }
]); ]);
$this->addColumn([ $this->addColumn([
@ -87,19 +80,19 @@ class OrderDataGrid extends DataGrid
'width' => '100px', 'width' => '100px',
'closure' => true, 'closure' => true,
'wrapper' => function ($value) { 'wrapper' => function ($value) {
if ($value == 'processing') if ($value->status == 'processing')
return '<span class="badge badge-md badge-success">Processing</span>'; return '<span class="badge badge-md badge-success">Processing</span>';
else if ($value == 'completed') else if ($value->status == 'completed')
return '<span class="badge badge-md badge-success">Completed</span>'; return '<span class="badge badge-md badge-success">Completed</span>';
else if ($value == "canceled") else if ($value->status == "canceled")
return '<span class="badge badge-md badge-danger">Canceled</span>'; return '<span class="badge badge-md badge-danger">Canceled</span>';
else if ($value == "closed") else if ($value->status == "closed")
return '<span class="badge badge-md badge-info">Closed</span>'; return '<span class="badge badge-md badge-info">Closed</span>';
else if ($value == "pending") else if ($value->status == "pending")
return '<span class="badge badge-md badge-warning">Pending</span>'; return '<span class="badge badge-md badge-warning">Pending</span>';
else if ($value == "pending_payment") else if ($value->status == "pending_payment")
return '<span class="badge badge-md badge-warning">Pending Payment</span>'; return '<span class="badge badge-md badge-warning">Pending Payment</span>';
else if ($value == "fraud") else if ($value->status == "fraud")
return '<span class="badge badge-md badge-danger">Fraud</span>'; return '<span class="badge badge-md badge-danger">Fraud</span>';
} }
]); ]);
@ -121,12 +114,4 @@ class OrderDataGrid extends DataGrid
'icon' => 'icon eye-icon' 'icon' => 'icon eye-icon'
]); ]);
} }
public function prepareMassActions() {
// $this->addMassAction([
// 'type' => 'delete',
// 'action' => route('admin.catalog.attributes.massdelete'),
// 'method' => 'DELETE'
// ]);
}
} }

View File

@ -37,7 +37,7 @@ class OrderInvoicesDataGrid extends DataGrid
'index' => 'order_id', 'index' => 'order_id',
'label' => trans('admin::app.datagrid.order-id'), 'label' => trans('admin::app.datagrid.order-id'),
'type' => 'number', 'type' => 'number',
'searchable' => false, 'searchable' => true,
'sortable' => true, 'sortable' => true,
'width' => '100px' 'width' => '100px'
]); ]);
@ -46,7 +46,6 @@ class OrderInvoicesDataGrid extends DataGrid
'index' => 'grand_total', 'index' => 'grand_total',
'label' => trans('admin::app.datagrid.grand-total'), 'label' => trans('admin::app.datagrid.grand-total'),
'type' => 'price', 'type' => 'price',
// 'currencyCode' => 'JOD',
'searchable' => true, 'searchable' => true,
'sortable' => true, 'sortable' => true,
'width' => '100px', 'width' => '100px',
@ -69,12 +68,4 @@ class OrderInvoicesDataGrid extends DataGrid
'icon' => 'icon eye-icon' 'icon' => 'icon eye-icon'
]); ]);
} }
public function prepareMassActions() {
// $this->addMassAction([
// 'type' => 'delete',
// 'action' => route('admin.catalog.attributes.massdelete'),
// 'method' => 'DELETE'
// ]);
}
} }

View File

@ -17,15 +17,19 @@ class OrderShipmentsDataGrid extends DataGrid
public function prepareQueryBuilder() 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->addFilter('shipment_id', 'ship.id');
$this->addFilters('shipment_order_id', 'ship.order_id'); $this->addFilter('shipment_order_id', 'ship.order_id');
$this->addFilters('shipment_total_qty', 'ship.total_qty'); $this->addFilter('shipment_total_qty', 'ship.total_qty');
$this->addFilters('inventory_source_name', 'is.name'); $this->addFilter('inventory_source_name', 'is.name');
$this->addFilters('orderdate', 'ors.created_at'); $this->addFilter('orderdate', 'ors.created_at');
$this->addFilters('shipment_created_at', 'ship.created_at'); $this->addFilter('shipment_created_at', 'ship.created_at');
$this->addFilters('custname', DB::raw('CONCAT(ors.customer_first_name, " ", ors.customer_last_name)')); $this->addFilter('custname', DB::raw('CONCAT(ors.customer_first_name, " ", ors.customer_last_name)'));
$this->setQueryBuilder($queryBuilder); $this->setQueryBuilder($queryBuilder);
} }
@ -36,7 +40,7 @@ class OrderShipmentsDataGrid extends DataGrid
'index' => 'shipment_id', 'index' => 'shipment_id',
'label' => trans('admin::app.datagrid.id'), 'label' => trans('admin::app.datagrid.id'),
'type' => 'number', 'type' => 'number',
'searchable' => true, 'searchable' => false,
'sortable' => true, 'sortable' => true,
'width' => '40px' 'width' => '40px'
]); ]);

View File

@ -17,15 +17,13 @@ class ProductDataGrid extends DataGrid
public function prepareQueryBuilder() 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->addFilter('product_id', 'pg.product_id');
$this->addFilters('product_sku', 'pg.sku'); $this->addFilter('product_sku', 'pg.sku');
$this->addFilters('product_name', 'pg.name'); $this->addFilter('product_type', 'pr.type');
$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->setQueryBuilder($queryBuilder); $this->setQueryBuilder($queryBuilder);
} }
@ -51,7 +49,7 @@ class ProductDataGrid extends DataGrid
]); ]);
$this->addColumn([ $this->addColumn([
'index' => 'product_name', 'index' => 'name',
'label' => trans('admin::app.datagrid.name'), 'label' => trans('admin::app.datagrid.name'),
'type' => 'string', 'type' => 'string',
'searchable' => true, 'searchable' => true,
@ -69,14 +67,14 @@ class ProductDataGrid extends DataGrid
]); ]);
$this->addColumn([ $this->addColumn([
'index' => 'product_status', 'index' => 'status',
'label' => trans('admin::app.datagrid.status'), 'label' => trans('admin::app.datagrid.status'),
'type' => 'boolean', 'type' => 'boolean',
'sortable' => true, 'sortable' => true,
'searchable' => false, 'searchable' => false,
'width' => '100px', 'width' => '100px',
'wrapper' => function($value) { 'wrapper' => function($value) {
if ($value == 1) if ($value->status == 1)
return 'Active'; return 'Active';
else else
return 'Inactive'; return 'Inactive';
@ -84,16 +82,16 @@ class ProductDataGrid extends DataGrid
]); ]);
$this->addColumn([ $this->addColumn([
'index' => 'product_price', 'index' => 'price',
'label' => trans('admin::app.datagrid.price'), 'label' => trans('admin::app.datagrid.price'),
'type' => 'price', 'type' => 'price',
'sortable' => true, 'sortable' => true,
'searchable' => false, 'searchable' => false,
'width' => '100px', 'width' => '100px'
]); ]);
$this->addColumn([ $this->addColumn([
'index' => 'product_qty', 'index' => 'quantity',
'label' => trans('admin::app.datagrid.qty'), 'label' => trans('admin::app.datagrid.qty'),
'type' => 'number', 'type' => 'number',
'sortable' => true, 'sortable' => true,

View File

@ -17,12 +17,11 @@ class SliderDataGrid extends DataGrid
public function prepareQueryBuilder() 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'); 'ch.id');
$this->addFilters('slider_id', 'sl.id'); $this->addFilter('slider_id', 'sl.id');
$this->addFilters('slider_title', 'sl.title'); $this->addFilter('channel_name', 'ch.name');
$this->addFilters('channel_name', 'ch.name');
$this->setQueryBuilder($queryBuilder); $this->setQueryBuilder($queryBuilder);
} }
@ -39,7 +38,7 @@ class SliderDataGrid extends DataGrid
]); ]);
$this->addColumn([ $this->addColumn([
'index' => 'slider_title', 'index' => 'title',
'label' => trans('admin::app.datagrid.title'), 'label' => trans('admin::app.datagrid.title'),
'type' => 'string', 'type' => 'string',
'searchable' => true, 'searchable' => true,
@ -48,7 +47,7 @@ class SliderDataGrid extends DataGrid
]); ]);
$this->addColumn([ $this->addColumn([
'index' => 'channel_name', 'index' => 'name',
'label' => trans('admin::app.datagrid.channel-name'), 'label' => trans('admin::app.datagrid.channel-name'),
'type' => 'string', 'type' => 'string',
'searchable' => true, 'searchable' => true,
@ -70,22 +69,4 @@ class SliderDataGrid extends DataGrid
'icon' => 'icon trash-icon' '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,
// ]
// ]);
}
} }

View File

@ -17,13 +17,11 @@ class UserDataGrid extends DataGrid
public function prepareQueryBuilder() 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->addFilter('user_id', 'u.id');
$this->addFilters('user_name', 'u.name'); $this->addFilter('user_name', 'u.name');
$this->addFilters('user_status', 'u.status'); $this->addFilter('role_name', 'ro.name');
$this->addFilters('user_email', 'u.email');
$this->addFilters('role_name', 'ro.name');
$this->setQueryBuilder($queryBuilder); $this->setQueryBuilder($queryBuilder);
} }
@ -49,14 +47,14 @@ class UserDataGrid extends DataGrid
]); ]);
$this->addColumn([ $this->addColumn([
'index' => 'user_status', 'index' => 'status',
'label' => trans('admin::app.datagrid.status'), 'label' => trans('admin::app.datagrid.status'),
'type' => 'boolean', 'type' => 'boolean',
'searchable' => true, 'searchable' => true,
'sortable' => true, 'sortable' => true,
'width' => '100px', 'width' => '100px',
'wrapper' => function($value) { 'wrapper' => function($value) {
if ($value == 1) { if ($value->status == 1) {
return 'Active'; return 'Active';
} else { } else {
return 'Inactive'; return 'Inactive';
@ -65,7 +63,7 @@ class UserDataGrid extends DataGrid
]); ]);
$this->addColumn([ $this->addColumn([
'index' => 'user_email', 'index' => 'email',
'label' => trans('admin::app.datagrid.email'), 'label' => trans('admin::app.datagrid.email'),
'type' => 'string', 'type' => 'string',
'searchable' => true, 'searchable' => true,
@ -90,22 +88,4 @@ class UserDataGrid extends DataGrid
'icon' => 'icon pencil-lg-icon' '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,
// ]
// ]);
}
} }

View File

@ -28,6 +28,6 @@ class EventServiceProvider extends ServiceProvider
Event::listen('catalog.product.update.after', 'Webkul\Admin\Listeners\Product@afterProductUpdate'); 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');
} }
} }

View File

@ -112,7 +112,7 @@ class AttributeController extends Controller
$attribute = $this->attribute->update(request()->all(), $id); $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.'); session()->flash('success', 'Attribute updated successfully.');

View File

@ -53,7 +53,7 @@ abstract class DataGrid
* *
* @return void * @return void
*/ */
public function addFilters($alias, $column) { public function addFilter($alias, $column) {
$this->filterMap[$alias] = $column; $this->filterMap[$alias] = $column;
$this->enableFilterMap = true; $this->enableFilterMap = true;

View File

@ -1,18 +0,0 @@
<?php
namespace Webkul\Ui\DataGrid\Facades;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Facade;
class ProductGrid extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'productgrid';
}
}

View File

@ -1,108 +0,0 @@
<?php
namespace Webkul\Ui\DataGrid\Helpers;
/**
* AbstractFillable
* @author Nikhil Malik <nikhil@webkul.com> @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;
}
}

View File

@ -1,169 +0,0 @@
<?php
namespace Webkul\Ui\DataGrid\Helpers;
use Illuminate\Http\Request;
/**
* Column controller
*
* @author Nikhil Malik <nikhil@webkul.com> @ysmnikhil
* &
* @author Prashant Singh <prashant.singh852@webkul.com> @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 = '<a href="%s">%s</a>';
/**
* 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 '<a href="'.$value.'">Nikhil</a>';
* },
* ]
*/
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 <script>alert('Kaboom!')</script>
*/
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;
}
}

View File

@ -1,36 +0,0 @@
<?php
namespace Webkul\Ui\DataGrid\Helpers;
/**
* Css
* @author Nikhil Malik <nikhil@webkul.com> @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',
];
}
}

View File

@ -1,36 +0,0 @@
<?php
namespace Webkul\Ui\DataGrid\Helpers;
use Illuminate\Http\Request;
/**
* MassAction
* @author Prashant Singh <prashant.singh852@webkul.com> @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');
}
}
}

View File

@ -1,37 +0,0 @@
<?php
namespace Webkul\Ui\DataGrid\Helpers;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Pagination\Paginator;
/**
* DataGrid controller
*
* @author Nikhil Malik <nikhil@webkul.com> @ysmnikhil
* &
* @author Prashant Singh <prashant.singh852@webkul.com> @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);
}
}

View File

@ -17,15 +17,13 @@
$columnIndex = explode('.', $column['index']); $columnIndex = explode('.', $column['index']);
$columnIndex = end($columnIndex); $columnIndex = end($columnIndex);
// dd($columnIndex);
@endphp @endphp
@if (isset($column['wrapper'])) @if (isset($column['wrapper']))
@if (isset($column['closure']) && $column['closure'] == true) @if (isset($column['closure']) && $column['closure'] == true)
<td>{!! $column['wrapper']($record->{$columnIndex}) !!}</td> <td>{!! $column['wrapper']($record) !!}</td>
@else @else
<td>{{ $column['wrapper']($record->{$columnIndex}) }}</td> <td>{{ $column['wrapper']($record) }}</td>
@endif @endif
@else @else
@if($column['type'] == 'price') @if($column['type'] == 'price')

View File

@ -1,14 +0,0 @@
<thead>
<tr>
<th class="grid_head" id="mastercheckbox" style="width: 50px;">
<span class="checkbox">
<input type="checkbox" id="mastercheckbox">
<label class="checkbox-view" for="checkbox"></label>
</span>
</th>
@foreach ($columns as $key => $column)
<th class="grid_head" data-column-alias="{{ $column['alias'] }}" data-column-name="{{ $column['column'] }}" data-column-sortable="{{ $column['sortable'] }}" data-column-type="{{ $column['type'] }}" style="width: {{ $column['width'] }}" v-on:click="sortCollection({{ $column['alias'] }})">{{ $column['label'] }}</th>
@endforeach
</tr>
</thead>

View File

@ -1,15 +1,15 @@
<div class="table"> <div class="table">
<testgrid-filters></testgrid-filters> <datagrid-filters></datagrid-filters>
@if (config('datagrid.paginate')) @if (config('datagrid.paginate'))
@include('ui::datagrid.pagination', ['results' => $results['records']]) @include('ui::datagrid.pagination', ['results' => $results['records']])
@endif @endif
@push('scripts') @push('scripts')
<script type="text/x-template" id="testgrid-filters"> <script type="text/x-template" id="datagrid-filters">
{{-- start filter here --}} {{-- start filter here --}}
<div class="grid-container"> <div class="grid-container">
<div class="filter-row-one" id="testgrid-filters"> <div class="filter-row-one" id="datagrid-filters">
<div class="search-filter"> <div class="search-filter">
<input type="search" id="search-field" class="control" placeholder="Search Here..." v-model="searchValue" /> <input type="search" id="search-field" class="control" placeholder="Search Here..." v-model="searchValue" />
@ -216,8 +216,8 @@
</script> </script>
<script> <script>
Vue.component('testgrid-filters', { Vue.component('datagrid-filters', {
template: '#testgrid-filters', template: '#datagrid-filters',
data: () => ({ data: () => ({
gridCurrentData: @json($results['records']), gridCurrentData: @json($results['records']),
@ -691,8 +691,6 @@
} }
} }
} }
// console.log(this.dataIds);
}, },
removeMassActions() { removeMassActions() {