Datagrid bug fixes

This commit is contained in:
prashant-webkul 2018-08-16 13:37:37 +05:30
parent bb3551a564
commit 3da39943f1
8 changed files with 171 additions and 15 deletions

View File

@ -0,0 +1,155 @@
<?php
namespace Webkul\Admin\DataGrids;
use Illuminate\View\View;
use Webkul\Ui\DataGrid\Facades\DataGrid;
/**
* Countries DataGrid
*
* @author Prashant Singh <prashant.singh852@webkul.com> @prashant-webkul
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/
class AttributeFamilyDataGrid
{
/**
* The Data Grid implementation.
*
* @var CountryComposer
* for countries
*/
public function createAttributeFamilyDataGrid()
{
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' => route('admin.datagrid.delete'),
'confirm_text' => 'Do you really want to do this?',
'icon' => 'icon pencil-lg-icon',
], [
'type' => 'Delete',
'route' => route('admin.datagrid.delete'),
'confirm_text' => 'Do you really want to do this?',
'icon' => 'icon trash-icon',
],
],
'join' => [
// [
// 'join' => 'leftjoin',
// 'table' => 'roles as r',
// 'primaryKey' => 'u.role_id',
// 'condition' => '=',
// 'secondaryKey' => 'r.id',
// ]
],
//use aliasing on secodary columns if join is performed
'columns' => [
[
'name' => 'id',
'alias' => 'attribute_family_id',
'type' => 'number',
'label' => 'ID',
'sortable' => true,
],
[
'name' => 'code',
'alias' => 'attribute_family_code',
'type' => 'string',
'label' => 'Code',
'sortable' => true,
],
[
'name' => 'name',
'alias' => 'attribute_family_name',
'type' => 'string',
'label' => 'Code',
'sortable' => true,
],
],
'filterable' => [
[
'column' => 'id',
'alias' => 'attribute_family_id',
'type' => 'number',
'label' => 'ID',
],
[
'column' => 'code',
'alias' => 'attribute_family_code',
'type' => 'string',
'label' => 'Code',
],
[
'column' => 'name',
'alias' => 'attribute_family_name',
'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' => []
]);
}
public function render()
{
return $this->createAttributeFamilyDataGrid()->render();
}
}

View File

@ -13,7 +13,7 @@ use Webkul\Ui\DataGrid\Facades\DataGrid;
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/
class ChannelsDataGrid
class ChannelDataGrid
{
/**
* The Data Grid implementation.

View File

@ -12,7 +12,7 @@ use Webkul\Ui\DataGrid\Facades\DataGrid;
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/
class CurrenciesDataGrid
class CurrencyDataGrid
{
/**
* The Data Grid implementation.

View File

@ -15,7 +15,8 @@
</div>
<div class="page-content">
@inject('attributefamily','Webkul\Admin\DataGrids\AttributeFamilyDataGrid')
{!! $attributefamily->render() !!}
</div>
</div>
@stop

View File

@ -15,7 +15,7 @@
</div>
<div class="page-content">
@inject('channels','Webkul\Admin\DataGrids\ChannelsDataGrid')
@inject('channels','Webkul\Admin\DataGrids\ChannelDataGrid')
{!! $channels->render() !!}
</div>
</div>

View File

@ -15,7 +15,7 @@
</div>
<div class="page-content">
@inject('currencies','Webkul\Admin\DataGrids\CurrenciesDataGrid')
@inject('currencies','Webkul\Admin\DataGrids\CurrencyDataGrid')
{!! $currencies->render() !!}
</div>
</div>

View File

@ -20,7 +20,7 @@ class AttributeFamilyTableSeeder extends Seeder
"name" => "General",
"is_user_defined" => 0,
"position" => 1,
"attributes" => [
"custom_attributes" => [
[
'code' => 'sku',
'position' => 1
@ -48,7 +48,7 @@ class AttributeFamilyTableSeeder extends Seeder
"name" => "Description",
"is_user_defined" => 0,
"position" => 2,
"attributes" => [
"custom_attributes" => [
[
'code' => 'short_description',
'position' => 1
@ -61,7 +61,7 @@ class AttributeFamilyTableSeeder extends Seeder
"name" => "Meta Description",
"is_user_defined" => 0,
"position" => 3,
"attributes" => [
"custom_attributes" => [
[
'code' => 'meta_title',
'position' => 1
@ -77,7 +77,7 @@ class AttributeFamilyTableSeeder extends Seeder
"name" => "Price",
"is_user_defined" => 0,
"position" => 4,
"attributes" => [
"custom_attributes" => [
[
'code' => 'price',
'position' => 1
@ -99,7 +99,7 @@ class AttributeFamilyTableSeeder extends Seeder
"name" => "Shipping",
"is_user_defined" => 0,
"position" => 5,
"attributes" => [
"custom_attributes" => [
[
'code' => 'width',
'position' => 1
@ -136,7 +136,7 @@ class AttributeFamilyTableSeeder extends Seeder
{
$this->attributeFamily = $attributeFamily;
}
public function run()
{
foreach($this->rawData as $row) {

View File

@ -1,7 +1,7 @@
<?php
<?php
namespace Webkul\Attribute\Repositories;
use Webkul\Core\Eloquent\Repository;
use Webkul\Attribute\Repositories\AttributeRepository;
use Webkul\Attribute\Repositories\AttributeGroupRepository;
@ -96,7 +96,7 @@ class AttributeFamilyRepository extends Repository
$family->update($data);
$previousAttributeGroupIds = $family->attribute_groups()->pluck('id');
if(isset($data['attribute_groups'])) {
foreach ($data['attribute_groups'] as $attributeGroupId => $attributeGroupInputs) {
if (str_contains($attributeGroupId, 'group_')) {
@ -114,7 +114,7 @@ class AttributeFamilyRepository extends Repository
$attributeGroup = $this->attributeGroup->findOrFail($attributeGroupId);
$attributeGroup->update($attributeGroupInputs);
$attributeIds = $attributeGroup->custom_attributes()->get()->pluck('id');
if(isset($attributeGroupInputs['custom_attributes'])) {