diff --git a/packages/Webkul/Admin/src/DataGrids/AttributeDataGrid.php b/packages/Webkul/Admin/src/DataGrids/AttributeDataGrid.php index bb6caf11c..f72434417 100644 --- a/packages/Webkul/Admin/src/DataGrids/AttributeDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/AttributeDataGrid.php @@ -2,213 +2,141 @@ namespace Webkul\Admin\DataGrids; -use Illuminate\View\View; -use Webkul\Ui\DataGrid\Facades\DataGrid; +use Webkul\Ui\DataGrid\AbsGrid; +use DB; /** - * Attributes DataGrid + * Product Data Grid class * - * @author Prashant Singh @prashant-webkul + * @author Prashant Singh @prashant-webkul * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) */ -class AttributeDataGrid +class AttributeDataGrid extends AbsGrid { + public $allColumns = []; - /** - * The Data Grid implementation for Attributes - */ - public function createAttributeDataGrid() + public function prepareQueryBuilder() { + $queryBuilder = DB::table('attributes')->select('id')->addSelect($this->columns); - return DataGrid::make([ - 'name' => 'Attributes', - 'table' => 'attributes', - 'select' => 'id', - 'perpage' => 10, - 'aliased' => true, + $this->setQueryBuilder($queryBuilder); + } - 'massoperations' => [ - 0 => [ - 'type' => 'delete', //all lower case will be shifted in the configuration file for better control and increased fault tolerance - 'action' => route('admin.catalog.attributes.massdelete'), - 'method' => 'DELETE' - ] - ], - - 'actions' => [ - [ - 'type' => 'Edit', - 'route' => 'admin.catalog.attributes.edit', - 'confirm_text' => 'Do you really want to edit this record?', - 'icon' => 'icon pencil-lg-icon', - ], [ - 'type' => 'Delete', - 'route' => 'admin.catalog.attributes.delete', - 'confirm_text' => 'Do you really want to delete this record?', - 'icon' => 'icon trash-icon', - ], - ], - - 'join' => [], - - //use aliasing on secodary columns if join is performed - 'columns' => [ - [ - 'name' => 'id', - 'alias' => 'attributeId', - 'type' => 'number', - 'label' => 'ID', - 'sortable' => true, - ], [ - 'name' => 'code', - 'alias' => 'attributeCode', - 'type' => 'string', - 'label' => 'Code', - 'sortable' => true, - ], [ - 'name' => 'admin_name', - 'alias' => 'attributeAdminName', - 'type' => 'string', - 'label' => 'Name', - 'sortable' => true, - ], [ - 'name' => 'type', - 'alias' => 'attributeType', - 'type' => 'string', - 'label' => 'Type', - 'sortable' => true, - ], [ - 'name' => 'is_required', - 'alias' => 'attributeIsRequired', - 'type' => 'boolean', - 'label' => 'Required', - 'sortable' => true, - 'wrapper' => function ($value) { - if($value == 0) - return "False"; - else - return "True"; - }, - ], [ - 'name' => 'is_unique', - 'alias' => 'attributeIsUnique', - 'type' => 'boolean', - 'label' => 'Unique', - 'sortable' => true, - 'wrapper' => function ($value) { - if($value == 0) - return "False"; - else - return "True"; - }, - ], [ - 'name' => 'value_per_locale', - 'alias' => 'attributeValuePerLocale', - 'type' => 'boolean', - 'label' => 'Locale based', - 'sortable' => true, - 'wrapper' => function ($value) { - if($value == 0) - return "False"; - else - return "True"; - }, - ], [ - 'name' => 'value_per_channel', - 'alias' => 'attributeValuePerChannel', - 'type' => 'boolean', - 'label' => 'Channel based', - 'sortable' => true, - 'wrapper' => function ($value) { - if($value == 0) - return "False"; - else - return "True"; - }, - ] - ], - - 'filterable' => [ - [ - 'column' => 'id', - 'alias' => 'attributeId', - 'type' => 'number', - 'label' => 'ID', - ], [ - 'column' => 'code', - 'alias' => 'attributeCode', - 'type' => 'string', - 'label' => 'Code', - ], [ - 'column' => 'admin_name', - 'alias' => 'attributeAdminName', - 'type' => 'string', - 'label' => 'Name', - ], [ - 'column' => 'type', - 'alias' => 'attributeType', - 'type' => 'string', - 'label' => 'Type', - ], [ - 'column' => 'is_required', - 'alias' => 'attributeIsRequired', - 'type' => 'boolean', - 'label' => 'Required', - ], [ - 'column' => 'is_unique', - 'alias' => 'attributeIsUnique', - 'type' => 'boolean', - 'label' => 'Unique', - ], [ - 'column' => 'value_per_locale', - 'alias' => 'attributeValuePerLocale', - 'type' => 'boolean', - 'label' => 'Locale based', - ], [ - 'column' => 'value_per_channel', - 'alias' => 'attributeValuePerChannel', - 'type' => 'boolean', - 'label' => 'Channel based', - ] - ], - - //don't use aliasing in case of searchables - 'searchable' => [ - [ - 'column' => 'code', - 'alias' => 'attributeCode', - 'type' => 'string', - ], [ - 'column' => 'admin_name', - 'alias' => 'attributeAdminName', - 'type' => 'string', - ], [ - 'column' => 'type', - 'alias' => 'attributeType', - 'type' => 'string', - ], - ], - - //list of viable operators that will be used - 'operators' => [ - 'eq' => "=", - 'lt' => "<", - 'gt' => ">", - 'lte' => "<=", - 'gte' => ">=", - 'neqs' => "<>", - 'neqn' => "!=", - 'like' => "like", - 'nlike' => "not like", - ], - - // 'css' => [] + public function addColumns() + { + $this->addColumn([ + 'column' => 'id', + 'alias' => 'attributeId', + 'label' => 'ID', + 'type' => 'number', + 'searchable' => false, + 'sortable' => true, + 'width' => '40px' ]); + $this->addColumn([ + 'column' => 'code', + 'alias' => 'attributeCode', + 'label' => 'Code', + 'type' => 'string', + 'searchable' => true, + 'sortable' => true, + 'width' => '100px' + ]); + + $this->addColumn([ + 'column' => 'admin_name', + 'alias' => 'attributeAdminName', + 'label' => 'Name', + 'type' => 'string', + 'searchable' => true, + 'sortable' => true, + 'width' => '100px' + ]); + + $this->addColumn([ + 'column' => 'type', + 'alias' => 'attributeType', + 'label' => 'Type', + 'type' => 'string', + 'sortable' => true, + 'searchable' => true, + 'width' => '100px' + ]); + + $this->addColumn([ + 'column' => 'is_required', + 'alias' => 'attributeRequired', + 'label' => 'Required', + 'type' => 'boolean', + 'sortable' => true, + 'searchable' => false, + 'width' => '100px' + ]); + + $this->addColumn([ + 'column' => 'is_unique', + 'alias' => 'attributeIsUnique', + 'label' => 'Unique', + 'type' => 'boolean', + 'sortable' => true, + 'searchable' => false, + 'width' => '100px' + ]); + + $this->addColumn([ + 'column' => 'value_per_locale', + 'alias' => 'attributeValuePerLocale', + 'label' => 'Locale Based', + 'type' => 'boolean', + 'sortable' => true, + 'searchable' => false, + 'width' => '100px' + ]); + + $this->addColumn([ + 'column' => 'value_per_channel', + 'alias' => 'attributeValuePerChannel', + 'label' => 'Channel Based', + 'type' => 'boolean', + 'sortable' => true, + 'searchable' => false, + 'width' => '100px' + ]); + } + + public function prepareActions() { + $this->prepareAction([ + 'type' => 'Edit', + 'route' => 'admin.catalog.attributes.edit', + 'icon' => 'icon pencil-lg-icon' + ]); + + $this->prepareAction([ + 'type' => 'Delete', + 'route' => 'admin.catalog.attributes.delete', + 'icon' => 'icon trash-icon' + ]); + } + + public function prepareMassActions() { + $this->prepareMassAction([ + 'type' => 'delete', + 'action' => route('admin.catalog.attributes.massdelete'), + 'method' => 'DELETE' + ]); } public function render() { - return $this->createAttributeDataGrid()->render(); + $this->addColumns(); + + $this->prepareActions(); + + $this->prepareMassActions(); + + $this->prepareQueryBuilder(); + + return view('ui::testgrid.table')->with('results', ['records' => $this->getCollection(), 'columns' => $this->allColumns, 'actions' => $this->actions, 'massactions' => $this->massActions]); } } \ No newline at end of file diff --git a/packages/Webkul/Admin/src/DataGrids/AttributeFamilyDataGrid.php b/packages/Webkul/Admin/src/DataGrids/AttributeFamilyDataGrid.php index 32df17782..519cc8d08 100644 --- a/packages/Webkul/Admin/src/DataGrids/AttributeFamilyDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/AttributeFamilyDataGrid.php @@ -2,143 +2,102 @@ namespace Webkul\Admin\DataGrids; -use Illuminate\View\View; -use Webkul\Ui\DataGrid\Facades\DataGrid; +use Webkul\Ui\DataGrid\AbsGrid; +use DB; /** - * Attributes Family DataGrid + * Product Data Grid class * - * @author Prashant Singh @prashant-webkul + * @author Prashant Singh @prashant-webkul * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) */ -class AttributeFamilyDataGrid +class AttributeFamilyDataGrid extends AbsGrid { + public $allColumns = []; - /** - * The Data Grid implementation for Attribute Families - */ - public function createAttributeFamilyDataGrid() + public function prepareQueryBuilder() { + $queryBuilder = DB::table('attribute_families')->select('id')->addSelect($this->columns); - return DataGrid::make([ - 'name' => 'Attribute Family', - 'table' => 'attribute_families', - 'select' => 'id', - 'perpage' => 10, - 'aliased' => false, //use this with false as default and true in case of joins - - 'massoperations' =>[ - // [ - // 'route' => route('admin.datagrid.delete'), - // 'method' => 'DELETE', - // 'label' => 'Delete', - // 'type' => 'button', - // ], - ], - - 'actions' => [ - [ - 'type' => 'Edit', - 'route' => 'admin.catalog.families.edit', - 'confirm_text' => 'Do you really want to edit this record?', - 'icon' => 'icon pencil-lg-icon', - ], [ - 'type' => 'Delete', - 'route' => 'admin.catalog.families.delete', - 'confirm_text' => 'Do you really want to delete this record?', - 'icon' => 'icon trash-icon', - ], - ], - - 'join' => [ - // [ - // 'join' => 'leftjoin', - // 'table' => 'roles as r', - // 'primaryKey' => 'u.role_id', - // 'condition' => '=', - // 'secondaryKey' => 'r.id', - // ] - ], - - //use aliasing on secodary columns if join is performed - - 'columns' => [ - [ - 'name' => 'id', - 'alias' => 'attributeFamilyId', - 'type' => 'number', - 'label' => 'ID', - 'sortable' => true, - ], [ - 'name' => 'code', - 'alias' => 'attributeFamilyCode', - 'type' => 'string', - 'label' => 'Code', - 'sortable' => true, - ], [ - 'name' => 'name', - 'alias' => 'attributeFamilyName', - 'type' => 'string', - 'label' => 'Name', - 'sortable' => true, - ], - ], - - 'filterable' => [ - [ - 'column' => 'id', - 'alias' => 'attributeFamilyId', - 'type' => 'number', - 'label' => 'ID', - ], [ - 'column' => 'code', - 'alias' => 'attributeFamilyCode', - 'type' => 'string', - 'label' => 'Code', - ], [ - 'column' => 'name', - 'alias' => 'attributeFamilyName', - 'type' => 'string', - 'label' => 'Name', - ], - ], - - //don't use aliasing in case of searchables - - 'searchable' => [ - [ - 'column' => 'name', - 'type' => 'string', - 'label' => 'Name', - ], [ - 'column' => 'code', - 'type' => 'string', - 'label' => 'Code', - ], - ], - - //list of viable operators that will be used - 'operators' => [ - 'eq' => "=", - 'lt' => "<", - 'gt' => ">", - 'lte' => "<=", - 'gte' => ">=", - 'neqs' => "<>", - 'neqn' => "!=", - 'like' => "like", - 'nlike' => "not like", - ], - // 'css' => [] + $this->setQueryBuilder($queryBuilder); + } + public function addColumns() + { + $this->addColumn([ + 'column' => 'id', + 'alias' => 'attributeFamilyId', + 'label' => 'ID', + 'type' => 'number', + 'searchable' => false, + 'sortable' => true, + 'width' => '40px' ]); + $this->addColumn([ + 'column' => 'code', + 'alias' => 'attributeFamilyCode', + 'label' => 'Code', + 'type' => 'string', + 'searchable' => true, + 'sortable' => true, + 'width' => '100px' + ]); + + $this->addColumn([ + 'column' => 'name', + 'alias' => 'attributeFamilyName', + 'label' => 'Name', + 'type' => 'string', + 'searchable' => true, + 'sortable' => true, + 'width' => '100px' + ]); + } + + public function prepareActions() { + $this->prepareAction([ + 'type' => 'Edit', + 'route' => 'admin.catalog.families.edit', + 'icon' => 'icon pencil-lg-icon' + ]); + + $this->prepareAction([ + 'type' => 'Delete', + 'route' => 'admin.catalog.families.delete', + // 'confirm_text' => trans('ui::app.datagrid.massaction.delete', ['resource' => 'product']), + '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, + // ] + // ]); } public function render() { + $this->addColumns(); - return $this->createAttributeFamilyDataGrid()->render(); + $this->prepareActions(); + $this->prepareMassActions(); + + $this->prepareQueryBuilder(); + + return view('ui::testgrid.table')->with('results', ['records' => $this->getCollection(), 'columns' => $this->allColumns, 'actions' => $this->actions, 'massactions' => $this->massActions]); } } \ 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 d50599b20..7c4bd5754 100644 --- a/packages/Webkul/Admin/src/DataGrids/CategoryDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/CategoryDataGrid.php @@ -2,176 +2,122 @@ namespace Webkul\Admin\DataGrids; -use Illuminate\View\View; -use Webkul\Ui\DataGrid\Facades\DataGrid; - +use Webkul\Ui\DataGrid\AbsGrid; +use DB; /** - * Category DataGrid + * Product Data Grid class * - * @author Prashant Singh @prashant-webkul + * @author Prashant Singh @prashant-webkul * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) */ -class CategoryDataGrid +class CategoryDataGrid extends AbsGrid { + public $allColumns = []; - /** - * The Data Grid implementation for category - */ - public function createCategoryDataGrid() + public function prepareQueryBuilder() { + $queryBuilder = DB::table('categories as cat')->select('cat.id')->addSelect($this->columns)->leftJoin('category_translations as ct', 'cat.id', '=', 'ct.category_id'); - return DataGrid::make([ - 'name' => 'Categories', - 'table' => 'categories as cat', - 'select' => 'cat.id', - 'perpage' => 10, - 'aliased' => true, //use this with false as default and true in case of joins + $this->setQueryBuilder($queryBuilder); + } - 'massoperations' =>[ - // [ - // 'route' => route('admin.datagrid.delete'), - // 'method' => 'DELETE', - // 'label' => 'Delete', - // 'type' => 'button', - // ] - ], - - 'actions' => [ - [ - 'type' => 'Edit', - 'route' => 'admin.catalog.categories.edit', - 'confirm_text' => 'Do you really want to edit this record?', - 'icon' => 'icon pencil-lg-icon', - ], [ - 'type' => 'Delete', - 'route' => 'admin.catalog.categories.delete', - 'confirm_text' => 'Do you really want to delete this record?', - 'icon' => 'icon trash-icon', - ] - ], - - 'join' => [ - [ - 'join' => 'leftjoin', - 'table' => 'category_translations as ct', - 'primaryKey' => 'cat.id', - 'condition' => '=', - 'secondaryKey' => 'ct.category_id', - 'conditions' => [ - 'condition' => ['ct.locale', app()->getLocale()] - ] - ], [ - 'join' => 'leftjoin', - 'table' => 'product_categories as pc', - 'primaryKey' => 'cat.id', - 'condition' => '=', - 'secondaryKey' => 'pc.category_id' - ] - ], - - //use aliasing on secodary columns if join is performed - - 'columns' => [ - [ - 'name' => 'cat.id', - 'alias' => 'catid', - 'type' => 'number', - 'label' => 'ID', - 'sortable' => true, - ], [ - 'name' => 'ct.name', - 'alias' => 'catname', - 'type' => 'string', - 'label' => 'Name', - 'sortable' => true, - ], [ - 'name' => 'cat.position', - 'alias' => 'catposition', - 'type' => 'string', - 'label' => 'Position', - 'sortable' => true, - ], [ - 'name' => 'cat.status', - 'alias' => 'catstatus', - 'type' => 'boolean', - 'label' => 'Visible in Menu', - 'sortable' => true, - 'wrapper' => function ($value) { - if($value == 0) - return "False"; - else - return "True"; - }, - ], [ - 'name' => 'ct.locale', - 'alias' => 'catlocale', - 'type' => 'string', - 'label' => 'Locale', - 'sortable' => true, - // 'filter' => [ - // 'function' => 'orWhere', - // 'condition' => ['ct.locale', app()->getLocale()] - // ], - ] - ], - - 'filterable' => [ - [ - 'column' => 'cat.id', - 'alias' => 'catid', - 'type' => 'number', - 'label' => 'ID', - ], [ - 'column' => 'ct.name', - 'alias' => 'catname', - 'type' => 'string', - 'label' => 'Name', - ], [ - 'column' => 'cat.status', - 'alias' => 'catstatus', - 'type' => 'boolean', - 'label' => 'Visible in Menu', - ], - ], - - //don't use aliasing in case of searchables - - 'searchable' => [ - [ - 'column' => 'cat.id', - 'type' => 'number', - 'label' => 'ID', - ], [ - 'column' => 'ct.name', - 'type' => 'string', - 'label' => 'Name', - ], [ - 'column' => 'cat.status', - 'type' => 'string', - 'label' => 'Visible in Menu', - ] - ], - - //list of viable operators that will be used - 'operators' => [ - 'eq' => "=", - 'lt' => "<", - 'gt' => ">", - 'lte' => "<=", - 'gte' => ">=", - 'neqs' => "<>", - 'neqn' => "!=", - 'like' => "like", - 'nlike' => "not like", - ], - // 'css' => [] + public function addColumns() + { + $this->addColumn([ + 'column' => 'cat.id', + 'alias' => 'catId', + 'label' => 'ID', + 'type' => 'number', + 'searchable' => false, + 'sortable' => true, + 'width' => '40px' ]); + + $this->addColumn([ + 'column' => 'ct.name', + 'alias' => 'catName', + 'label' => 'Name', + 'type' => 'string', + 'searchable' => true, + 'sortable' => true, + 'width' => '100px' + ]); + + $this->addColumn([ + 'column' => 'cat.position', + 'alias' => 'catPosition', + 'label' => 'Position', + 'type' => 'string', + 'searchable' => true, + 'sortable' => true, + 'width' => '100px' + ]); + + $this->addColumn([ + 'column' => 'cat.status', + 'alias' => 'catStatus', + 'label' => 'Type', + 'type' => 'boolean', + 'sortable' => true, + 'searchable' => true, + 'width' => '100px' + ]); + + $this->addColumn([ + 'column' => 'ct.locale', + 'alias' => 'catLocale', + 'label' => 'Locale', + 'type' => 'boolean', + 'sortable' => true, + 'searchable' => false, + 'width' => '100px' + ]); + } + + public function prepareActions() { + $this->prepareAction([ + 'type' => 'Edit', + 'route' => 'admin.catalog.products.edit', + 'icon' => 'icon pencil-lg-icon' + ]); + + $this->prepareAction([ + 'type' => 'Delete', + 'route' => 'admin.catalog.products.delete', + 'confirm_text' => trans('ui::app.datagrid.massaction.delete', ['resource' => 'product']), + '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, + // ] + // ]); } public function render() { - return $this->createCategoryDataGrid()->render(); + $this->addColumns(); + $this->prepareActions(); + + $this->prepareMassActions(); + + $this->prepareQueryBuilder(); + + return view('ui::testgrid.table')->with('results', ['records' => $this->getCollection(), 'columns' => $this->allColumns, 'actions' => $this->actions, 'massactions' => $this->massActions]); } } \ No newline at end of file diff --git a/packages/Webkul/Admin/src/DataGrids/ChannelDataGrid.php b/packages/Webkul/Admin/src/DataGrids/ChannelDataGrid.php index 87c9bde98..b6718f0fe 100644 --- a/packages/Webkul/Admin/src/DataGrids/ChannelDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/ChannelDataGrid.php @@ -2,157 +2,112 @@ namespace Webkul\Admin\DataGrids; -use Illuminate\View\View; -use Webkul\Ui\DataGrid\Facades\DataGrid; - +use Webkul\Ui\DataGrid\AbsGrid; +use DB; /** - * Channels DataGrid + * Channel Data Grid class * - * @author Prashant Singh @prashant-webkul + * @author Prashant Singh @prashant-webkul * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) */ -class ChannelDataGrid +class ChannelDataGrid extends AbsGrid { + public $allColumns = []; - /** - * The Data Grid implementation for channel - */ - public function createChannelsDataGrid() + public function prepareQueryBuilder() { + $queryBuilder = DB::table('channels')->select('id')->addSelect($this->columns); - return DataGrid::make([ - 'name' => 'Channels', - 'table' => 'channels', - 'select' => 'id', - 'perpage' => 10, - 'aliased' => false, //use this with false as default and true in case of joins - - 'massoperations' =>[ - // [ - // 'route' => route('admin.datagrid.delete'), - // 'method' => 'DELETE', - // 'label' => 'Delete', - // 'type' => 'button', - // ], - ], - - 'actions' => [ - [ - 'type' => 'Edit', - 'route' => 'admin.channels.edit', - 'confirm_text' => 'Do you really want to edit this record?', - 'icon' => 'icon pencil-lg-icon', - ], [ - 'type' => 'Delete', - 'route' => 'admin.channels.delete', - 'confirm_text' => 'Do you really want to delete this record?', - 'icon' => 'icon trash-icon', - ], - ], - - 'join' => [ - // [ - // 'join' => 'leftjoin', - // 'table' => 'roles as r', - // 'primaryKey' => 'u.role_id', - // 'condition' => '=', - // 'secondaryKey' => 'r.id', - // ] - ], - - //use aliasing on secodary columns if join is performed - - 'columns' => [ - [ - 'name' => 'id', - 'alias' => 'channelID', - 'type' => 'number', - 'label' => 'ID', - 'sortable' => true, - ], [ - 'name' => 'code', - 'alias' => 'channelCode', - 'type' => 'string', - 'label' => 'Code', - 'sortable' => true, - ], [ - 'name' => 'name', - 'alias' => 'channelName', - 'type' => 'string', - 'label' => 'Name', - 'sortable' => true, - ], [ - 'name' => 'hostname', - 'alias' => 'channelHostName', - 'type' => 'string', - 'label' => 'Host Name', - 'sortable' => true, - ], - ], - - //don't use aliasing in case of filters - 'filterable' => [ - [ - 'column' => 'id', - 'alias' => 'channelID', - 'type' => 'number', - 'label' => 'ID', - ], [ - 'column' => 'code', - 'alias' => 'channelCode', - 'type' => 'string', - 'label' => 'Code', - ], [ - 'column' => 'name', - 'alias' => 'channelName', - 'type' => 'string', - 'label' => 'Name', - ], - ], - - //don't use aliasing in case of searchables - - 'searchable' => [ - [ - 'column' => 'name', - 'type' => 'string', - 'label' => 'Name', - ], [ - 'column' => 'code', - 'type' => 'string', - 'label' => 'Code', - ], [ - 'column' => 'hostname', - 'type' => 'string', - 'label' => 'Host Name', - ], [ - 'column' => 'name', - 'type' => 'string', - 'label' => 'Name', - ], - ], - - //list of viable operators that will be used - 'operators' => [ - 'eq' => "=", - 'lt' => "<", - 'gt' => ">", - 'lte' => "<=", - 'gte' => ">=", - 'neqs' => "<>", - 'neqn' => "!=", - 'like' => "like", - 'nlike' => "not like", - ], - // 'css' => [] + $this->setQueryBuilder($queryBuilder); + } + public function addColumns() + { + $this->addColumn([ + 'column' => 'id', + 'alias' => 'channelId', + 'label' => 'ID', + 'type' => 'number', + 'searchable' => false, + 'sortable' => true, + 'width' => '40px' ]); + $this->addColumn([ + 'column' => 'code', + 'alias' => 'channelCode', + 'label' => 'Code', + 'type' => 'string', + 'searchable' => true, + 'sortable' => true, + 'width' => '100px' + ]); + + $this->addColumn([ + 'column' => 'name', + 'alias' => 'channelName', + 'label' => 'Name', + 'type' => 'string', + 'searchable' => true, + 'sortable' => true, + 'width' => '100px' + ]); + + $this->addColumn([ + 'column' => 'hostname', + 'alias' => 'channelHostname', + 'label' => 'Hostname', + 'type' => 'string', + 'sortable' => true, + 'searchable' => true, + 'width' => '100px' + ]); + } + + public function prepareActions() { + $this->prepareAction([ + 'type' => 'Edit', + 'route' => 'admin.channels.edit', + 'icon' => 'icon pencil-lg-icon' + ]); + + $this->prepareAction([ + 'type' => 'Delete', + 'route' => 'admin.channels.delete', + 'confirm_text' => trans('ui::app.datagrid.massaction.delete', ['resource' => 'product']), + '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, + // ] + // ]); } public function render() { - return $this->createChannelsDataGrid()->render(); + $this->addColumns(); + + $this->prepareActions(); + + $this->prepareMassActions(); + + $this->prepareQueryBuilder(); + + return view('ui::testgrid.table')->with('results', ['records' => $this->getCollection(), 'columns' => $this->allColumns, 'actions' => $this->actions, 'massactions' => $this->massActions]); } } \ No newline at end of file diff --git a/packages/Webkul/Admin/src/DataGrids/CountryDataGrid.php b/packages/Webkul/Admin/src/DataGrids/CountryDataGrid.php index a94818bc6..32679093a 100644 --- a/packages/Webkul/Admin/src/DataGrids/CountryDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/CountryDataGrid.php @@ -2,165 +2,112 @@ namespace Webkul\Admin\DataGrids; -use Illuminate\View\View; -use Webkul\Ui\DataGrid\Facades\DataGrid; - +use Webkul\Ui\DataGrid\AbsGrid; +use DB; /** - * Countries DataGrid + * Product Data Grid class * - * @author Prashant Singh @prashant-webkul + * @author Prashant Singh @prashant-webkul * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) */ -class CountryDataGrid +class CountryDataGrid extends AbsGrid { + public $allColumns = []; - /** - * The Data Grid implementation for countries - */ - public function createCountryDataGrid() + public function prepareQueryBuilder() { + $queryBuilder = DB::table('countries')->select('id')->addSelect($this->columns); - return DataGrid::make([ - 'name' => 'Countries', - 'table' => 'countries', - 'select' => 'id', - 'perpage' => 10, - 'aliased' => false, //use this with false as default and true in case of joins - - 'massoperations' =>[ - // [ - // 'route' => route('admin.datagrid.delete'), - // 'method' => 'DELETE', - // 'label' => 'Delete', - // 'type' => 'button', - // ], - ], - - 'actions' => [ - [ - 'type' => 'Edit', - 'route' => route('admin.datagrid.delete'), - 'confirm_text' => 'Do you really want to edit this record?', - 'icon' => 'icon pencil-lg-icon', - ], [ - 'type' => 'Delete', - 'route' => route('admin.datagrid.delete'), - 'confirm_text' => 'Do you really want to delete this record?', - 'icon' => 'icon trash-icon', - ], - ], - - 'join' => [ - // [ - // 'join' => 'leftjoin', - // 'table' => 'roles as r', - // 'primaryKey' => 'u.role_id', - // 'condition' => '=', - // 'secondaryKey' => 'r.id', - // ] - ], - - //use aliasing on secodary columns if join is performed - - 'columns' => [ - [ - 'name' => 'id', - 'alias' => 'countryId', - 'type' => 'number', - 'label' => 'ID', - 'sortable' => true, - ], [ - 'name' => 'code', - 'alias' => 'countryCode', - 'type' => 'string', - 'label' => 'Code', - 'sortable' => true, - ], [ - 'name' => 'name', - 'alias' => 'countryName', - 'type' => 'string', - 'label' => 'Name', - 'sortable' => true, - ], [ - 'name' => 'status', - 'alias' => 'countryStatus', - 'type' => 'number', - 'label' => 'Code', - 'sortable' => true, - ], - - ], - - //don't use aliasing in case of filters - 'filterable' => [ - [ - 'column' => 'id', - 'alias' => 'countryId', - 'type' => 'number', - 'label' => 'ID', - ], [ - 'column' => 'code', - 'alias' => 'countryCode', - 'type' => 'string', - 'label' => 'Code', - ], [ - 'column' => 'name', - 'alias' => 'countryName', - 'type' => 'string', - 'label' => 'Name', - ], [ - 'column' => 'status', - 'alias' => 'countryStatus', - 'type' => 'number', - 'label' => 'Code', - ], - ], - - //don't use aliasing in case of searchables - - 'searchable' => [ - [ - 'column' => 'name', - 'type' => 'string', - 'label' => 'Name', - ], [ - 'column' => 'code', - 'type' => 'string', - 'label' => 'Code', - ], [ - 'column' => 'name', - 'type' => 'string', - 'label' => 'Name', - ], [ - 'column' => 'status', - 'type' => 'number', - 'label' => 'Code', - ] - ], - - //list of viable operators that will be used - 'operators' => [ - 'eq' => "=", - 'lt' => "<", - 'gt' => ">", - 'lte' => "<=", - 'gte' => ">=", - 'neqs' => "<>", - 'neqn' => "!=", - 'like' => "like", - 'nlike' => "not like", - ], - // 'css' => [] + $this->setQueryBuilder($queryBuilder); + } + public function addColumns() + { + $this->addColumn([ + 'column' => 'id', + 'alias' => 'countryId', + 'label' => 'ID', + 'type' => 'number', + 'searchable' => false, + 'sortable' => true, + 'width' => '40px' ]); + $this->addColumn([ + 'column' => 'code', + 'alias' => 'countryCode', + 'label' => 'Code', + 'type' => 'string', + 'searchable' => true, + 'sortable' => true, + 'width' => '100px' + ]); + + $this->addColumn([ + 'column' => 'name', + 'alias' => 'countryName', + 'label' => 'Name', + 'type' => 'string', + 'searchable' => true, + 'sortable' => true, + 'width' => '100px' + ]); + + $this->addColumn([ + 'column' => 'status', + 'alias' => 'countryStatus', + 'label' => 'Status', + 'type' => 'number', + 'sortable' => true, + 'searchable' => true, + 'width' => '100px' + ]); + } + + public function prepareActions() { + $this->prepareAction([ + 'type' => 'Edit', + 'route' => 'admin.catalog.products.edit', + 'icon' => 'icon pencil-lg-icon' + ]); + + $this->prepareAction([ + 'type' => 'Delete', + 'route' => 'admin.catalog.products.delete', + 'confirm_text' => trans('ui::app.datagrid.massaction.delete', ['resource' => 'product']), + '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, + // ] + // ]); } public function render() { + $this->addColumns(); - return $this->createCountryDataGrid()->render(); + $this->prepareActions(); + $this->prepareMassActions(); + + $this->prepareQueryBuilder(); + + return view('ui::testgrid.table')->with('results', ['records' => $this->getCollection(), 'columns' => $this->allColumns, 'actions' => $this->actions, 'massactions' => $this->massActions]); } } \ No newline at end of file diff --git a/packages/Webkul/Admin/src/DataGrids/CurrencyDataGrid.php b/packages/Webkul/Admin/src/DataGrids/CurrencyDataGrid.php index a53903a99..f4c3919ad 100644 --- a/packages/Webkul/Admin/src/DataGrids/CurrencyDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/CurrencyDataGrid.php @@ -2,146 +2,101 @@ namespace Webkul\Admin\DataGrids; -use Illuminate\View\View; -use Webkul\Ui\DataGrid\Facades\DataGrid; +use Webkul\Ui\DataGrid\AbsGrid; +use DB; /** - * Currencies DataGrid + * Currency Data Grid class * - * @author Prashant Singh @prashant-webkul + * @author Prashant Singh @prashant-webkul * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) */ -class CurrencyDataGrid +class CurrencyDataGrid extends AbsGrid { + public $allColumns = []; - /** - * The Data Grid implementation for currencies - */ - public function createCurrencyDataGrid() + public function prepareQueryBuilder() { + $queryBuilder = DB::table('currencies')->select('id')->addSelect($this->columns); - return DataGrid::make([ - 'name' => 'Currencies', - 'table' => 'currencies', - 'select' => 'id', - 'perpage' => 10, - 'aliased' => false, //use this with false as default and true in case of joins - - 'massoperations' =>[ - 0 => [ - 'type' => 'delete', //all lower case will be shifted in the configuration file for better control and increased fault tolerance - 'action' => route('admin.currencies.massdelete'), - 'method' => 'DELETE' - ] - ], - - 'actions' => [ - [ - 'type' => 'Edit', - 'route' => 'admin.currencies.edit', - // 'confirm_text' => 'Do you really want to edit this record?', - 'icon' => 'icon pencil-lg-icon', - ], [ - 'type' => 'Delete', - 'route' => 'admin.currencies.delete', - 'confirm_text' => 'Do you really want to delete this record?', - 'icon' => 'icon trash-icon', - ], - ], - - 'join' => [ - // [ - // 'join' => 'leftjoin', - // 'table' => 'roles as r', - // 'primaryKey' => 'u.role_id', - // 'condition' => '=', - // 'secondaryKey' => 'r.id', - // ] - ], - - //use aliasing on secodary columns if join is performed - 'columns' => [ - [ - 'name' => 'id', - 'alias' => 'currencyId', - 'type' => 'number', - 'label' => 'ID', - 'sortable' => true, - ], [ - 'name' => 'code', - 'alias' => 'currencyCode', - 'type' => 'string', - 'label' => 'Code', - 'sortable' => true, - ], [ - 'name' => 'name', - 'alias' => 'currencyName', - 'type' => 'string', - 'label' => 'Name', - 'sortable' => true, - ], - - ], - - //don't use aliasing in case of filters - - 'filterable' => [ - [ - 'column' => 'id', - 'alias' => 'currencyId', - 'type' => 'number', - 'label' => 'ID', - ], [ - 'column' => 'code', - 'alias' => 'currencyCode', - 'type' => 'string', - 'label' => 'Code', - ], [ - 'column' => 'name', - 'alias' => 'currencyName', - 'type' => 'string', - 'label' => 'Name', - ], - ], - - //don't use aliasing in case of searchables - - 'searchable' => [ - [ - 'column' => 'id', - 'alias' => 'currencyId', - 'type' => 'number', - ], [ - 'column' => 'name', - 'type' => 'string', - 'label' => 'Name', - ], [ - 'column' => 'code', - 'type' => 'string', - 'label' => 'Code', - ], - ], - - //list of viable operators that will be used - 'operators' => [ - 'eq' => "=", - 'lt' => "<", - 'gt' => ">", - 'lte' => "<=", - 'gte' => ">=", - 'neqs' => "<>", - 'neqn' => "!=", - 'like' => "like", - 'nlike' => "not like", - ], - // 'css' => [] + $this->setQueryBuilder($queryBuilder); + } + public function addColumns() + { + $this->addColumn([ + 'column' => 'id', + 'alias' => 'currencyId', + 'label' => 'ID', + 'type' => 'number', + 'searchable' => false, + 'sortable' => true, + 'width' => '40px' ]); + $this->addColumn([ + 'column' => 'name', + 'alias' => 'currencyName', + 'label' => 'Name', + 'type' => 'string', + 'searchable' => true, + 'sortable' => true, + 'width' => '100px' + ]); + + $this->addColumn([ + 'column' => 'code', + 'alias' => 'currencyCode', + 'label' => 'Code', + 'type' => 'string', + 'searchable' => true, + 'sortable' => true, + 'width' => '100px' + ]); + } + + public function prepareActions() { + $this->prepareAction([ + 'type' => 'Edit', + 'route' => 'admin.currencies.edit', + 'icon' => 'icon pencil-lg-icon' + ]); + + $this->prepareAction([ + 'type' => 'Delete', + 'route' => 'admin.currencies.delete', + '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, + // ] + // ]); } public function render() { - return $this->createCurrencyDataGrid()->render(); + $this->addColumns(); + + $this->prepareActions(); + + $this->prepareMassActions(); + + $this->prepareQueryBuilder(); + + return view('ui::testgrid.table')->with('results', ['records' => $this->getCollection(), 'columns' => $this->allColumns, 'actions' => $this->actions, 'massactions' => $this->massActions]); } } \ No newline at end of file diff --git a/packages/Webkul/Admin/src/DataGrids/CustomerDataGrid.php b/packages/Webkul/Admin/src/DataGrids/CustomerDataGrid.php index 1168a72a6..cfe1e4643 100644 --- a/packages/Webkul/Admin/src/DataGrids/CustomerDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/CustomerDataGrid.php @@ -2,149 +2,112 @@ namespace Webkul\Admin\DataGrids; -use Illuminate\View\View; -use Webkul\Ui\DataGrid\Facades\DataGrid; +use Webkul\Ui\DataGrid\AbsGrid; +use DB; /** - * Customer DataGrid + * Currency Data Grid class * - * @author Rahul Shukla @rahul-webkul + * @author Prashant Singh @prashant-webkul * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) */ -class CustomerDataGrid +class CustomerDataGrid extends AbsGrid { + public $allColumns = []; - /** - * The CustomerDataGrid implementation. - */ - public function createCustomerDataGrid() + public function prepareQueryBuilder() { + $queryBuilder = DB::table('customers as cus')->select('cus.id')->addSelect($this->columns)->leftJoin('customer_groups as cg', 'cus.customer_group_id', '=', 'cg.id'); - return DataGrid::make([ - 'name' => 'Customer', - 'table' => 'customers as cus', - 'select' => 'cus.id', - 'perpage' => 10, - 'aliased' => true, //use this with false as default and true in case of joins - - 'massoperations' =>[ - // [ - // 'route' => route('admin.datagrid.delete'), - // 'method' => 'DELETE', - // 'label' => 'Delete', - // 'type' => 'button', //select || button only - // ], - ], - - 'actions' => [ - [ - 'type' => 'Edit', - 'route' => 'admin.customer.edit', - 'confirm_text' => 'Do you really want to edit this record?', - 'icon' => 'icon pencil-lg-icon', - ], [ - 'type' => 'Delete', - 'route' => 'admin.customer.delete', - 'confirm_text' => 'Do you really want to delete this record?', - 'icon' => 'icon trash-icon', - ], - ], - - 'join' => [ - [ - 'join' => 'leftjoin', - 'table' => 'customer_groups as cg', - 'primaryKey' => 'cus.customer_group_id', - 'condition' => '=', - 'secondaryKey' => 'cg.id', - ] - ], - - //use aliasing on secodary columns if join is performed - 'columns' => [ - [ - 'name' => 'cus.id', - 'alias' => 'ID', - 'type' => 'number', - 'label' => 'ID', - 'sortable' => true, - ], [ - 'name' => 'CONCAT(first_name, " ", last_name)', - 'alias' => 'Name', - 'type' => 'string', - 'label' => 'Name', - 'sortable' => true, - ], [ - 'name' => 'email', - 'alias' => 'Email', - 'type' => 'string', - 'label' => 'Email', - 'sortable' => false, - ], [ - 'name' => 'cg.name', - 'alias' => 'CustomerGroupName', - 'type' => 'string', - 'label' => 'Group Name', - 'sortable' => false, - ], - ], - - //don't use aliasing in case of filters - 'filterable' => [ - [ - 'column' => 'cus.id', - 'alias' => 'ID', - 'type' => 'number', - 'label' => 'ID', - ], [ - 'column' => 'email', - 'alias' => 'Email', - 'type' => 'string', - 'label' => 'Email', - ], [ - 'column' => 'cg.name', - 'alias' => 'CustomerGroupName', - 'type' => 'string', - 'label' => 'Group Name', - ] - ], - - //don't use aliasing in case of searchables - - 'searchable' => [ - [ - 'column' => 'FirstName', - 'type' => 'string', - 'label' => 'First Name', - ], [ - 'column' => 'email', - 'alias' => 'Email', - 'type' => 'string', - ], - ], - - //list of viable operators that will be used - 'operators' => [ - 'eq' => "=", - 'lt' => "<", - 'gt' => ">", - 'lte' => "<=", - 'gte' => ">=", - 'neqs' => "<>", - 'neqn' => "!=", - 'like' => "like", - 'nlike' => "not like", - ], - // 'css' => [] + $this->setQueryBuilder($queryBuilder); + } + public function addColumns() + { + $this->addColumn([ + 'column' => 'cus.id', + 'alias' => 'customerId', + 'label' => 'ID', + 'type' => 'number', + 'searchable' => false, + 'sortable' => true, + 'width' => '40px' ]); + $this->addColumn([ + // 'column' => 'CONCAT(cus.first_name, " ", cus.last_name)', + 'column' => 'cus.first_name', + 'alias' => 'customerFullName', + 'label' => 'Name', + 'type' => 'string', + 'searchable' => true, + 'sortable' => true, + 'width' => '100px' + ]); + + $this->addColumn([ + 'column' => 'cus.email', + 'alias' => 'customerEmail', + 'label' => 'Email', + 'type' => 'string', + 'searchable' => true, + 'sortable' => true, + 'width' => '100px' + ]); + + $this->addColumn([ + 'column' => 'cg.name', + 'alias' => 'customerGroupName', + 'label' => 'Group', + 'type' => 'string', + 'searchable' => false, + 'sortable' => true, + 'width' => '100px' + ]); } - public function render($pagination = true) + public function prepareActions() { + $this->prepareAction([ + 'type' => 'Edit', + 'route' => 'admin.customer.edit', + 'icon' => 'icon pencil-lg-icon' + ]); + + $this->prepareAction([ + 'type' => 'Delete', + 'route' => 'admin.customer.delete', + '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, + // ] + // ]); + } + + public function render() { + $this->addColumns(); - return $this->createCustomerDataGrid()->render($pagination); + $this->prepareActions(); + $this->prepareMassActions(); + + $this->prepareQueryBuilder(); + + return view('ui::testgrid.table')->with('results', ['records' => $this->getCollection(), 'columns' => $this->allColumns, 'actions' => $this->actions, 'massactions' => $this->massActions]); } } \ No newline at end of file diff --git a/packages/Webkul/Admin/src/DataGrids/CustomerGroupDataGrid.php b/packages/Webkul/Admin/src/DataGrids/CustomerGroupDataGrid.php index 8bd25c996..96880b247 100644 --- a/packages/Webkul/Admin/src/DataGrids/CustomerGroupDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/CustomerGroupDataGrid.php @@ -2,136 +2,92 @@ namespace Webkul\Admin\DataGrids; -use Illuminate\View\View; -use Webkul\Ui\DataGrid\Facades\DataGrid; +use Webkul\Ui\DataGrid\AbsGrid; +use DB; /** - * Customer Group DataGrid + * Currency Data Grid class * - * @author Rahul Shukla + * @author Prashant Singh @prashant-webkul * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) */ -class CustomerGroupDataGrid +class CustomerGroupDataGrid extends AbsGrid { + public $allColumns = []; - /** - * The Customer Group Data Grid implementation. - */ - public function createCustomerGroupDataGrid() + public function prepareQueryBuilder() { + $queryBuilder = DB::table('customer_groups')->select('id')->addSelect($this->columns); - return DataGrid::make([ - - 'name' => 'Customer Group', - 'table' => 'customer_groups as cg', - 'select' => 'cg.id', - 'perpage' => 10, - 'aliased' => true, //use this with false as default and true in case of joins - - 'massoperations' =>[ - // [ - // 'route' => route('admin.datagrid.delete'), - // 'method' => 'DELETE', - // 'label' => 'Delete', - // 'type' => 'button', - // ], - // [ - // 'route' => route('admin.datagrid.index'), - // 'method' => 'POST', - // 'label' => 'View Grid', - // 'type' => 'select', - // 'options' =>[ - // 1 => 'Edit', - // 2 => 'Set', - // 3 => 'Change Status' - // ] - // ], - ], - 'actions' => [ - [ - 'type' => 'Edit', - 'route' => 'admin.groups.edit', - 'confirm_text' => 'Do you really want to edit this record?', - 'icon' => 'icon pencil-lg-icon', - ], [ - 'type' => 'Delete', - 'route' => 'admin.groups.delete', - 'confirm_text' => 'Do you really want to delete this record?', - 'icon' => 'icon trash-icon', - ], - ], - 'join' => [ - // [ - // 'join' => 'leftjoin', - // 'table' => 'roles as r', - // 'primaryKey' => 'u.role_id', - // 'condition' => '=', - // 'secondaryKey' => 'r.id', - // ] - ], - - //use aliasing on secodary columns if join is performed - 'columns' => [ - [ - 'name' => 'cg.id', - 'alias' => 'ID', - 'type' => 'number', - 'label' => 'ID', - 'sortable' => true, - ], [ - 'name' => 'cg.name', - 'alias' => 'Name', - 'type' => 'string', - 'label' => 'Name', - 'sortable' => true, - ], - ], - - //don't use aliasing in case of filters - 'filterable' => [ - [ - 'column' => 'cg.name', - 'alias' => 'Name', - 'type' => 'string', - 'label' => 'Name' - ], [ - 'column' => 'cg.id', - 'alias' => 'ID', - 'type' => 'number', - 'label' => 'ID' - ], - ], - //don't use aliasing in case of searchables - 'searchable' => [ - [ - 'column' => 'cg.id', - 'type' => 'number', - 'label' => 'Id' - ], [ - 'column' => 'cg.name', - 'type' => 'string', - 'label' => 'Name' - ] - ], - - 'operators' => [ - 'eq' => "=", - 'lt' => "<", - 'gt' => ">", - 'lte' => "<=", - 'gte' => ">=", - 'neqs' => "<>", - 'neqn' => "!=", - 'like' => "like", - 'nlike' => "not like", - ], - // 'css' => [] + $this->setQueryBuilder($queryBuilder); + } + public function addColumns() + { + $this->addColumn([ + 'column' => 'id', + 'alias' => 'groupId', + 'label' => 'ID', + 'type' => 'number', + 'searchable' => false, + 'sortable' => true, + 'width' => '40px' ]); + $this->addColumn([ + // 'column' => 'CONCAT(cus.first_name, " ", cus.last_name)', + 'column' => 'name', + 'alias' => 'groupName', + 'label' => 'Name', + 'type' => 'string', + 'searchable' => true, + 'sortable' => true, + 'width' => '100px' + ]); } - public function render() { - return $this->createCustomerGroupDataGrid()->render(); + public function prepareActions() { + $this->prepareAction([ + 'type' => 'Edit', + 'route' => 'admin.customer.edit', + 'icon' => 'icon pencil-lg-icon' + ]); + + $this->prepareAction([ + 'type' => 'Delete', + 'route' => 'admin.customer.delete', + '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, + // ] + // ]); + } + + public function render() + { + $this->addColumns(); + + $this->prepareActions(); + + $this->prepareMassActions(); + + $this->prepareQueryBuilder(); + + return view('ui::testgrid.table')->with('results', ['records' => $this->getCollection(), 'columns' => $this->allColumns, 'actions' => $this->actions, 'massactions' => $this->massActions]); } } \ 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 b3381e2e6..f8707432f 100644 --- a/packages/Webkul/Admin/src/DataGrids/CustomerReviewDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/CustomerReviewDataGrid.php @@ -2,182 +2,121 @@ namespace Webkul\Admin\DataGrids; -use Illuminate\View\View; -use Webkul\Ui\DataGrid\Facades\DataGrid; - +use Webkul\Ui\DataGrid\AbsGrid; +use DB; /** - * CustomerReview DataGrid + * Currency Data Grid class * - * @author Rahul Shukla @rahul-webkul + * @author Prashant Singh @prashant-webkul * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) */ -class CustomerReviewDataGrid +class CustomerReviewDataGrid extends AbsGrid { + public $allColumns = []; - /** - * The ProductReviewDataGrid implementation for Product Reviews - */ - public function createCustomerReviewDataGrid() + public function prepareQueryBuilder() { + $queryBuilder = DB::table('product_reviews as pr')->select('pr.id')->addSelect($this->columns)->leftjoin('products_grid as pg', 'pr.product_id', '=', 'pg.id'); - return DataGrid::make([ - 'name' => 'Review', - 'table' => 'product_reviews as pr', - 'select' => 'pr.id', - 'perpage' => 10, - 'aliased' => true, //use this with false as default and true in case of joins - - 'massoperations' =>[ - 0 => [ - 'type' => 'delete', //all lower case will be shifted in the configuration file for better control and increased fault tolerance - 'action' => route('admin.customer.review.massdelete'), - 'method' => 'DELETE' - ], 1 => [ - 'type' => 'update', //all lower case will be shifted in the configuration file for better control and increased fault tolerance - 'action' => route('admin.customer.review.massupdate'), - 'method' => 'PUT', - 'options' => [ - 0 => 'Disapprove', - 1 => 'Approve', - ] - ] - ], - - 'actions' => [ - [ - 'type' => 'Edit', - 'route' => 'admin.customer.review.edit', - 'confirm_text' => 'Do you really want to edit this record?', - 'icon' => 'icon pencil-lg-icon', - ], [ - 'type' => 'Delete', - 'route' => 'admin.customer.review.delete', - 'confirm_text' => 'Do you really want to delete this record?', - 'icon' => 'icon trash-icon', - ], - ], - - 'join' => [ - [ - 'join' => 'leftjoin', - 'table' => 'products_grid as pt', - 'primaryKey' => 'pr.product_id', - 'condition' => '=', - 'secondaryKey' => 'pt.product_id', - ] - ], - - //use aliasing on secodary columns if join is performed - - 'columns' => [ - [ - 'name' => 'pr.id', - 'alias' => 'reviewId', - 'type' => 'number', - 'label' => 'ID', - 'sortable' => true, - ], [ - 'name' => 'pr.title', - 'alias' => 'titleName', - 'type' => 'string', - 'label' => 'Title', - 'sortable' => true, - ], [ - 'name' => 'pr.comment', - 'alias' => 'productComment', - 'type' => 'string', - 'label' => 'Comment', - 'sortable' => true, - ], [ - 'name' => 'pt.name', - 'alias' => 'productName', - 'type' => 'string', - 'label' => 'Product Name', - 'sortable' => true, - ], [ - 'name' => 'pr.status', - 'alias' => 'reviewStatus', - 'type' => 'number', - 'label' => 'Status', - 'sortable' => true, - 'closure' => true, - 'wrapper' => function ($value) { - if($value == 'approved') - return 'Approved'; - else if($value == "pending") - return 'Pending'; - }, - ], - ], - - //don't use aliasing in case of filters - 'filterable' => [ - [ - 'column' => 'pr.id', - 'alias' => 'reviewId', - 'type' => 'number', - 'label' => 'ID', - ], [ - 'column' => 'pr.title', - 'alias' => 'titleName', - 'type' => 'string', - 'label' => 'Title', - ], [ - 'column' => 'pr.comment', - 'alias' => 'productComment', - 'type' => 'string', - 'label' => 'Comment', - ], [ - 'column' => 'pt.name', - 'alias' => 'productName', - 'type' => 'string', - 'label' => 'Product Name', - ], [ - 'column' => 'pr.status', - 'alias' => 'reviewStatus', - 'type' => 'string', - 'label' => 'Status', - ], - ], - - //don't use aliasing in case of searchables - 'searchable' => [ - [ - 'column' => 'title', - 'type' => 'string', - 'label' => 'Title', - ], [ - 'column' => 'rating', - 'type' => 'number', - 'label' => 'Rating', - ], [ - 'column' => 'pt.name', - 'alias' => 'productName', - 'type' => 'string', - ], - ], - - //list of viable operators that will be used - 'operators' => [ - 'eq' => "=", - 'lt' => "<", - 'gt' => ">", - 'lte' => "<=", - 'gte' => ">=", - 'neqs' => "<>", - 'neqn' => "!=", - 'like' => "like", - 'nlike' => "not like", - ], - // 'css' => [] + $this->setQueryBuilder($queryBuilder); + } + public function addColumns() + { + $this->addColumn([ + 'column' => 'pr.id', + 'alias' => 'reviewId', + 'label' => 'ID', + 'type' => 'number', + 'searchable' => false, + 'sortable' => true, + 'width' => '40px' ]); + $this->addColumn([ + 'column' => 'pr.title', + 'alias' => 'reviewTitle', + 'label' => 'Title', + 'type' => 'string', + 'searchable' => true, + 'sortable' => true, + 'width' => '100px' + ]); + + $this->addColumn([ + 'column' => 'pr.comment', + 'alias' => 'reviewComment', + 'label' => 'Comment', + 'type' => 'string', + 'searchable' => true, + 'sortable' => true, + 'width' => '100px' + ]); + + $this->addColumn([ + 'column' => 'pg.name', + 'alias' => 'productName', + 'label' => 'Product', + 'type' => 'string', + 'searchable' => true, + 'sortable' => true, + 'width' => '100px' + ]); + + $this->addColumn([ + 'column' => 'pr.status', + 'alias' => 'reviewStatus', + 'label' => 'Status', + 'type' => 'boolean', + 'searchable' => true, + 'sortable' => true, + 'width' => '100px' + ]); + } + + public function prepareActions() { + $this->prepareAction([ + 'type' => 'Edit', + 'route' => 'admin.customer.review.edit', + 'icon' => 'icon pencil-lg-icon' + ]); + + $this->prepareAction([ + 'type' => 'Delete', + 'route' => 'admin.customer.review.delete', + '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, + ] + ]); } public function render() { - return $this->createCustomerReviewDataGrid()->render(); + $this->addColumns(); + + $this->prepareActions(); + + $this->prepareMassActions(); + + $this->prepareQueryBuilder(); + + return view('ui::testgrid.table')->with('results', ['records' => $this->getCollection(), 'columns' => $this->allColumns, 'actions' => $this->actions, 'massactions' => $this->massActions]); } } \ No newline at end of file diff --git a/packages/Webkul/Admin/src/DataGrids/ExchangeRatesDataGrid.php b/packages/Webkul/Admin/src/DataGrids/ExchangeRatesDataGrid.php index d2f9b0ef8..5ff2849a9 100644 --- a/packages/Webkul/Admin/src/DataGrids/ExchangeRatesDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/ExchangeRatesDataGrid.php @@ -2,141 +2,102 @@ namespace Webkul\Admin\DataGrids; -use Illuminate\View\View; -use Webkul\Ui\DataGrid\Facades\DataGrid; +use Webkul\Ui\DataGrid\AbsGrid; +use DB; /** - * Exchange Rates DataGrid + * Product Data Grid class * - * @author Prashant Singh @prashant-webkul + * @author Prashant Singh @prashant-webkul * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) */ -class ExchangeRatesDataGrid +class ExchangeRatesDataGrid extends AbsGrid { + public $allColumns = []; - /** - * The Data Grid implementation for Exchange Rates - */ - public function createExchangeRatesDataGrid() + public function prepareQueryBuilder() { + $queryBuilder = DB::table('currency_exchange_rates as cer')->select('cer.id')->addSelect($this->columns)->leftJoin('currencies as curr', 'cer.target_currency', '=', 'curr.id'); - return DataGrid::make([ - 'name' => 'Exchange Rates', - 'table' => 'currency_exchange_rates as cer', - 'select' => 'cer.id', - 'perpage' => 10, - 'aliased' => true, //use this with false as default and true in case of joins - - 'massoperations' =>[ - // [ - // 'route' => route('admin.datagrid.delete'), - // 'method' => 'DELETE', - // 'label' => 'Delete', - // 'type' => 'button', - // ], - ], - - 'actions' => [ - [ - 'type' => 'Edit', - 'route' => 'admin.exchange_rates.edit', - 'confirm_text' => 'Do you really want to edit this record?', - 'icon' => 'icon pencil-lg-icon', - ], [ - 'type' => 'Delete', - 'route' => 'admin.exchange_rates.delete', - 'confirm_text' => 'Do you really want to delete this record?', - 'icon' => 'icon trash-icon', - ], - ], - - 'join' => [ - [ - 'join' => 'leftjoin', - 'table' => 'currencies as curr', - 'primaryKey' => 'cer.target_currency', - 'condition' => '=', - 'secondaryKey' => 'curr.id', - ] - ], - - //use aliasing on secodary columns if join is performed - - 'columns' => [ - [ - 'name' => 'cer.id', - 'alias' => 'exchid', - 'type' => 'number', - 'label' => 'Rate ID', - 'sortable' => true, - ], [ - 'name' => 'curr.name', - 'alias' => 'exchcurrname', - 'type' => 'string', - 'label' => 'Currency Name', - 'sortable' => true, - ], [ - 'name' => 'cer.rate', - 'alias' => 'exchrate', - 'type' => 'string', - 'label' => 'Exchange Rate', - 'sortable' => true - ], - ], - - //don't use aliasing in case of filters - 'filterable' => [ - [ - 'column' => 'cer.id', - 'alias' => 'exchid', - 'type' => 'number', - 'label' => 'Rate ID', - ], [ - 'column' => 'curr.name', - 'alias' => 'exchcurrname', - 'type' => 'string', - 'label' => 'Currency Name', - ], [ - 'column' => 'cer.rate', - 'alias' => 'exchrate', - 'type' => 'string', - 'label' => 'Exchange Rate', - ], - ], - - //don't use aliasing in case of searchables - 'searchable' => [ - [ - 'column' => 'exchcurrname', - 'type' => 'string', - 'label' => 'Currency Name', - ], [ - 'column' => 'cer.rate', - 'type' => 'string', - 'label' => 'Exchange Rate', - ], - ], - - //list of viable operators that will be used - 'operators' => [ - 'eq' => "=", - 'lt' => "<", - 'gt' => ">", - 'lte' => "<=", - 'gte' => ">=", - 'neqs' => "<>", - 'neqn' => "!=", - 'like' => "like", - 'nlike' => "not like", - ], - // 'css' => [] + $this->setQueryBuilder($queryBuilder); + } + public function addColumns() + { + $this->addColumn([ + 'column' => 'cer.id', + 'alias' => 'exchId', + 'label' => 'ID', + 'type' => 'number', + 'searchable' => false, + 'sortable' => true, + 'width' => '40px' ]); + $this->addColumn([ + 'column' => 'curr.name', + 'alias' => 'exchName', + 'label' => 'Currency Name', + 'type' => 'string', + 'searchable' => true, + 'sortable' => true, + 'width' => '100px' + ]); + + $this->addColumn([ + 'column' => 'cer.rate', + 'alias' => 'exchRate', + 'label' => 'Exchange Rate', + 'type' => 'string', + 'searchable' => true, + 'sortable' => true, + 'width' => '100px' + ]); + } + + public function prepareActions() { + $this->prepareAction([ + 'type' => 'Edit', + 'route' => 'admin.exchange_rates.edit', + 'icon' => 'icon pencil-lg-icon' + ]); + + $this->prepareAction([ + 'type' => 'Delete', + 'route' => 'admin.exchange_rates.delete', + 'confirm_text' => trans('ui::app.datagrid.massaction.delete', ['resource' => 'Exchange Rate']), + '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, + // ] + // ]); } public function render() { - return $this->createExchangeRatesDataGrid()->render(); + $this->addColumns(); + + $this->prepareActions(); + + $this->prepareMassActions(); + + $this->prepareQueryBuilder(); + + return view('ui::testgrid.table')->with('results', ['records' => $this->getCollection(), 'columns' => $this->allColumns, 'actions' => $this->actions, 'massactions' => $this->massActions]); } } \ 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 65c3f3858..335160c3c 100644 --- a/packages/Webkul/Admin/src/DataGrids/InventorySourcesDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/InventorySourcesDataGrid.php @@ -2,169 +2,122 @@ namespace Webkul\Admin\DataGrids; -use Illuminate\View\View; -use Webkul\Ui\DataGrid\Facades\DataGrid; +use Webkul\Ui\DataGrid\AbsGrid; +use DB; /** - * Inventory Sources DataGrid + * Product Data Grid class * - * @author Prashant Singh @prashant-webkul + * @author Prashant Singh @prashant-webkul * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) */ -class InventorySourcesDataGrid +class InventorySourcesDataGrid extends AbsGrid { + public $allColumns = []; - /** - * The Data Grid implementation for Inventory Sources - */ - public function createInventorySourcesDataGrid() + public function prepareQueryBuilder() { - return DataGrid::make([ - 'name' => 'Inventory Sources', - 'table' => 'inventory_sources', - 'select' => 'id', - 'perpage' => 10, - 'aliased' => false, //use this with false as default and true in case of joins + $queryBuilder = DB::table('inventory_sources')->select('id')->addSelect($this->columns); - 'massoperations' =>[ - // [ - // 'route' => route('admin.datagrid.delete'), - // 'method' => 'DELETE', - // 'label' => 'Delete', - // 'type' => 'button', - // ], - ], - - 'actions' => [ - [ - 'type' => 'Edit', - 'route' => 'admin.inventory_sources.edit', - 'confirm_text' => 'Do you really want to edit this record?', - 'icon' => 'icon pencil-lg-icon', - ], [ - 'type' => 'Delete', - 'route' => 'admin.inventory_sources.delete', - 'confirm_text' => 'Do you really want to delete this record?', - 'icon' => 'icon trash-icon', - ], - ], - - 'join' => [ - // [ - // 'join' => 'leftjoin', - // 'table' => 'roles as r', - // 'primaryKey' => 'u.role_id', - // 'condition' => '=', - // 'secondaryKey' => 'r.id', - // ] - ], - - //use aliasing on secodary columns if join is performed - 'columns' => [ - - [ - 'name' => 'id', - 'alias' => 'inventoryID', - 'type' => 'number', - 'label' => 'ID', - 'sortable' => true, - ], [ - 'name' => 'code', - 'alias' => 'inventoryCode', - 'type' => 'string', - 'label' => 'Code', - 'sortable' => true, - ], [ - 'name' => 'name', - 'alias' => 'inventoryName', - 'type' => 'string', - 'label' => 'Name', - 'sortable' => true, - ], [ - 'name' => 'priority', - 'alias' => 'inventoryPriority', - 'type' => 'string', - 'label' => 'Priority', - 'sortable' => true, - ], [ - 'name' => 'status', - 'alias' => 'inventoryStatus', - 'type' => 'boolean', - 'label' => 'Status', - 'sortable' => true, - 'wrapper' => function ($value) { - if($value == 0) - return "In Active"; - else - return "Active"; - }, - ], - - ], - - //don't use aliasing in case of filters - - 'filterable' => [ - [ - 'column' => 'id', - 'alias' => 'inventoryID', - 'type' => 'number', - 'label' => 'ID', - ], [ - 'column' => 'code', - 'alias' => 'inventoryCode', - 'type' => 'string', - 'label' => 'Code', - ], [ - 'column' => 'name', - 'alias' => 'inventoryName', - 'type' => 'string', - 'label' => 'Name', - ], [ - 'name' => 'status', - 'alias' => 'inventoryStatus', - 'type' => 'boolean', - 'label' => 'Status', - ], - ], - - //don't use aliasing in case of searchables - - 'searchable' => [ - [ - 'column' => 'name', - 'type' => 'string', - 'label' => 'Name', - ], [ - 'column' => 'code', - 'type' => 'string', - 'label' => 'Code', - ], [ - 'column' => 'name', - 'type' => 'string', - 'label' => 'Name', - ], - ], - - //list of viable operators that will be used - 'operators' => [ - 'eq' => "=", - 'lt' => "<", - 'gt' => ">", - 'lte' => "<=", - 'gte' => ">=", - 'neqs' => "<>", - 'neqn' => "!=", - 'like' => "like", - 'nlike' => "not like", - ], - // 'css' => [] + $this->setQueryBuilder($queryBuilder); + } + public function addColumns() + { + $this->addColumn([ + 'column' => 'id', + 'alias' => 'invId', + 'label' => 'ID', + 'type' => 'number', + 'searchable' => false, + 'sortable' => true, + 'width' => '40px' ]); + + $this->addColumn([ + 'column' => 'code', + 'alias' => 'invCode', + 'label' => 'Code', + 'type' => 'string', + 'searchable' => true, + 'sortable' => true, + 'width' => '100px' + ]); + + $this->addColumn([ + 'column' => 'name', + 'alias' => 'invName', + 'label' => 'Name', + 'type' => 'string', + 'searchable' => true, + 'sortable' => true, + 'width' => '100px' + ]); + + $this->addColumn([ + 'column' => 'priority', + 'alias' => 'invPriority', + 'label' => 'Priority', + 'type' => 'string', + 'searchable' => true, + 'sortable' => true, + 'width' => '100px' + ]); + + $this->addColumn([ + 'column' => 'status', + 'alias' => 'invStatus', + 'label' => 'Status', + 'type' => 'boolean', + 'searchable' => true, + 'sortable' => true, + 'width' => '100px' + ]); + } + + public function prepareActions() { + $this->prepareAction([ + 'type' => 'Edit', + 'route' => 'admin.inventory_sources.edit', + 'icon' => 'icon pencil-lg-icon' + ]); + + $this->prepareAction([ + 'type' => 'Delete', + 'route' => 'admin.inventory_sources.delete', + 'confirm_text' => trans('ui::app.datagrid.massaction.delete', ['resource' => 'Exchange Rate']), + '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, + // ] + // ]); } public function render() { - return $this->createInventorySourcesDataGrid()->render(); + $this->addColumns(); + + $this->prepareActions(); + + $this->prepareMassActions(); + + $this->prepareQueryBuilder(); + + return view('ui::testgrid.table')->with('results', ['records' => $this->getCollection(), 'columns' => $this->allColumns, 'actions' => $this->actions, 'massactions' => $this->massActions]); } } \ No newline at end of file diff --git a/packages/Webkul/Admin/src/DataGrids/LocalesDataGrid.php b/packages/Webkul/Admin/src/DataGrids/LocalesDataGrid.php index 9a2ca5ef2..1ed4233ef 100644 --- a/packages/Webkul/Admin/src/DataGrids/LocalesDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/LocalesDataGrid.php @@ -2,141 +2,102 @@ namespace Webkul\Admin\DataGrids; -use Illuminate\View\View; -use Webkul\Ui\DataGrid\Facades\DataGrid; +use Webkul\Ui\DataGrid\AbsGrid; +use DB; /** - * Locales DataGrid + * Product Data Grid class * - * @author Prashant Singh @prashant-webkul + * @author Prashant Singh @prashant-webkul * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) */ -class LocalesDataGrid +class LocalesDataGrid extends AbsGrid { + public $allColumns = []; - /** - * The Data Grid implementation for countries - */ - public function createCountryDataGrid() + public function prepareQueryBuilder() { + $queryBuilder = DB::table('locales')->select('id')->addSelect($this->columns); - return DataGrid::make([ - 'name' => 'Locales', - 'table' => 'locales', - 'select' => 'id', - 'perpage' => 10, - 'aliased' => false, //use this with false as default and true in case of joins - - 'massoperations' =>[ - // [ - // 'route' => route('admin.datagrid.delete'), - // 'method' => 'DELETE', - // 'label' => 'Delete', - // 'type' => 'button', - // ], - ], - - 'actions' => [ - [ - 'type' => 'Edit', - 'route' => 'admin.locales.edit', - // 'confirm_text' => 'Do you really want to edit this record?', - 'icon' => 'icon pencil-lg-icon', - ], [ - 'type' => 'Delete', - 'route' => 'admin.locales.delete', - 'confirm_text' => 'Do you really want to delete this record?', - 'icon' => 'icon trash-icon', - ], - ], - - 'join' => [ - // [ - // 'join' => 'leftjoin', - // 'table' => 'roles as r', - // 'primaryKey' => 'u.role_id', - // 'condition' => '=', - // 'secondaryKey' => 'r.id', - // ] - ], - - //use aliasing as attribute - 'columns' => [ - [ - 'name' => 'id', - 'alias' => 'localeId', - 'type' => 'number', - 'label' => 'ID', - 'sortable' => true, - ], [ - 'name' => 'code', - 'alias' => 'localeCode', - 'type' => 'string', - 'label' => 'Code', - 'sortable' => true, - ], [ - 'name' => 'name', - 'alias' => 'localeName', - 'type' => 'string', - 'label' => 'Name', - 'sortable' => true, - ], - - ], - - //don't use aliasing in case of filters - 'filterable' => [ - [ - 'column' => 'id', - 'alias' => 'localeId', - 'type' => 'number', - 'label' => 'ID', - ], [ - 'column' => 'code', - 'alias' => 'localeCode', - 'type' => 'string', - 'label' => 'Code', - ], [ - 'column' => 'name', - 'alias' => 'localeName', - 'type' => 'string', - 'label' => 'Name', - ], - ], - - //don't use aliasing in case of searchables - 'searchable' => [ - [ - 'column' => 'name', - 'type' => 'string', - 'label' => 'Name', - ], [ - 'column' => 'code', - 'type' => 'string', - 'label' => 'Code', - ], - ], - - //list of viable operators that will be used - 'operators' => [ - 'eq' => "=", - 'lt' => "<", - 'gt' => ">", - 'lte' => "<=", - 'gte' => ">=", - 'neqs' => "<>", - 'neqn' => "!=", - 'like' => "like", - 'nlike' => "not like", - ], - // 'css' => [] + $this->setQueryBuilder($queryBuilder); + } + public function addColumns() + { + $this->addColumn([ + 'column' => 'id', + 'alias' => 'localeId', + 'label' => 'ID', + 'type' => 'number', + 'searchable' => false, + 'sortable' => true, + 'width' => '40px' ]); + $this->addColumn([ + 'column' => 'code', + 'alias' => 'localeCode', + 'label' => 'Code', + 'type' => 'string', + 'searchable' => true, + 'sortable' => true, + 'width' => '100px' + ]); + + $this->addColumn([ + 'column' => 'name', + 'alias' => 'localeName', + 'label' => 'Name', + 'type' => 'string', + 'searchable' => true, + 'sortable' => true, + 'width' => '100px' + ]); + } + + public function prepareActions() { + $this->prepareAction([ + 'type' => 'Edit', + 'route' => 'admin.locales.edit', + 'icon' => 'icon pencil-lg-icon' + ]); + + $this->prepareAction([ + 'type' => 'Delete', + 'route' => 'admin.locales.delete', + 'confirm_text' => trans('ui::app.datagrid.massaction.delete', ['resource' => 'Exchange Rate']), + '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, + // ] + // ]); } public function render() { - return $this->createCountryDataGrid()->render(); + $this->addColumns(); + + $this->prepareActions(); + + $this->prepareMassActions(); + + $this->prepareQueryBuilder(); + + return view('ui::testgrid.table')->with('results', ['records' => $this->getCollection(), 'columns' => $this->allColumns, 'actions' => $this->actions, 'massactions' => $this->massActions]); } } \ No newline at end of file diff --git a/packages/Webkul/Admin/src/DataGrids/NewsLetterDataGrid.php b/packages/Webkul/Admin/src/DataGrids/NewsLetterDataGrid.php index c8c9e7bb7..dfdf8c7ea 100644 --- a/packages/Webkul/Admin/src/DataGrids/NewsLetterDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/NewsLetterDataGrid.php @@ -2,140 +2,102 @@ namespace Webkul\Admin\DataGrids; -use Illuminate\View\View; -use Webkul\Ui\DataGrid\Facades\DataGrid; +use Webkul\Ui\DataGrid\AbsGrid; +use DB; /** - * orderDataGrid + * News Letter Grid class * - * @author Prashant Singh @prashant-webkul + * @author Prashant Singh @prashant-webkul * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) */ -class NewsLetterDataGrid +class NewsLetterDataGrid extends AbsGrid { + public $allColumns = []; - /** - * The Data Grid implementation for orders - */ - public function newsLetterDataGrid() + public function prepareQueryBuilder() { + $queryBuilder = DB::table('subscribers_list')->select('id')->addSelect($this->columns); - return DataGrid::make([ - 'name' => 'Subscriberslist', - 'table' => 'subscribers_list as sublist', - 'select' => 'sublist.id', - 'perpage' => 10, - 'aliased' => false, - //True in case of joins else aliasing key required on all cases + $this->setQueryBuilder($queryBuilder); + } - 'massoperations' =>[ - // [ - // 'route' => route('admin.datagrid.delete'), - // 'method' => 'DELETE', - // 'label' => 'Delete', - // 'type' => 'button', - // ], - ], - - 'actions' => [ - [ - 'type' => 'Edit', - 'route' => 'admin.customers.subscribers.edit', - // 'confirm_text' => 'Do you really want to delete this record?', - 'icon' => 'icon pencil-lg-icon', - ], [ - 'type' => 'Delete', - 'route' => 'admin.customers.subscribers.delete', - 'confirm_text' => 'Do you really want to delete this record?', - 'icon' => 'icon trash-icon', - ], - ], - - 'join' => [], - - //use aliasing on secodary columns if join is performed - 'columns' => [ - [ - 'name' => 'sublist.id', - 'alias' => 'subid', - 'type' => 'number', - 'label' => 'ID', - 'sortable' => true - ], [ - 'name' => 'sublist.is_subscribed', - 'alias' => 'issubs', - 'type' => 'boolean', - 'label' => 'Subscribed', - 'sortable' => true, - 'wrapper' => function ($value) { - if($value == 0) - return "False"; - else - return "True"; - }, - ], [ - 'name' => 'sublist.email', - 'alias' => 'subsemail', - 'type' => 'string', - 'label' => 'Email', - 'sortable' => true - ] - ], - - 'filterable' => [ - [ - 'column' => 'sublist.id', - 'alias' => 'subid', - 'type' => 'number', - 'label' => 'ID', - ], [ - 'column' => 'sublist.is_subscribed', - 'alias' => 'issubs', - 'type' => 'boolean', - 'label' => 'Subscribed', - ], [ - 'column' => 'sublist.email', - 'alias' => 'subsemail', - 'type' => 'string', - 'label' => 'Email', - ] - ], - //don't use aliasing in case of searchables - - 'searchable' => [ - [ - 'column' => 'sublist.id', - 'type' => 'number', - 'label' => 'ID', - ], [ - 'column' => 'sublist.is_subscribed', - 'type' => 'string', - 'label' => 'Subscribed', - ], [ - 'column' => 'sublist.email', - 'type' => 'string', - 'label' => 'Email', - ] - ], - - //list of viable operators that will be used - 'operators' => [ - 'eq' => "=", - 'lt' => "<", - 'gt' => ">", - 'lte' => "<=", - 'gte' => ">=", - 'neqs' => "<>", - 'neqn' => "!=", - 'like' => "like", - 'nlike' => "not like", - ], - // 'css' => [] + public function addColumns() + { + $this->addColumn([ + 'column' => 'id', + 'alias' => 'subsId', + 'label' => 'ID', + 'type' => 'number', + 'searchable' => false, + 'sortable' => true, + 'width' => '40px' ]); + + $this->addColumn([ + 'column' => 'is_subscribed', + 'alias' => 'subsCode', + 'label' => 'Subscribed', + 'type' => 'string', + 'searchable' => true, + 'sortable' => true, + 'width' => '100px' + ]); + + $this->addColumn([ + 'column' => 'email', + 'alias' => 'subsEmail', + 'label' => 'Email', + 'type' => 'string', + 'searchable' => true, + 'sortable' => true, + 'width' => '100px' + ]); + } + + public function prepareActions() { + $this->prepareAction([ + 'type' => 'Edit', + 'route' => 'admin.customers.subscribers.edit', + 'icon' => 'icon pencil-lg-icon' + ]); + + $this->prepareAction([ + 'type' => 'Delete', + 'route' => 'admin.customers.subscribers.delete', + 'confirm_text' => trans('ui::app.datagrid.massaction.delete', ['resource' => 'Exchange Rate']), + '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, + // ] + // ]); } public function render() { - return $this->newsLetterDataGrid()->render(); + $this->addColumns(); + + $this->prepareActions(); + + $this->prepareMassActions(); + + $this->prepareQueryBuilder(); + + return view('ui::testgrid.table')->with('results', ['records' => $this->getCollection(), 'columns' => $this->allColumns, 'actions' => $this->actions, 'massactions' => $this->massActions]); } } \ No newline at end of file diff --git a/packages/Webkul/Admin/src/DataGrids/RolesDataGrid.php b/packages/Webkul/Admin/src/DataGrids/RolesDataGrid.php index ca04bbf36..1abec0a0e 100644 --- a/packages/Webkul/Admin/src/DataGrids/RolesDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/RolesDataGrid.php @@ -2,137 +2,95 @@ namespace Webkul\Admin\DataGrids; -use Illuminate\View\View; -use Webkul\Ui\DataGrid\Facades\DataGrid; +use Webkul\Ui\DataGrid\AbsGrid; +use DB; /** - * User Roles DataGrid + * News Letter Grid class * - * @author Prashant Singh @prashant-webkul + * @author Prashant Singh @prashant-webkul * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) */ -class RolesDataGrid +class RolesDataGrid extends AbsGrid { - /** - * The Data Grid implementation for Roles - */ - public function createRolesDataGrid() + public $allColumns = []; + + public function prepareQueryBuilder() { + $queryBuilder = DB::table('roles')->select('id')->addSelect($this->columns); - return DataGrid::make([ - 'name' => 'Roles', - 'table' => 'roles', - 'select' => 'id', - 'perpage' => 10, - 'aliased' => false, //use this with false as default and true in case of joins - - 'massoperations' =>[ - // [ - // 'route' => route('admin.datagrid.delete'), - // 'method' => 'DELETE', - // 'label' => 'Delete', - // 'type' => 'button', - // ], - ], - - 'actions' => [ - [ - 'type' => 'Edit', - 'route' => 'admin.roles.edit', - 'confirm_text' => 'Do you really want to edit this record?', - 'icon' => 'icon pencil-lg-icon', - ] - ], - - 'join' => [ - // [ - // 'join' => 'leftjoin', - // 'table' => 'roles as r', - // 'primaryKey' => 'u.role_id', - // 'condition' => '=', - // 'secondaryKey' => 'r.id', - // ] - ], - - //use aliasing on secodary columns if join is performed - - 'columns' => [ - [ - 'name' => 'id', - 'alias' => 'roleId', - 'type' => 'number', - 'label' => 'ID', - 'sortable' => true, - ], [ - 'name' => 'name', - 'alias' => 'roleName', - 'type' => 'string', - 'label' => 'Name', - 'sortable' => true, - ], [ - 'name' => 'permission_type', - 'alias' => 'rolePermissionType', - 'type' => 'string', - 'label' => 'Permission Type', - 'sortable' => true, - ], - ], - - //don't use aliasing in case of filters - - 'filterable' => [ - [ - 'column' => 'id', - 'alias' => 'roleId', - 'type' => 'number', - 'label' => 'ID', - ], [ - 'column' => 'name', - 'alias' => 'roleName', - 'type' => 'string', - 'label' => 'Name', - ], [ - 'column' => 'permission_type', - 'alias' => 'rolePermissionType', - 'type' => 'string', - 'label' => 'Permission Type', - ], - ], - - //don't use aliasing in case of searchables - - 'searchable' => [ - [ - 'column' => 'name', - 'type' => 'string', - 'label' => 'Name', - ], [ - 'column' => 'permission_type', - 'type' => 'string', - 'label' => 'Permission Type', - ], - ], - - //list of viable operators that will be used - 'operators' => [ - 'eq' => "=", - 'lt' => "<", - 'gt' => ">", - 'lte' => "<=", - 'gte' => ">=", - 'neqs' => "<>", - 'neqn' => "!=", - 'like' => "like", - 'nlike' => "not like", - ], - // 'css' => [] + $this->setQueryBuilder($queryBuilder); + } + public function addColumns() + { + $this->addColumn([ + 'column' => 'id', + 'alias' => 'roleId', + 'label' => 'ID', + 'type' => 'number', + 'searchable' => false, + 'sortable' => true, + 'width' => '40px' ]); + $this->addColumn([ + 'column' => 'name', + 'alias' => 'roleName', + 'label' => 'Name', + 'type' => 'string', + 'searchable' => true, + 'sortable' => true, + 'width' => '100px' + ]); + + $this->addColumn([ + 'column' => 'permission_type', + 'alias' => 'roleType', + 'label' => 'Permission Type', + 'type' => 'string', + 'searchable' => true, + 'sortable' => true, + 'width' => '100px' + ]); + } + + public function prepareActions() { + $this->prepareAction([ + 'type' => 'Edit', + 'route' => 'admin.roles.edit', + '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, + // ] + // ]); } public function render() { - return $this->createRolesDataGrid()->render(); + $this->addColumns(); + + $this->prepareActions(); + + $this->prepareMassActions(); + + $this->prepareQueryBuilder(); + + return view('ui::testgrid.table')->with('results', ['records' => $this->getCollection(), 'columns' => $this->allColumns, 'actions' => $this->actions, 'massactions' => $this->massActions]); } } \ No newline at end of file diff --git a/packages/Webkul/Admin/src/DataGrids/SliderDataGrid.php b/packages/Webkul/Admin/src/DataGrids/SliderDataGrid.php index 042322293..4d682245c 100644 --- a/packages/Webkul/Admin/src/DataGrids/SliderDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/SliderDataGrid.php @@ -2,143 +2,101 @@ namespace Webkul\Admin\DataGrids; -use Illuminate\View\View; -use Webkul\Ui\DataGrid\Facades\DataGrid; +use Webkul\Ui\DataGrid\AbsGrid; +use DB; /** - * Sliders DataGrid + * News Letter Grid class * - * @author Prashant Singh @prashant-webkul + * @author Prashant Singh @prashant-webkul * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) */ -class SliderDataGrid +class SliderDataGrid extends AbsGrid { + public $allColumns = []; - /** - * The Data Grid implementation for Sliders - */ - public function createSliderDataGrid() + public function prepareQueryBuilder() { + $queryBuilder = DB::table('sliders as sl')->select('sl.id')->addSelect($this->columns)->leftJoin('channels as ch', 'sl.channel_id', '=', 'ch.id'); - return DataGrid::make([ - 'name' => 'Sliders', - 'table' => 'sliders as s', - 'select' => 's.id', - 'perpage' => 10, - 'aliased' => true, //use this with false as default and true in case of joins + $this->setQueryBuilder($queryBuilder); + } - 'massoperations' =>[ - // [ - // 'route' => route('admin.datagrid.delete'), - // 'method' => 'DELETE', - // 'label' => 'Delete', - // 'type' => 'button', - // ], - ], - - 'actions' => [ - [ - 'type' => 'Edit', - 'route' => 'admin.sliders.edit', - 'confirm_text' => 'Do you really want to edit this record?', - 'icon' => 'icon pencil-lg-icon', - ], [ - 'type' => 'Delete', - 'route' => 'admin.sliders.delete', - 'confirm_text' => 'Do you really want to delete this record?', - 'icon' => 'icon trash-icon', - ], - ], - - 'join' => [ - [ - 'join' => 'leftjoin', - 'table' => 'channels as c', - 'primaryKey' => 's.channel_id', - 'condition' => '=', - 'secondaryKey' => 'c.id', - ] - ], - - //use aliasing on secodary columns if join is performed - - 'columns' => [ - [ - 'name' => 's.id', - 'alias' => 'sliderId', - 'type' => 'number', - 'label' => 'ID', - 'sortable' => true, - ], [ - 'name' => 's.title', - 'alias' => 'sliderTitle', - 'type' => 'string', - 'label' => 'title', - 'sortable' => true - ], [ - 'name' => 'c.name', - 'alias' => 'channelName', - 'type' => 'string', - 'label' => 'Channel Name', - 'sortable' => true, - ], - ], - - //don't use aliasing in case of filters - 'filterable' => [ - [ - 'column' => 's.id', - 'alias' => 'sliderId', - 'type' => 'number', - 'label' => 'ID' - ], [ - 'column' => 's.title', - 'alias' => 'sliderTitle', - 'type' => 'string', - 'label' => 'title' - ], [ - 'column' => 'c.name', - 'alias' => 'channelName', - 'type' => 'string', - 'label' => 'Channel Name', - ] - ], - - //don't use aliasing in case of searchables - 'searchable' => [ - [ - 'column' => 's.id', - 'type' => 'number', - 'label' => 'ID' - ], [ - 'column' => 's.title', - 'type' => 'string', - 'label' => 'Slider Title' - ], [ - 'column' => 'c.name', - 'type' => 'string', - 'label' => 'Channel Name', - ] - ], - - //list of viable operators that will be used - 'operators' => [ - 'eq' => "=", - 'lt' => "<", - 'gt' => ">", - 'lte' => "<=", - 'gte' => ">=", - 'neqs' => "<>", - 'neqn' => "!=", - 'like' => "like", - 'nlike' => "not like", - ], - // 'css' => [] + public function addColumns() + { + $this->addColumn([ + 'column' => 'sl.id', + 'alias' => 'sliderId', + 'label' => 'ID', + 'type' => 'number', + 'searchable' => false, + 'sortable' => true, + 'width' => '40px' ]); + + $this->addColumn([ + 'column' => 'sl.title', + 'alias' => 'sliderTitle', + 'label' => 'Tile', + 'type' => 'string', + 'searchable' => true, + 'sortable' => true, + 'width' => '100px' + ]); + + $this->addColumn([ + 'column' => 'ch.name', + 'alias' => 'channelName', + 'label' => 'Channel Name', + 'type' => 'string', + 'searchable' => true, + 'sortable' => true, + 'width' => '100px' + ]); + } + + public function prepareActions() { + $this->prepareAction([ + 'type' => 'Edit', + 'route' => 'admin.sliders.edit', + 'icon' => 'icon pencil-lg-icon' + ]); + + $this->prepareAction([ + 'type' => 'Delete', + 'route' => 'admin.sliders.delete', + '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, + // ] + // ]); } public function render() { - return $this->createSliderDataGrid()->render(); + $this->addColumns(); + + $this->prepareActions(); + + $this->prepareMassActions(); + + $this->prepareQueryBuilder(); + + return view('ui::testgrid.table')->with('results', ['records' => $this->getCollection(), 'columns' => $this->allColumns, 'actions' => $this->actions, 'massactions' => $this->massActions]); } } \ No newline at end of file diff --git a/packages/Webkul/Admin/src/DataGrids/TaxCategoryDataGrid.php b/packages/Webkul/Admin/src/DataGrids/TaxCategoryDataGrid.php index 2e2a79aa2..7fad061e4 100644 --- a/packages/Webkul/Admin/src/DataGrids/TaxCategoryDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/TaxCategoryDataGrid.php @@ -2,151 +2,101 @@ namespace Webkul\Admin\DataGrids; -use Illuminate\View\View; -use Webkul\Ui\DataGrid\Facades\DataGrid; +use Webkul\Ui\DataGrid\AbsGrid; +use DB; /** - * Tax Category DataGrid + * Tax Category Grid class * - * @author Prashant Singh @prashant-webkul + * @author Prashant Singh @prashant-webkul * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) */ - -class TaxCategoryDataGrid +class TaxCategoryDataGrid extends AbsGrid { + public $allColumns = []; - /** - * The Tax Category Data Grid implementation. - */ - public function createTaxCategoryDataGrid() + public function prepareQueryBuilder() { + $queryBuilder = DB::table('tax_categories as tr')->select('tr.id')->addSelect($this->columns); - return DataGrid::make([ - - 'name' => 'Tax Category', - 'table' => 'tax_categories as tr', - 'select' => 'tr.id', - 'perpage' => 10, - 'aliased' => true, //use this with false as default and true in case of joins - - 'massoperations' =>[ - // [ - // 'route' => route('admin.datagrid.delete'), - // 'method' => 'DELETE', - // 'label' => 'Delete', - // 'type' => 'button', - // ], - // [ - // 'route' => route('admin.datagrid.index'), - // 'method' => 'POST', - // 'label' => 'View Grid', - // 'type' => 'select', - // 'options' =>[ - // 1 => 'Edit', - // 2 => 'Set', - // 3 => 'Change Status' - // ] - // ], - ], - 'actions' => [ - [ - 'type' => 'Edit', - 'route' => 'admin.tax-categories.edit', - 'confirm_text' => 'Do you really want to edit this record?', - 'icon' => 'icon pencil-lg-icon', - ], - [ - 'type' => 'Delete', - 'route' => 'admin.tax-categories.delete', - 'confirm_text' => 'Do you really want to delete this record?', - 'icon' => 'icon trash-icon', - ], - ], - 'join' => [ - // [ - // 'join' => 'leftjoin', - // 'table' => 'roles as r', - // 'primaryKey' => 'u.role_id', - // 'condition' => '=', - // 'secondaryKey' => 'r.id', - // ] - ], - - //use aliasing on secodary columns if join is performed - 'columns' => [ - [ - 'name' => 'tr.id', - 'alias' => 'ID', - 'type' => 'number', - 'label' => 'ID', - 'sortable' => true, - ], [ - 'name' => 'tr.name', - 'alias' => 'Name', - 'type' => 'string', - 'label' => 'Name', - 'sortable' => true, - ], [ - 'name' => 'tr.code', - 'alias' => 'code', - 'type' => 'string', - 'label' => 'Code', - 'sortable' => true, - ], - ], - - //don't use aliasing in case of filters - 'filterable' => [ - [ - 'column' => 'tr.id', - 'alias' => 'ID', - 'type' => 'number', - 'label' => 'ID' - ], [ - 'column' => 'tr.name', - 'alias' => 'Name', - 'type' => 'string', - 'label' => 'Name' - ], [ - 'column' => 'tr.code', - 'alias' => 'code', - 'type' => 'string', - 'label' => 'Code' - ] - ], - - //don't use aliasing in case of searchables - 'searchable' => [ - [ - 'column' => 'tr.code', - 'type' => 'string', - 'label' => 'Code' - ], [ - 'column' => 'tr.name', - 'type' => 'string', - 'label' => 'Name' - ] - ], - 'operators' => [ - 'eq' => "=", - 'lt' => "<", - 'gt' => ">", - 'lte' => "<=", - 'gte' => ">=", - 'neqs' => "<>", - 'neqn' => "!=", - 'like' => "like", - 'nlike' => "not like", - ], - // 'css' => [] + $this->setQueryBuilder($queryBuilder); + } + public function addColumns() + { + $this->addColumn([ + 'column' => 'tr.id', + 'alias' => 'taxCatId', + 'label' => 'ID', + 'type' => 'number', + 'searchable' => false, + 'sortable' => true, + 'width' => '40px' ]); + $this->addColumn([ + 'column' => 'tr.name', + 'alias' => 'taxCatName', + 'label' => 'Name', + 'type' => 'string', + 'searchable' => true, + 'sortable' => true, + 'width' => '100px' + ]); + + $this->addColumn([ + 'column' => 'tr.code', + 'alias' => 'taxCatCode', + 'label' => 'Code', + 'type' => 'string', + 'searchable' => true, + 'sortable' => true, + 'width' => '100px' + ]); } - public function render() { + public function prepareActions() { + $this->prepareAction([ + 'type' => 'Edit', + 'route' => 'admin.tax-categories.edit', + 'icon' => 'icon pencil-lg-icon' + ]); - return $this->createTaxCategoryDataGrid()->render(); + $this->prepareAction([ + 'type' => 'Delete', + 'route' => 'admin.tax-categories.delete', + '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, + // ] + // ]); + } + + public function render() + { + $this->addColumns(); + + $this->prepareActions(); + + $this->prepareMassActions(); + + $this->prepareQueryBuilder(); + + return view('ui::testgrid.table')->with('results', ['records' => $this->getCollection(), 'columns' => $this->allColumns, 'actions' => $this->actions, 'massactions' => $this->massActions]); } } \ No newline at end of file diff --git a/packages/Webkul/Admin/src/DataGrids/TaxRateDataGrid.php b/packages/Webkul/Admin/src/DataGrids/TaxRateDataGrid.php index f8d962e12..47b6bce7f 100644 --- a/packages/Webkul/Admin/src/DataGrids/TaxRateDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/TaxRateDataGrid.php @@ -2,172 +2,121 @@ namespace Webkul\Admin\DataGrids; -use Illuminate\View\View; -use Webkul\Ui\DataGrid\Facades\DataGrid; +use Webkul\Ui\DataGrid\AbsGrid; +use DB; /** - * Tax Rates DataGrid + * Tax Rate Grid class * - * @author Prashant Singh @prashant-webkul + * @author Prashant Singh @prashant-webkul * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) */ -class TaxRateDataGrid +class TaxRateDataGrid extends AbsGrid { + public $allColumns = []; - /** - * The Tax Category Data Grid implementation. - */ - public function createTaxRateDataGrid() + public function prepareQueryBuilder() { + $queryBuilder = DB::table('tax_rates as tr')->select('tr.id')->addSelect($this->columns); - return DataGrid::make([ - 'name' => 'Tax Rates', - 'table' => 'tax_rates as tr', - 'select' => 'tr.id', - 'perpage' => 10, - 'aliased' => true, //use this with false as default and true in case of joins - - 'massoperations' =>[ - // [ - // 'route' => route('admin.datagrid.delete'), - // 'method' => 'DELETE', - // 'label' => 'Delete', - // 'type' => 'button', - // ], - // [ - // 'route' => route('admin.datagrid.index'), - // 'method' => 'POST', - // 'label' => 'View Grid', - // 'type' => 'select', - // 'options' =>[ - // 1 => 'Edit', - // 2 => 'Set', - // 3 => 'Change Status' - // ] - // ], - ], - 'actions' => [ - [ - 'type' => 'Edit', - 'route' => 'admin.tax-rates.store', - 'confirm_text' => 'Do you really want to edit this record?', - 'icon' => 'icon pencil-lg-icon', - ], - [ - 'type' => 'Delete', - 'route' => 'admin.tax-rates.delete', - 'confirm_text' => 'Do you really want to delete this record?', - 'icon' => 'icon trash-icon', - ], - ], - 'join' => [], - - //use aliasing on secodary columns if join is performed - 'columns' => [ - [ - 'name' => 'tr.id', - 'alias' => 'id', - 'type' => 'number', - 'label' => 'ID', - 'sortable' => true, - ], [ - 'name' => 'tr.identifier', - 'alias' => 'identifier', - 'type' => 'string', - 'label' => 'Identifier', - 'sortable' => true, - // 'wrapper' => function ($value, $object) { - // return '' . $object->identifier . ''; - // }, - ], [ - 'name' => 'tr.state', - 'alias' => 'state', - 'type' => 'string', - 'label' => 'State', - 'sortable' => true, - ], [ - 'name' => 'tr.country', - 'alias' => 'country', - 'type' => 'string', - 'label' => 'Country', - 'sortable' => true, - ], [ - 'name' => 'tr.tax_rate', - 'alias' => 'taxrate', - 'type' => 'number', - 'label' => 'Tax Rate', - 'sortable' => true, - ], - ], - //don't use aliasing in case of filters - 'filterable' => [ - [ - 'column' => 'tr.id', - 'alias' => 'ID', - 'type' => 'number', - 'label' => 'ID', - ], [ - 'column' => 'tr.identifier', - 'alias' => 'identifier', - 'type' => 'string', - 'label' => 'Identifier', - ], [ - 'column' => 'tr.state', - 'alias' => 'state', - 'type' => 'string', - 'label' => 'State', - ], [ - 'column' => 'tr.country', - 'alias' => 'country', - 'type' => 'string', - 'label' => 'Country', - ], [ - 'column' => 'tr.tax_rate', - 'alias' => 'taxrate', - 'type' => 'number', - 'label' => 'Tax Rate', - ], - ], - //don't use aliasing in case of searchables - 'searchable' => [ - [ - 'column' => 'tr.identifier', - 'type' => 'string', - 'label' => 'Identifier', - ], [ - 'column' => 'tr.state', - 'type' => 'string', - 'label' => 'State', - ], [ - 'column' => 'tr.country', - 'type' => 'string', - 'label' => 'Country', - ], [ - 'column' => 'tr.tax_rate', - 'type' => 'number', - 'label' => 'Tax Rate', - ], - ], - 'operators' => [ - 'eq' => "=", - 'lt' => "<", - 'gt' => ">", - 'lte' => "<=", - 'gte' => ">=", - 'neqs' => "<>", - 'neqn' => "!=", - 'like' => "like", - 'nlike' => "not like", - ], - // 'css' => [] + $this->setQueryBuilder($queryBuilder); + } + public function addColumns() + { + $this->addColumn([ + 'column' => 'tr.id', + 'alias' => 'taxRateId', + 'label' => 'ID', + 'type' => 'number', + 'searchable' => false, + 'sortable' => true, + 'width' => '40px' ]); + $this->addColumn([ + 'column' => 'tr.identifier', + 'alias' => 'taxRateName', + 'label' => 'Identifier', + 'type' => 'string', + 'searchable' => true, + 'sortable' => true, + 'width' => '100px' + ]); + + $this->addColumn([ + 'column' => 'tr.state', + 'alias' => 'taxRateState', + 'label' => 'State', + 'type' => 'string', + 'searchable' => true, + 'sortable' => true, + 'width' => '100px' + ]); + + $this->addColumn([ + 'column' => 'tr.country', + 'alias' => 'taxRateCountry', + 'label' => 'Country', + 'type' => 'string', + 'searchable' => true, + 'sortable' => true, + 'width' => '100px' + ]); + + $this->addColumn([ + 'column' => 'tr.tax_rate', + 'alias' => 'taxRate', + 'label' => 'Rate', + 'type' => 'string', + 'searchable' => true, + 'sortable' => true, + 'width' => '100px' + ]); } - public function render() { + public function prepareActions() { + $this->prepareAction([ + 'type' => 'Edit', + 'route' => 'admin.tax-categories.edit', + 'icon' => 'icon pencil-lg-icon' + ]); - return $this->createTaxRateDataGrid()->render(); + $this->prepareAction([ + 'type' => 'Delete', + 'route' => 'admin.tax-categories.delete', + '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, + // ] + // ]); + } + + public function render() + { + $this->addColumns(); + + $this->prepareActions(); + + $this->prepareMassActions(); + + $this->prepareQueryBuilder(); + + return view('ui::testgrid.table')->with('results', ['records' => $this->getCollection(), 'columns' => $this->allColumns, 'actions' => $this->actions, 'massactions' => $this->massActions]); } } \ No newline at end of file diff --git a/packages/Webkul/Admin/src/DataGrids/TestDataGrid.php b/packages/Webkul/Admin/src/DataGrids/TestDataGrid.php index ee9985354..3ee5bd280 100644 --- a/packages/Webkul/Admin/src/DataGrids/TestDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/TestDataGrid.php @@ -70,7 +70,7 @@ class TestDataGrid extends AbsGrid 'label' => 'Status', 'type' => 'boolean', 'sortable' => true, - 'searchable' => true, + 'searchable' => false, 'width' => '100px' ]); @@ -80,7 +80,7 @@ class TestDataGrid extends AbsGrid 'label' => 'Price', 'type' => 'number', 'sortable' => true, - 'searchable' => true, + 'searchable' => false, 'width' => '100px' ]); @@ -90,7 +90,7 @@ class TestDataGrid extends AbsGrid 'label' => 'Quantity', 'type' => 'number', 'sortable' => true, - 'searchable' => true, + 'searchable' => false, 'width' => '100px' ]); } diff --git a/packages/Webkul/Admin/src/Resources/views/catalog/products/index.blade.php b/packages/Webkul/Admin/src/Resources/views/catalog/products/index.blade.php index 545d72f9c..5d75b7260 100644 --- a/packages/Webkul/Admin/src/Resources/views/catalog/products/index.blade.php +++ b/packages/Webkul/Admin/src/Resources/views/catalog/products/index.blade.php @@ -22,7 +22,7 @@ {{-- @inject('product','Webkul\Admin\DataGrids\ProductDataGrid') {!! $product->render() !!} --}} - @inject('products','Webkul\Admin\DataGrids\TestDataGrid') + @inject('products', 'Webkul\Admin\DataGrids\TestDataGrid') {!! $products->render() !!} diff --git a/packages/Webkul/Admin/src/Resources/views/customers/index.blade.php b/packages/Webkul/Admin/src/Resources/views/customers/index.blade.php index 9c67e67c2..a5e49369e 100644 --- a/packages/Webkul/Admin/src/Resources/views/customers/index.blade.php +++ b/packages/Webkul/Admin/src/Resources/views/customers/index.blade.php @@ -12,12 +12,12 @@

{{ __('admin::app.customers.customers.title') }}

-
+ {{--
{{ __('admin::app.export.export') }} -
+
--}} {{ __('admin::app.customers.customers.add-title') }} @@ -32,18 +32,18 @@
- + {{--

{{ __('admin::app.export.download') }}

-
+
--}} @stop @push('scripts') - + --}} @endpush diff --git a/packages/Webkul/Ui/src/DataGrid/AbsGrid.php b/packages/Webkul/Ui/src/DataGrid/AbsGrid.php index a54542629..1efedab8f 100644 --- a/packages/Webkul/Ui/src/DataGrid/AbsGrid.php +++ b/packages/Webkul/Ui/src/DataGrid/AbsGrid.php @@ -91,7 +91,13 @@ abstract class AbsGrid if(count($p)) { $filteredOrSortedCollection = $this->sortOrFilterCollection($this->collection = $this->queryBuilder, $p); - return $filteredOrSortedCollection->get(); + // return $filteredOrSortedCollection->get(); + + if (config()->has('datagrid.pagination')) { + return $filteredOrSortedCollection->paginate(config('datagrid.pagination')); + } else { + return $filteredOrSortedCollection->get(); + } } if (config()->has('datagrid.pagination')) { diff --git a/packages/Webkul/Ui/src/Resources/views/testgrid/table.blade.php b/packages/Webkul/Ui/src/Resources/views/testgrid/table.blade.php index 3c2ec1c52..7d165c152 100644 --- a/packages/Webkul/Ui/src/Resources/views/testgrid/table.blade.php +++ b/packages/Webkul/Ui/src/Resources/views/testgrid/table.blade.php @@ -1,6 +1,10 @@
+ @if(config('datagrid.pagination')) + @include('ui::testgrid.pagination', ['results' => $results['records']]) + @endif + @push('scripts')