Browse Source

Merge pull request #19200 from abpframework/sinan/tooltip-for-grid-action

Add tooltip functionality to grid actions component
pull/19211/head
Masum ULU 3 years ago
committed by GitHub
parent
commit
af99ee236c
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 37
      npm/ng-packs/packages/components/extensible/src/lib/components/grid-actions/grid-actions.component.html
  2. 3
      npm/ng-packs/packages/components/extensible/src/lib/components/grid-actions/grid-actions.component.ts
  3. 3
      npm/ng-packs/packages/components/extensible/src/lib/models/entity-actions.ts

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

@ -53,16 +53,31 @@
<ng-template #btnTmp let-action> <ng-template #btnTmp let-action>
@if (action.visible(data)) { @if (action.visible(data)) {
<button @if (action.tooltip) {
*abpPermission="action.permission; runChangeDetection: false" <button
(click)="action.action(data)" *abpPermission="action.permission; runChangeDetection: false"
type="button" (click)="action.action(data)"
[class]="action.btnClass" type="button"
[style]="action.btnStyle" [class]="action.btnClass"
> [style]="action.btnStyle"
<ng-container [ngbTooltip]="action.tooltip.text | abpLocalization" [placement]="action.tooltip.placement || 'auto'" container="body"
*ngTemplateOutlet="buttonContentTmp; context: { $implicit: action }" >
></ng-container> <ng-container
</button> *ngTemplateOutlet="buttonContentTmp; context: { $implicit: action }"
></ng-container>
</button>
} @else {
<button
*abpPermission="action.permission; runChangeDetection: false"
(click)="action.action(data)"
type="button"
[class]="action.btnClass"
[style]="action.btnStyle"
>
<ng-container
*ngTemplateOutlet="buttonContentTmp; context: { $implicit: action }"
></ng-container>
</button>
}
} }
</ng-template> </ng-template>

3
npm/ng-packs/packages/components/extensible/src/lib/components/grid-actions/grid-actions.component.ts

@ -8,7 +8,7 @@ import {
import { EntityAction, EntityActionList } from '../../models/entity-actions'; import { EntityAction, EntityActionList } from '../../models/entity-actions';
import { EXTENSIONS_ACTION_TYPE } from '../../tokens/extensions.token'; import { EXTENSIONS_ACTION_TYPE } from '../../tokens/extensions.token';
import { AbstractActionsComponent } from '../abstract-actions/abstract-actions.component'; import { AbstractActionsComponent } from '../abstract-actions/abstract-actions.component';
import { NgbDropdownModule } from '@ng-bootstrap/ng-bootstrap'; import { NgbDropdownModule, NgbTooltipModule } from '@ng-bootstrap/ng-bootstrap';
import { LocalizationModule, PermissionDirective } from '@abp/ng.core'; import { LocalizationModule, PermissionDirective } from '@abp/ng.core';
import { EllipsisDirective } from '@abp/ng.theme.shared'; import { EllipsisDirective } from '@abp/ng.theme.shared';
import { NgClass, NgTemplateOutlet } from '@angular/common'; import { NgClass, NgTemplateOutlet } from '@angular/common';
@ -23,6 +23,7 @@ import { NgClass, NgTemplateOutlet } from '@angular/common';
NgClass, NgClass,
LocalizationModule, LocalizationModule,
NgTemplateOutlet, NgTemplateOutlet,
NgbTooltipModule
], ],
selector: 'abp-grid-actions', selector: 'abp-grid-actions',
templateUrl: './grid-actions.component.html', templateUrl: './grid-actions.component.html',

3
npm/ng-packs/packages/components/extensible/src/lib/models/entity-actions.ts

@ -8,6 +8,7 @@ import {
Actions, Actions,
ActionsFactory, ActionsFactory,
} from './actions'; } from './actions';
import { FormPropTooltip } from './form-props';
export class EntityActionList<R = any> extends ActionList<R, EntityAction<R>> {} export class EntityActionList<R = any> extends ActionList<R, EntityAction<R>> {}
@ -25,6 +26,7 @@ export class EntityAction<R = any> extends Action<R> {
readonly btnClass?: string; readonly btnClass?: string;
readonly btnStyle?: string; readonly btnStyle?: string;
readonly showOnlyIcon?: boolean; readonly showOnlyIcon?: boolean;
readonly tooltip?: FormPropTooltip;
constructor(options: EntityActionOptions<R>) { constructor(options: EntityActionOptions<R>) {
super(options.permission || '', options.visible, options.action); super(options.permission || '', options.visible, options.action);
@ -33,6 +35,7 @@ export class EntityAction<R = any> extends Action<R> {
this.btnClass = options.btnClass || 'btn btn-primary text-center'; this.btnClass = options.btnClass || 'btn btn-primary text-center';
this.btnStyle = options.btnStyle; this.btnStyle = options.btnStyle;
this.showOnlyIcon = options.showOnlyIcon || false; this.showOnlyIcon = options.showOnlyIcon || false;
this.tooltip = options.tooltip;
} }
static create<R = any>(options: EntityActionOptions<R>) { static create<R = any>(options: EntityActionOptions<R>) {

Loading…
Cancel
Save