Skip to content

Commit

Permalink
ToggleDetail Row Rule
Browse files Browse the repository at this point in the history
  • Loading branch information
dansysanalyst committed May 19, 2024
1 parent 38443fd commit 969aed4
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<td
class="{{ data_get($theme, 'tdBodyClass') }}"
style="{{ data_get($theme, 'tdBodyStyle') }}"
></td>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<td
class="{{ data_get($theme, 'tdBodyClass') }}"
style="{{ data_get($theme, 'tdBodyStyle') }}"
></td>
38 changes: 28 additions & 10 deletions resources/views/components/row.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,32 @@
])

@php
$ruleDetailView = data_get($rulesValues, 'detailView');
// =============* Get Rules *=====================
$rowRules = $actionRulesClass->recoverFromAction($row, RuleManager::TYPE_ROWS);
// =============* Toggle Detail Rules *=====================
$showToggleDetail = data_get($setUp, 'detail.showCollapseIcon');
$toggleDetailVisibilityRowRules = collect(data_get($rowRules, 'ToggleDetailVisibility', []));
if ($toggleDetailVisibilityRowRules) {
// Has permission, but Row Action Rule is changing to hide
if ($showToggleDetail && $toggleDetailVisibilityRowRules->last() == 'hide')
{
$showToggleDetail = false;
}
// No permission, but Row Action Rule is forcing to show
if (!$showToggleDetail && $toggleDetailVisibilityRowRules->last() == 'show')
{
$showToggleDetail = true;
}
}
$toggleDetailView = powerGridThemeRoot() . ($showToggleDetail ? '.toggle-detail' : '.no-toggle-detail');
@endphp

@includeWhen(data_get($setUp, 'detail.showCollapseIcon'), powerGridThemeRoot() . '.toggle-detail', [
@includeWhen(data_get($setUp, 'detail.showCollapseIcon'), $toggleDetailView, [
'theme' => data_get($theme, 'table'),
'view' => data_get($setUp, 'detail.viewIcon') ?? null,
])
Expand Down Expand Up @@ -65,15 +87,11 @@
@endforeach
@endif
</div>

{{-- =============* Get Rules *===================== --}}
@php
$rowRules = $actionRulesClass->recoverFromAction($row, RuleManager::TYPE_ROWS);
$hasFieldRules = $actionRulesClass->recoverActionForField($row, $field);
@endphp

{{-- =============* Edit On Click *===================== --}}
@php
// =============* Get Field Rules *=====================
$hasFieldRules = $actionRulesClass->recoverActionForField($row, $field);
// =============* Edit On Click *=====================
$showEditOnClick = false;
Expand Down
3 changes: 1 addition & 2 deletions src/Components/Rules/RuleManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ class RuleManager

public static function applicableModifiers(): array
{
return ['bladeComponent', 'detailView', 'disable', 'dispatch', 'dispatchTo', 'emit', 'hide', 'loop', 'redirect', 'rowClasses', 'setAttribute', 'slot', 'ToggleableVisibility', 'DetailButtonVisibility', 'EditOnClickVisibility', 'field_hide_editonclick', 'field_hide_toggleable'];
return ['bladeComponent', 'detailView', 'disable', 'dispatch', 'dispatchTo', 'emit', 'hide', 'loop', 'redirect', 'rowClasses', 'setAttribute', 'slot', 'ToggleableVisibility', 'ToggleDetailVisibility', 'EditOnClickVisibility', 'field_hide_editonclick', 'field_hide_toggleable'];
}

//@TODO DetailButtonVisibility
public function button(string $button): RuleActions
{
return new RuleActions($button);
Expand Down
12 changes: 6 additions & 6 deletions src/Components/Rules/RuleRows.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,21 +74,21 @@ public function disableEditOnClick(): self
}

/**
* Show the Detail button in current row.
* Show the Detail toggle in current row.
*/
public function showDetailButton(): self
public function showToggleDetail(): self
{
$this->setModifier('DetailButtonVisibility', 'show');
$this->setModifier('ToggleDetailVisibility', 'show');

return $this;
}

/**
* Hide the Detail button in current row.
* Hide the Detail toggle in current row.
*/
public function hideDetailButton(): self
public function hideToggleDetail(): self
{
$this->setModifier('DetailButtonVisibility', 'hide');
$this->setModifier('ToggleDetailVisibility', 'hide');

return $this;
}
Expand Down

0 comments on commit 969aed4

Please sign in to comment.