diff --git a/resources/views/bread/datatable.blade.php b/resources/views/bread/datatable.blade.php
index ee95e04..351212d 100644
--- a/resources/views/bread/datatable.blade.php
+++ b/resources/views/bread/datatable.blade.php
@@ -27,11 +27,7 @@
@endif
@endcan
- @foreach($actions as $action)
- @if (method_exists($action, 'massAction'))
- @include('voyager::bread.partials.actions', ['action' => $action, 'data' => null])
- @endif
- @endforeach
+ @include('joy-voyager-datatable::bread.partials.group-actions', ['actions' => $actions, 'dataType' => $dataType, 'data' => null])
@include('voyager::multilingual.language-selector')
@stop
diff --git a/resources/views/bread/partials/group-actions.blade.php b/resources/views/bread/partials/group-actions.blade.php
new file mode 100644
index 0000000..8d60150
--- /dev/null
+++ b/resources/views/bread/partials/group-actions.blade.php
@@ -0,0 +1,41 @@
+@php
+ $crudActions = collect($actions)->filter(function($action) {
+ return Str::is([
+ '*DeleteAction',
+ '*RestoreAction',
+ '*EditAction',
+ '*ViewAction',
+ '*ExportAction',
+ ], get_class($action));
+ });
+ $otherActions = collect($actions)->filter(function($action) {
+ return !Str::is([
+ '*DeleteAction',
+ '*RestoreAction',
+ '*EditAction',
+ '*ViewAction',
+ '*ExportAction',
+ ], get_class($action));
+ });
+@endphp
+
+ @foreach($crudActions as $action)
+ @if (method_exists($action, 'massAction'))
+ @include('voyager::bread.partials.actions', ['action' => $action, 'dataType' => $dataType, 'data' => null])
+ @endif
+ @endforeach
+
+
+
+
\ No newline at end of file
diff --git a/resources/views/bread/partials/single-group-actions.blade.php b/resources/views/bread/partials/single-group-actions.blade.php
new file mode 100644
index 0000000..bbe2ab6
--- /dev/null
+++ b/resources/views/bread/partials/single-group-actions.blade.php
@@ -0,0 +1,42 @@
+@php
+ $crudActions = collect($actions)->filter(function($action) {
+ return Str::is([
+ '*DeleteAction',
+ '*RestoreAction',
+ '*EditAction',
+ '*ViewAction',
+ '*ExportAction',
+ ], get_class($action));
+ });
+ $otherActions = collect($actions)->filter(function($action) {
+ return !Str::is([
+ '*DeleteAction',
+ '*RestoreAction',
+ '*EditAction',
+ '*ViewAction',
+ '*ExportAction',
+ ], get_class($action));
+ });
+@endphp
+
+
+
+ @foreach($crudActions as $action)
+ @if (!method_exists($action, 'massAction'))
+ @include('voyager::bread.partials.actions', ['action' => $action, 'dataType' => $dataType, 'data' => $data])
+ @endif
+ @endforeach
+
\ No newline at end of file
diff --git a/resources/views/components/datatable.blade.php b/resources/views/components/datatable.blade.php
index 8ebed50..07e3b24 100644
--- a/resources/views/components/datatable.blade.php
+++ b/resources/views/components/datatable.blade.php
@@ -1,7 +1,5 @@
@php
- $columnDefs = [
- ['targets' => 'dt-not-orderable', 'searchable' => false, 'orderable' => false],
- ];
+ array_push($columnDefs, ['targets' => 'dt-not-orderable', 'searchable' => false, 'orderable' => false]);
if($withoutCheckbox) {
array_push($columnDefs, ['targets' => 'dt-index', 'visible' => false]);
}
@@ -70,6 +68,7 @@
var options = {!! json_encode(
array_merge([
"order" => $orderColumn,
+ "autoWidth" => $autoWidth,
"language" => __('voyager::datatable'),
"columnDefs" => $columnDefs,
"processing" => true,
diff --git a/resources/views/components/datatables.blade.php b/resources/views/components/datatables.blade.php
index 7d4763b..524adde 100644
--- a/resources/views/components/datatables.blade.php
+++ b/resources/views/components/datatables.blade.php
@@ -1,9 +1,11 @@
@foreach($dataTypes as $dataType)
@endforeach
\ No newline at end of file
diff --git a/src/Services/Column.php b/src/Services/Column.php
index e3a914a..a3bd9d1 100644
--- a/src/Services/Column.php
+++ b/src/Services/Column.php
@@ -615,16 +615,16 @@ public function actions(
$dataType,
$actions
) {
- $view = '';
- foreach ($actions as $action) {
- if (!method_exists($action, 'massAction')) {
- $view .= view('voyager::bread.partials.actions', [
- 'action' => $action,
- 'dataType' => $dataType,
- 'data' => $data,
- ]);
- }
+ $view = 'joy-voyager-datatable::bread.partials.single-group-actions';
+
+ if (view()->exists('joy-voyager-datatable::' . $dataType->slug . '.partials.single-group-actions')) {
+ $view = 'joy-voyager-datatable::' . $dataType->slug . '.partials.single-group-actions';
}
- return $view;
+
+ return view($view, [
+ 'actions' => $actions,
+ 'dataType' => $dataType,
+ 'data' => $data,
+ ]);
}
}
diff --git a/src/View/Components/Datatable.php b/src/View/Components/Datatable.php
index 3db51e2..8e2c9ff 100644
--- a/src/View/Components/Datatable.php
+++ b/src/View/Components/Datatable.php
@@ -31,18 +31,25 @@ class Datatable extends Component
protected $slug;
/**
- * The dataId.
+ * The withLabel.
*
- * @var string|null
+ * @var bool|null
*/
- protected $dataId;
+ protected $withLabel;
/**
- * The withLabel.
+ * The autoWidth.
*
- * @var bool|null
+ * @var bool
*/
- protected $withLabel;
+ protected $autoWidth;
+
+ /**
+ * The columnDefs.
+ *
+ * @var array
+ */
+ protected $columnDefs;
/**
* The withoutCheckbox.
@@ -58,14 +65,23 @@ class Datatable extends Component
*/
protected $withoutActions;
+ /**
+ * The dataId.
+ *
+ * @var string|null
+ */
+ protected $dataId;
+
/**
* Create the component instance.
*
* @param Request $request
* @param string $slug
+ * @param bool|null $withLabel
+ * @param bool $autoWidth
+ * @param array $columnDefs
* @param bool|null $withoutCheckbox
* @param bool|null $withoutActions
- * @param bool|null $withLabel
* @param string|null $dataId
*
* @return void
@@ -73,16 +89,20 @@ class Datatable extends Component
public function __construct(
Request $request,
string $slug,
+ ?bool $withLabel = null,
+ ?bool $autoWidth = false,
+ ?array $columnDefs = [],
?bool $withoutCheckbox = null,
?bool $withoutActions = null,
- ?bool $withLabel = null,
?string $dataId = null
) {
$this->request = $request;
$this->slug = $slug;
+ $this->withLabel = $withLabel;
+ $this->autoWidth = $autoWidth;
+ $this->columnDefs = $columnDefs;
$this->withoutCheckbox = $withoutCheckbox;
$this->withoutActions = $withoutActions;
- $this->withLabel = $withLabel;
$this->dataId = $dataId;
}
@@ -176,9 +196,11 @@ public function render()
'usesSoftDeletes' => $usesSoftDeletes,
'showSoftDeleted' => $showSoftDeleted,
'showCheckboxColumn' => $showCheckboxColumn,
+ 'withLabel' => $this->withLabel,
+ 'autoWidth' => $this->autoWidth,
+ 'columnDefs' => $this->columnDefs,
'withoutCheckbox' => $this->withoutCheckbox,
'withoutActions' => $this->withoutActions,
- 'withLabel' => $this->withLabel,
'dataId' => $this->dataId,
]);
}
diff --git a/src/View/Components/Datatables.php b/src/View/Components/Datatables.php
index 256834f..4afd489 100644
--- a/src/View/Components/Datatables.php
+++ b/src/View/Components/Datatables.php
@@ -24,11 +24,25 @@ class Datatables extends Component
protected $slugs;
/**
- * The dataId.
+ * The withLabel.
*
- * @var string|null
+ * @var bool|null
*/
- protected $dataId;
+ protected $withLabel;
+
+ /**
+ * The autoWidth.
+ *
+ * @var bool
+ */
+ protected $autoWidth;
+
+ /**
+ * The columnDefs.
+ *
+ * @var array
+ */
+ protected $columnDefs;
/**
* The withoutCheckbox.
@@ -45,20 +59,22 @@ class Datatables extends Component
protected $withoutActions;
/**
- * The withLabel.
+ * The dataId.
*
- * @var bool|null
+ * @var string|null
*/
- protected $withLabel;
+ protected $dataId;
/**
* Create the component instance.
*
* @param Request $request
* @param array $slugs
+ * @param bool|null $withLabel
+ * @param bool $autoWidth
+ * @param array $columnDefs
* @param bool|null $withoutCheckbox
* @param bool|null $withoutActions
- * @param bool|null $withLabel
* @param string|null $dataId
*
* @return void
@@ -66,16 +82,20 @@ class Datatables extends Component
public function __construct(
Request $request,
array $slugs = [],
+ ?bool $withLabel = true,
+ ?bool $autoWidth = false,
+ ?array $columnDefs = [],
?bool $withoutCheckbox = true,
?bool $withoutActions = true,
- ?bool $withLabel = true,
?string $dataId = null
) {
$this->request = $request;
$this->slugs = $slugs;
+ $this->withLabel = $withLabel;
+ $this->autoWidth = $autoWidth;
+ $this->columnDefs = $columnDefs;
$this->withoutCheckbox = $withoutCheckbox;
$this->withoutActions = $withoutActions;
- $this->withLabel = $withLabel;
$this->dataId = $dataId;
}
@@ -95,9 +115,12 @@ public function render()
return Voyager::view($view, [
'dataTypes' => $dataTypes,
+ 'slugs' => $this->slugs,
+ 'withLabel' => $this->withLabel,
+ 'autoWidth' => $this->autoWidth,
+ 'columnDefs' => $this->columnDefs,
'withoutCheckbox' => $this->withoutCheckbox,
'withoutActions' => $this->withoutActions,
- 'withLabel' => $this->withLabel,
'dataId' => $this->dataId,
]);
}