closed #2476 Fixed: Category bulk actions ( #31u2zbh )
This commit is contained in:
parent
94c927d685
commit
8dc11762b2
@ -39,6 +39,19 @@ class Categories extends BulkAction
|
|||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public function getSelectedRecords($request, $relationships = null)
|
||||||
|
{
|
||||||
|
if (empty($relationships)) {
|
||||||
|
$model = $this->model::query();
|
||||||
|
} else {
|
||||||
|
$relationships = Arr::wrap($relationships);
|
||||||
|
|
||||||
|
$model = $this->model::with($relationships);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $model->getWithoutChildren()->find($this->getSelectedInput($request));
|
||||||
|
}
|
||||||
|
|
||||||
public function disable($request)
|
public function disable($request)
|
||||||
{
|
{
|
||||||
$categories = $this->getSelectedRecords($request);
|
$categories = $this->getSelectedRecords($request);
|
||||||
|
@ -64,51 +64,58 @@
|
|||||||
</x-table.thead>
|
</x-table.thead>
|
||||||
|
|
||||||
<x-table.tbody>
|
<x-table.tbody>
|
||||||
@foreach($categories as $category)
|
@foreach($categories as $item)
|
||||||
<x-table.tr href="{{ route('categories.edit', $category->id) }}" class="relative flex items-center border-b hover:bg-gray-100 px-1 group transition-all">
|
<x-table.tr href="{{ route('categories.edit', $item->id) }}" class="relative flex items-center border-b hover:bg-gray-100 px-1 group transition-all">
|
||||||
<x-table.td class="ltr:pr-6 rtl:pl-6 hidden sm:table-cell" override="class">
|
<x-table.td class="ltr:pr-6 rtl:pl-6 hidden sm:table-cell" override="class">
|
||||||
<x-index.bulkaction.single id="{{ $category->id }}" name="{{ $category->name }}" />
|
<x-index.bulkaction.single id="{{ $item->id }}" name="{{ $item->name }}" />
|
||||||
</x-table.td>
|
</x-table.td>
|
||||||
|
|
||||||
<x-table.td class="w-5/12 truncate">
|
<x-table.td class="w-5/12 truncate">
|
||||||
@if ($category->sub_categories->count())
|
@if ($item->sub_categories->count())
|
||||||
<div class="flex items-center font-bold">
|
<div class="flex items-center font-bold">
|
||||||
{{ $category->name }}
|
{{ $item->name }}
|
||||||
<x-tooltip id="tooltip-category-{{ $category->id }}" placement="bottom" message="{{ trans('categories.collapse') }}">
|
|
||||||
|
<x-tooltip id="tooltip-category-{{ $item->id }}" placement="bottom" message="{{ trans('categories.collapse') }}">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
class="w-4 h-4 flex items-center justify-center mx-2 leading-none align-text-top rounded-lg bg-gray-500 hover:bg-gray-700"
|
class="w-4 h-4 flex items-center justify-center mx-2 leading-none align-text-top rounded-lg bg-gray-500 hover:bg-gray-700"
|
||||||
node="child-{{ $category->id }}"
|
node="child-{{ $item->id }}"
|
||||||
onClick="toggleSub('child-{{ $category->id }}', event)"
|
onClick="toggleSub('child-{{ $item->id }}', event)"
|
||||||
>
|
>
|
||||||
<span class="material-icons transform rotate-90 transition-all text-lg leading-none align-middle text-white">chevron_right</span>
|
<span class="material-icons transform rotate-90 transition-all text-lg leading-none align-middle text-white">chevron_right</span>
|
||||||
</button>
|
</button>
|
||||||
</x-tooltip>
|
</x-tooltip>
|
||||||
</div>
|
</div>
|
||||||
@else
|
@else
|
||||||
<span class="font-bold">{{ $category->name }}</span>
|
<span class="font-bold">
|
||||||
|
{{ $item->name }}
|
||||||
|
</span>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@if (! $item->enabled)
|
||||||
|
<x-index.disable text="{{ trans_choice('general.categories', 1) }}" />
|
||||||
@endif
|
@endif
|
||||||
</x-table.td>
|
</x-table.td>
|
||||||
|
|
||||||
<x-table.td class="w-5/12 truncate">
|
<x-table.td class="w-5/12 truncate">
|
||||||
@if (! empty($types[$category->type]))
|
@if (! empty($types[$item->type]))
|
||||||
{{ $types[$category->type] }}
|
{{ $types[$item->type] }}
|
||||||
@else
|
@else
|
||||||
<x-empty-data />
|
<x-empty-data />
|
||||||
@endif
|
@endif
|
||||||
</x-table.td>
|
</x-table.td>
|
||||||
|
|
||||||
<x-table.td class="w-2/12 relative">
|
<x-table.td class="w-2/12 relative">
|
||||||
<span class="material-icons text-{{ $category->color }}" class="text-3xl" style="color:{{ $category->color }};">circle</span>
|
<span class="material-icons text-{{ $item->color }}" class="text-3xl" style="color:{{ $item->color }};">circle</span>
|
||||||
</x-table.td>
|
</x-table.td>
|
||||||
|
|
||||||
<x-table.td kind="action">
|
<x-table.td kind="action">
|
||||||
<x-table.actions :model="$category" />
|
<x-table.actions :model="$item" />
|
||||||
</x-table.td>
|
</x-table.td>
|
||||||
</x-table.tr>
|
</x-table.tr>
|
||||||
|
|
||||||
@foreach($category->sub_categories as $sub_category)
|
@foreach($item->sub_categories as $sub_category)
|
||||||
@include('settings.categories.sub_category', ['parent_category' => $category, 'sub_category' => $sub_category, 'tree_level' => 1])
|
@include('settings.categories.sub_category', ['parent_category' => $item, 'sub_category' => $sub_category, 'tree_level' => 1])
|
||||||
@endforeach
|
@endforeach
|
||||||
@endforeach
|
@endforeach
|
||||||
</x-table.tbody>
|
</x-table.tbody>
|
||||||
|
@ -31,15 +31,15 @@
|
|||||||
</x-table.td>
|
</x-table.td>
|
||||||
|
|
||||||
<x-table.td class="w-5/12 ltr:pr-6 rtl:pl-6 py-4 ltr:text-left rtl:text-right whitespace-nowrap text-sm font-normal text-black cursor-pointer truncate">
|
<x-table.td class="w-5/12 ltr:pr-6 rtl:pl-6 py-4 ltr:text-left rtl:text-right whitespace-nowrap text-sm font-normal text-black cursor-pointer truncate">
|
||||||
@if (! empty($types[$category->type]))
|
@if (! empty($types[$item->type]))
|
||||||
{{ $types[$category->type] }}
|
{{ $types[$item->type] }}
|
||||||
@else
|
@else
|
||||||
<x-empty-data />
|
<x-empty-data />
|
||||||
@endif
|
@endif
|
||||||
</x-table.td>
|
</x-table.td>
|
||||||
|
|
||||||
<x-table.td class="ltr:pr-6 rtl:pl-6 py-4 ltr:text-left rtl:text-right whitespace-nowrap text-sm font-normal text-black cursor-pointer w-2/12 relative">
|
<x-table.td class="ltr:pr-6 rtl:pl-6 py-4 ltr:text-left rtl:text-right whitespace-nowrap text-sm font-normal text-black cursor-pointer w-2/12 relative">
|
||||||
<span class="material-icons text-3xl text-{{ $category->color }}" style="color:{{ $sub_category->color }};">circle</span>
|
<span class="material-icons text-3xl text-{{ $item->color }}" style="color:{{ $sub_category->color }};">circle</span>
|
||||||
</x-table.td>
|
</x-table.td>
|
||||||
|
|
||||||
<x-table.td kind="action">
|
<x-table.td kind="action">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user