From 806ffb460fa23b26ee1050746e71ccf081acb36e Mon Sep 17 00:00:00 2001 From: prashant-webkul Date: Thu, 18 Oct 2018 16:34:55 +0530 Subject: [PATCH] Order Datagrid, Datagrid Currency Capabilities via wrapper and UI fixes in storefront navigation bar, admin panel menu item, datagrid actions checks before rendering of datagrid --- .../src/DataGrids/ExchangeRatesDataGrid.php | 35 +++-- .../Admin/src/DataGrids/OrderDataGrid.php | 123 +++++++----------- .../Admin/src/DataGrids/UserDataGrid.php | 15 +-- .../src/Providers/EventServiceProvider.php | 28 ++-- .../views/sales/orders/index.blade.php | 4 +- ...2_create_currency_exchange_rates_table.php | 1 - .../Shop/src/Resources/assets/sass/app.scss | 4 +- .../views/products/buy-now.blade.php | 4 +- .../Ui/src/Resources/assets/sass/app.scss | 27 ++-- .../views/datagrid/table/body.blade.php | 4 +- .../views/datagrid/table/head.blade.php | 8 +- public/themes/default/assets/css/shop.css | 11 +- 12 files changed, 111 insertions(+), 153 deletions(-) diff --git a/packages/Webkul/Admin/src/DataGrids/ExchangeRatesDataGrid.php b/packages/Webkul/Admin/src/DataGrids/ExchangeRatesDataGrid.php index 9d4f085e0..9171064dd 100644 --- a/packages/Webkul/Admin/src/DataGrids/ExchangeRatesDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/ExchangeRatesDataGrid.php @@ -27,10 +27,10 @@ class ExchangeRatesDataGrid return DataGrid::make([ 'name' => 'Exchange Rates', - 'table' => 'currency_exchange_rates', - 'select' => 'id', + 'table' => 'currency_exchange_rates as cer', + 'select' => 'cer.id', 'perpage' => 5, - 'aliased' => false, //use this with false as default and true in case of joins + 'aliased' => true, //use this with false as default and true in case of joins 'massoperations' =>[ [ @@ -56,13 +56,13 @@ class ExchangeRatesDataGrid ], 'join' => [ - // [ - // 'join' => 'leftjoin', - // 'table' => 'roles as r', - // 'primaryKey' => 'u.role_id', - // 'condition' => '=', - // 'secondaryKey' => 'r.id', - // ] + [ + 'join' => 'leftjoin', + 'table' => 'currencies as curr', + 'primaryKey' => 'cer.target_currency', + 'condition' => '=', + 'secondaryKey' => 'curr.id', + ] ], //use aliasing on secodary columns if join is performed @@ -70,39 +70,38 @@ class ExchangeRatesDataGrid 'columns' => [ [ - 'name' => 'id', + 'name' => 'cer.id', 'alias' => 'exchID', 'type' => 'number', 'label' => 'Rate ID', 'sortable' => true, ], [ - 'name' => 'target_currency', - 'alias' => 'exchTargetCurrency', + 'name' => 'curr.name', + 'alias' => 'currencyname', 'type' => 'string', - 'label' => 'Target Currency', + 'label' => 'Currency Name', 'sortable' => true, ], [ - 'name' => 'rate', + 'name' => 'cer.rate', 'alias' => 'exchRate', 'type' => 'string', 'label' => 'Exchange Rate', ], - ], //don't use aliasing in case of filters 'filterable' => [ [ - 'column' => 'id', + 'column' => 'cer.id', 'alias' => 'exchId', 'type' => 'number', 'label' => 'Rate ID', ], [ - 'column' => 'target_currency', + 'column' => 'curr.name', 'alias' => 'exchTargetCurrency', 'type' => 'string', 'label' => 'Target Currency', diff --git a/packages/Webkul/Admin/src/DataGrids/OrderDataGrid.php b/packages/Webkul/Admin/src/DataGrids/OrderDataGrid.php index d61e4a429..9d5678b37 100644 --- a/packages/Webkul/Admin/src/DataGrids/OrderDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/OrderDataGrid.php @@ -29,7 +29,8 @@ class OrderDataGrid 'table' => 'orders as or', 'select' => 'or.id', 'perpage' => 5, - 'aliased' => true, //use this with false as default and true in case of joins + 'aliased' => false, + //True in case of joins else aliasing key required on all cases 'massoperations' =>[ [ @@ -40,36 +41,9 @@ class OrderDataGrid ], ], - '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', - ], - ], + 'actions' => [ ], - 'join' => [ - // [ - // 'join' => 'leftjoin', - // 'table' => 'order_address as oa', - // 'primaryKey' => 'or.id', - // 'condition' => '=', - // 'secondaryKey' => 'oa.order_id', - // ], - // [ - // 'join' => 'leftjoin', - // 'table' => 'category_translations as cta', - // 'primaryKey' => 'cat.parent_id', - // 'condition' => '=', - // 'secondaryKey' => 'cta.category_id', - // ], - ], + 'join' => [], //use aliasing on secodary columns if join is performed @@ -81,63 +55,62 @@ class OrderDataGrid 'label' => 'ID', 'sortable' => true, ], [ - 'name' => 'or.status', - 'alias' => 'orstatus', + 'name' => 'or.customer_first_name', + 'alias' => 'oafirstname', 'type' => 'string', - 'label' => 'Status', - 'sortable' => true, - // 'wrapper' => function ($value) { - // if($value == 0) - // return "False"; - // else - // return "True"; - // }, + 'label' => 'Billed To', + 'sortable' => false, ], [ 'name' => 'or.base_grand_total', 'alias' => 'orbasegrandtotal', 'type' => 'string', 'label' => 'Base Total', 'sortable' => true, + 'wrapper' => function ($value) { + return core()->currency($value); + } + ], [ + 'name' => 'or.grand_total', + 'alias' => 'oagrandtotal', + 'type' => 'string', + 'label' => 'Grand Total', + 'sortable' => false, + 'wrapper' => function ($value) { + return core()->currency($value); + } + ], [ + 'name' => 'or.status', + 'alias' => 'orstatus', + 'type' => 'string', + 'label' => 'Status', + 'sortable' => true, + 'wrapper' => function ($value) { + if($value == 'completed') + return 'Completed'; + else if($value == "cancelled") + return 'Completed'; + else if($value == "closed") + return 'Completed'; + else if($value == "pending") + return 'Pending'; + + }, ], - // [ - // 'name' => 'or.customer_first_name', - // 'alias' => 'oafirstname', - // 'type' => 'string', - // 'label' => 'Billed To', - // 'sortable' => false, - // ], [ - // 'name' => 'oa.first_name', - // 'alias' => 'oafirstname', - // 'type' => 'string', - // 'label' => 'Shipped To', - // 'sortable' => false, - // ], ], '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', - // ], + [ + 'column' => 'or.id', + 'alias' => 'orderid', + 'type' => 'number', + 'label' => 'ID', + ], [ + 'name' => 'or.status', + 'alias' => 'orstatus', + 'type' => 'string', + 'label' => 'Status' + ] ], - //don't use aliasing in case of searchables 'searchable' => [ diff --git a/packages/Webkul/Admin/src/DataGrids/UserDataGrid.php b/packages/Webkul/Admin/src/DataGrids/UserDataGrid.php index 85432930a..d639b1071 100644 --- a/packages/Webkul/Admin/src/DataGrids/UserDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/UserDataGrid.php @@ -111,13 +111,7 @@ class UserDataGrid 'label' => 'Role Name', 'sortable' => true, ], - [ - 'name' => 'r.id', - 'alias' => 'xc', - 'type' => 'string', - 'label' => 'Role ID', - 'sortable' => true, - ], + ], //don't use aliasing in case of filters 'filterable' => [ @@ -133,12 +127,7 @@ class UserDataGrid 'type' => 'number', 'label' => 'Admin ID' ], - [ - 'column' => 'r.id', - 'alias' => 'xc', - 'type' => 'number', - 'label' => 'Role ID' - ] + ], //don't use aliasing in case of searchables 'searchable' => [ diff --git a/packages/Webkul/Admin/src/Providers/EventServiceProvider.php b/packages/Webkul/Admin/src/Providers/EventServiceProvider.php index 8b5747b22..6eb34a845 100644 --- a/packages/Webkul/Admin/src/Providers/EventServiceProvider.php +++ b/packages/Webkul/Admin/src/Providers/EventServiceProvider.php @@ -29,19 +29,21 @@ class EventServiceProvider extends ServiceProvider 'route' => 'admin.sales.orders.index', 'sort' => 1, 'icon-class' => '', - ], [ - 'key' => 'sales.shipments', - 'name' => 'Shipments', - 'route' => 'admin.sales.orders.index', - 'sort' => 2, - 'icon-class' => '', - ], [ - 'key' => 'sales.invoices', - 'name' => 'Invoices', - 'route' => 'admin.sales.orders.index', - 'sort' => 3, - 'icon-class' => '', - ], [ + ], + // [ + // 'key' => 'sales.shipments', + // 'name' => 'Shipments', + // 'route' => 'admin.sales.orders.index', + // 'sort' => 2, + // 'icon-class' => '', + // ], [ + // 'key' => 'sales.invoices', + // 'name' => 'Invoices', + // 'route' => 'admin.sales.orders.index', + // 'sort' => 3, + // 'icon-class' => '', + // ], + [ 'key' => 'catalog', 'name' => 'Catalog', 'route' => 'admin.catalog.products.index', diff --git a/packages/Webkul/Admin/src/Resources/views/sales/orders/index.blade.php b/packages/Webkul/Admin/src/Resources/views/sales/orders/index.blade.php index 927a6334f..696d9c3c7 100644 --- a/packages/Webkul/Admin/src/Resources/views/sales/orders/index.blade.php +++ b/packages/Webkul/Admin/src/Resources/views/sales/orders/index.blade.php @@ -1,10 +1,10 @@ -@extends('admin::layouts.master') +@extends('admin::layouts.content') @section('page_title') {{ __('admin::app.sales.orders.title') }} @stop -@section('content-wrapper') +@section('content')