Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
luanfreitasdev committed Aug 21, 2024
1 parent 5084fa1 commit 02c6357
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 38 deletions.
2 changes: 1 addition & 1 deletion dist/bootstrap5.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions dist/mix-manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"/powergrid.js": "/powergrid.js?id=abadfd5261368378c9a092e58c07156e",
"/bootstrap5.css": "/bootstrap5.css?id=ebd9853ab6704f4a2335e83a4310bb2b",
"/tailwind.css": "/tailwind.css?id=01ab1b7207e6bfcf473c14f0818e9d5f",
"/bootstrap5.css": "/bootstrap5.css?id=a27af22343149104b2aa3283d8fd502b",
"/tailwind.css": "/tailwind.css?id=924477e2afcb2cb56aa392e266ee56ca",
"/tom-select.css": "/tom-select.css?id=7feeb634924554f9e57ce1e09edcabcb",
"/powergrid.css": "/powergrid.css?id=ccf9e99db3929ffc436445d5befaf2ac"
"/powergrid.css": "/powergrid.css?id=c2648f9d0d2b90371db3b914ef05450e"
}
2 changes: 1 addition & 1 deletion dist/powergrid.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/tailwind.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/Concerns/ToggleDetail.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function mountToggleDetail(): void

private function resolveDetailRow(mixed $results): void
{
if (!isset($this->setUp['detail'])) {
if (!isset($this->setUp['detail']) && !isset($this->setUp['lazy'])) {
return;
}

Expand Down
16 changes: 12 additions & 4 deletions src/DataSource/Processors/DataSourceBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,22 @@ private static function processRows(BaseCollection $results, PowerGridComponent
$loopInstance = app(ManageLoops::class);
$loopInstance->addLoop($results);

return $results->map(function ($row, $index) use ($component, $fields, $loopInstance) {
$renderActions = false;

if (method_exists($component, 'actions')) {
$renderActions = true;
}

return $results->map(function ($row, $index) use ($component, $fields, $loopInstance, $renderActions) {
$data = $fields->map(fn ($field) => $field((object) $row, $index));

$loopInstance->incrementLoopIndices();

$hasCookieActionsForRow = isset($_COOKIE['pg_cookie_' . $component->tableName . '_row_' . data_get($row, $component->realPrimaryKey)]);
$rowId = data_get($row, $component->realPrimaryKey);

$hasCookieActionsForRow = isset($_COOKIE['pg_cookie_' . $component->tableName . '_row_' . $rowId]);

if (method_exists($component, 'actions') && !$hasCookieActionsForRow) {
if ($renderActions && !$hasCookieActionsForRow) {
$actions = collect($component->actions((object) $row)) // @phpstan-ignore-line
->transform(function (Button|array $action) use ($row, $component) {
return [
Expand All @@ -184,7 +192,7 @@ private static function processRows(BaseCollection $results, PowerGridComponent
];
});

static::$actionsHtml[data_get($row, $component->realPrimaryKey)] = $actions->toArray();
static::$actionsHtml[$rowId] = $actions->toArray();
}

$mergedData = $data->merge([
Expand Down
Loading

0 comments on commit 02c6357

Please sign in to comment.