Browse Source

add: hasAvailableActions condition to check the related availibility beforehand

pull/19651/head
sumeyyeKurtulus 2 years ago
parent
commit
6d4ed1bf42
  1. 76
      npm/ng-packs/packages/components/extensible/src/lib/components/grid-actions/grid-actions.component.html

76
npm/ng-packs/packages/components/extensible/src/lib/components/grid-actions/grid-actions.component.html

@ -1,42 +1,46 @@
@if (actionList.length > 1) {
<div ngbDropdown container="body" class="d-inline-block">
<button
class="btn btn-primary btn-sm dropdown-toggle"
data-toggle="dropdown"
aria-haspopup="true"
ngbDropdownToggle
>
<i [ngClass]="icon" [class.me-1]="icon"></i>{{ text | abpLocalization }}
</button>
<div ngbDropdownMenu>
@for (action of actionList; track action.text) {
<ng-container
[ngTemplateOutlet]="dropDownBtnItemTmp"
[ngTemplateOutletContext]="{ $implicit: action }"
@if (hasAvailableActions()) {
@if (actionList.length > 1) {
<div ngbDropdown container="body" class="d-inline-block">
<button
class="btn btn-primary btn-sm dropdown-toggle"
data-toggle="dropdown"
aria-haspopup="true"
ngbDropdownToggle
>
</ng-container>
}
</div>
</div>
} @if (actionList.length === 1) {
<ng-container
[ngTemplateOutlet]="btnTmp"
[ngTemplateOutletContext]="{ $implicit: actionList.get(0).value }"
></ng-container>
<i [ngClass]="icon" [class.me-1]="icon"></i>{{ text | abpLocalization }}
</button>
<div ngbDropdownMenu>
@for (action of actionList; track action.text) {
<ng-container
[ngTemplateOutlet]="dropDownBtnItemTmp"
[ngTemplateOutletContext]="{ $implicit: action }"
>
</ng-container>
}
</div>
</div>
}
@if (actionList.length === 1) {
<ng-container
[ngTemplateOutlet]="btnTmp"
[ngTemplateOutletContext]="{ $implicit: actionList.get(0).value }"
></ng-container>
}
}
<ng-template #dropDownBtnItemTmp let-action>
@if (action.visible(data)) {
<button
ngbDropdownItem
*abpPermission="action.permission; runChangeDetection: false"
(click)="action.action(data)"
type="button"
>
<ng-container
*ngTemplateOutlet="buttonContentTmp; context: { $implicit: action }"
></ng-container>
</button>
<button
ngbDropdownItem
*abpPermission="action.permission; runChangeDetection: false"
(click)="action.action(data)"
type="button"
>
<ng-container
*ngTemplateOutlet="buttonContentTmp; context: { $implicit: action }"
></ng-container>
</button>
}
</ng-template>
@ -60,7 +64,9 @@
type="button"
[class]="action.btnClass"
[style]="action.btnStyle"
[ngbTooltip]="action.tooltip.text | abpLocalization" [placement]="action.tooltip.placement || 'auto'" container="body"
[ngbTooltip]="action.tooltip.text | abpLocalization"
[placement]="action.tooltip.placement || 'auto'"
container="body"
>
<ng-container
*ngTemplateOutlet="buttonContentTmp; context: { $implicit: action }"

Loading…
Cancel
Save