Browse Source

Confirmation Icon can change via DI.

pull/11576/head
Mahmut Gundogdu 5 years ago
parent
commit
323128ac02
  1. 19
      docs/en/UI/Angular/Confirmation-Service.md
  2. 7
      npm/ng-packs/packages/theme-shared/src/lib/components/confirmation/confirmation.component.ts
  3. 2
      npm/ng-packs/packages/theme-shared/src/lib/models/common.ts
  4. 9
      npm/ng-packs/packages/theme-shared/src/lib/services/confirmation.service.ts
  5. 2
      npm/ng-packs/packages/theme-shared/src/lib/tests/confirmation.service.spec.ts

19
docs/en/UI/Angular/Confirmation-Service.md

@ -131,6 +131,25 @@ The open confirmation popup can be removed manually via the `clear` method:
this.confirmation.clear();
```
### How to Change Icons of The Confirmation Popup
You can change icons with the token of "confirmationIcons" in ThemeSharedModule in the app.module.ts. The changes will affect all confirmation popup in the project.
```js
...
ThemeSharedModule.forRoot({
confirmationIcons: {
info: 'fa fa-info-circle',
success: 'fa fa-check-circle',
warning: 'fa fa-exclamation-triangle',
error: 'fa fa-times-circle',
default: 'fa fa-question-circle',
},
}),
...
```
## API
### success

7
npm/ng-packs/packages/theme-shared/src/lib/components/confirmation/confirmation.component.ts

@ -1,7 +1,7 @@
import { Component } from '@angular/core';
import { Component, Inject } from '@angular/core';
import { ReplaySubject } from 'rxjs';
import { Confirmation } from '../../models/confirmation';
import { ConfirmationIcons } from '../../tokens/confirmation-icons.token';
import { CONFIRMATION_ICONS, ConfirmationIcons } from '../../tokens/confirmation-icons.token';
@Component({
selector: 'abp-confirmation',
@ -9,12 +9,13 @@ import { ConfirmationIcons } from '../../tokens/confirmation-icons.token';
styleUrls: ['./confirmation.component.scss'],
})
export class ConfirmationComponent {
constructor(@Inject(CONFIRMATION_ICONS) private icons: ConfirmationIcons) {}
confirm = Confirmation.Status.confirm;
reject = Confirmation.Status.reject;
dismiss = Confirmation.Status.dismiss;
confirmation$!: ReplaySubject<Confirmation.DialogData>;
icons: ConfirmationIcons;
clear!: (status: Confirmation.Status) => void;

2
npm/ng-packs/packages/theme-shared/src/lib/models/common.ts

@ -5,7 +5,7 @@ import { Observable } from 'rxjs';
import { ConfirmationIcons } from '../tokens/confirmation-icons.token';
export interface RootParams {
httpErrorConfig: HttpErrorConfig;
httpErrorConfig?: HttpErrorConfig;
validation?: Partial<Validation.Config>;
confirmationIcons?: Partial<ConfirmationIcons>;
}

9
npm/ng-packs/packages/theme-shared/src/lib/services/confirmation.service.ts

@ -1,10 +1,9 @@
import { ContentProjectionService, LocalizationParam, PROJECTION_STRATEGY } from '@abp/ng.core';
import { ComponentRef, Inject, Injectable } from '@angular/core';
import { ComponentRef, Injectable } from '@angular/core';
import { fromEvent, Observable, ReplaySubject, Subject } from 'rxjs';
import { debounceTime, filter, takeUntil } from 'rxjs/operators';
import { ConfirmationComponent } from '../components/confirmation/confirmation.component';
import { Confirmation } from '../models/confirmation';
import { CONFIRMATION_ICONS, ConfirmationIcons } from '../tokens/confirmation-icons.token';
@Injectable({ providedIn: 'root' })
export class ConfirmationService {
@ -18,17 +17,13 @@ export class ConfirmationService {
this.status$.next(status);
};
constructor(
private contentProjectionService: ContentProjectionService,
@Inject(CONFIRMATION_ICONS) private confirmationIcons: ConfirmationIcons,
) {}
constructor(private contentProjectionService: ContentProjectionService) {}
private setContainer() {
this.containerComponentRef = this.contentProjectionService.projectContent(
PROJECTION_STRATEGY.AppendComponentToBody(ConfirmationComponent, {
confirmation$: this.confirmation$,
clear: this.clear,
icons: this.confirmationIcons,
}),
);

2
npm/ng-packs/packages/theme-shared/src/lib/tests/confirmation.service.spec.ts

@ -13,6 +13,7 @@ import { CONFIRMATION_ICONS, DEFAULT_CONFIRMATION_ICONS } from '../tokens/confir
entryComponents: [ConfirmationComponent],
declarations: [ConfirmationComponent],
imports: [CoreTestingModule.withConfig()],
providers: [{ provide: CONFIRMATION_ICONS, useValue: DEFAULT_CONFIRMATION_ICONS }],
})
export class MockModule {}
@ -22,7 +23,6 @@ describe('ConfirmationService', () => {
const createService = createServiceFactory({
service: ConfirmationService,
imports: [CoreTestingModule.withConfig(), MockModule],
providers: [{ provide: CONFIRMATION_ICONS, useValue: DEFAULT_CONFIRMATION_ICONS }],
});
beforeEach(() => {

Loading…
Cancel
Save