Browse Source

Merge branch 'dev' into liangshiwei/virtualfilesystem-explorer-module

pull/3971/head
liangshiwei 6 years ago
parent
commit
443a3023b4
  1. 12
      docs/en/UI/Angular/Confirmation-Service.md
  2. 4
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Pagination/PagerModel.cs
  3. 3
      npm/ng-packs/packages/core/src/lib/tests/config.state.spec.ts
  4. 5
      npm/ng-packs/packages/theme-shared/src/lib/components/confirmation/confirmation.component.html
  5. 8
      npm/ng-packs/packages/theme-shared/src/lib/models/confirmation.ts
  6. 7
      npm/ng-packs/packages/theme-shared/src/lib/services/confirmation.service.ts
  7. 15
      npm/ng-packs/packages/theme-shared/src/lib/tests/confirmation.service.spec.ts

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

@ -53,7 +53,7 @@ this.confirmation
- `Confirmation.Status` is an enum and has three properties;
- `Confirmation.Status.confirm` is a closing event value that will be emitted when the popup is closed by the confirm button.
- `Confirmation.Status.reject` is a closing event value that will be emitted when the popup is closed by the cancel button.
- `Confirmation.Status.dismiss` is a closing event value that will be emitted when the popup is closed by pressing the escape.
- `Confirmation.Status.dismiss` is a closing event value that will be emitted when the popup is closed by pressing the escape or clicking the backdrop.
If you are not interested in the confirmation status, you do not have to subscribe to the returned observable:
@ -70,6 +70,7 @@ Options can be passed as the third parameter to `success`, `warn`, `error`, and
const options: Partial<Confirmation.Options> = {
hideCancelBtn: false,
hideYesBtn: false,
dismissible: false,
cancelText: 'Close',
yesText: 'Confirm',
messageLocalizationParams: ['Demo'],
@ -83,10 +84,11 @@ this.confirmation.warn(
);
```
- `hideCancelBtn` option hides the cancellation button when `true`. Default value is `false`
- `hideYesBtn` option hides the confirmation button when `true`. Default value is `false`
- `cancelText` is the text of the cancellation button. A localization key or localization object can be passed. Default value is `AbpUi::Cancel`
- `yesText` is the text of the confirmation button. A localization key or localization object can be passed. Default value is `AbpUi::Yes`
- `hideCancelBtn` option hides the cancellation button when `true`. Default value is `false`.
- `hideYesBtn` option hides the confirmation button when `true`. Default value is `false`.
- `dismissible` option allows dismissing the confirmation popup by pressing escape or clicking the backdrop. Default value is `true`.
- `cancelText` is the text of the cancellation button. A localization key or localization object can be passed. Default value is `AbpUi::Cancel`.
- `yesText` is the text of the confirmation button. A localization key or localization object can be passed. Default value is `AbpUi::Yes`.
- `messageLocalizationParams` is the interpolation parameters for the localization of the message.
- `titleLocalizationParams` is the interpolation parameters for the localization of the title.

4
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Pagination/PagerModel.cs

@ -54,8 +54,8 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Pagination
CurrentPage = currentPage;
}
ShowingFrom = totalCount == 0 ? 0 : CurrentPage * PageSize;
ShowingTo = totalCount == 0 ? 0 : ShowingFrom + PageSize;
ShowingFrom = totalCount == 0 ? 0 : (CurrentPage - 1) * PageSize + 1;
ShowingTo = totalCount == 0 ? 0 : (int)Math.Min(ShowingFrom + PageSize - 1 , totalCount);
PreviousPage = CurrentPage <= 1 ? 1 : CurrentPage - 1;
NextPage = CurrentPage >= TotalPageCount ? CurrentPage : CurrentPage + 1;
Pages = CalculatePageNumbers();

3
npm/ng-packs/packages/core/src/lib/tests/config.state.spec.ts

@ -306,6 +306,7 @@ describe('ConfigState', () => {
const configuration = {
setting: { values: { 'Abp.Localization.DefaultLanguage': 'tr;TR' } },
localization: { currentCulture: {} },
};
const res$ = new ReplaySubject(1);
@ -324,7 +325,7 @@ describe('ConfigState', () => {
timer(0).subscribe(() => {
expect(patchStateArg).toEqual(configuration);
expect(dispatchArg instanceof SetLanguage).toBeTruthy();
expect(dispatchArg).toEqual({ payload: 'tr' });
expect(dispatchArg).toEqual({ payload: 'tr', dispatchAppConfiguration: false });
done();
});
});

5
npm/ng-packs/packages/theme-shared/src/lib/components/confirmation/confirmation.component.html

@ -1,5 +1,8 @@
<div class="confirmation" *ngIf="confirmation$ | async as data">
<div class="confirmation-backdrop"></div>
<div
class="confirmation-backdrop"
(click)="data.options?.dismissible ? close(dismiss) : null"
></div>
<div class="confirmation-dialog">
<div class="icon-container" [ngClass]="data.severity" *ngIf="data.severity">
<i class="fa icon" [ngClass]="getIconClass(data)"></i>

8
npm/ng-packs/packages/theme-shared/src/lib/models/confirmation.ts

@ -3,13 +3,19 @@ import { Config } from '@abp/ng.core';
export namespace Confirmation {
export interface Options {
id?: any;
closable?: boolean;
dismissible?: boolean;
messageLocalizationParams?: string[];
titleLocalizationParams?: string[];
hideCancelBtn?: boolean;
hideYesBtn?: boolean;
cancelText?: Config.LocalizationParam;
yesText?: Config.LocalizationParam;
/**
*
* @deprecated To be deleted in v2.9
*/
closable?: boolean;
}
export interface DialogData {

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

@ -68,7 +68,7 @@ export class ConfirmationService {
message: Config.LocalizationParam,
title: Config.LocalizationParam,
severity?: Confirmation.Severity,
options?: Partial<Confirmation.Options>,
options = {} as Partial<Confirmation.Options>,
): Observable<Confirmation.Status> {
if (!this.containerComponentRef) this.setContainer();
@ -78,8 +78,11 @@ export class ConfirmationService {
severity: severity || 'neutral',
options,
});
this.status$ = new Subject();
this.listenToEscape();
const { dismissible = true } = options;
if (dismissible) this.listenToEscape();
return this.status$;
}

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

@ -105,6 +105,21 @@ describe('ConfirmationService', () => {
selectConfirmationElement<HTMLButtonElement>('button#cancel').click();
});
test.each`
dismissible | count
${true} | ${1}
${false} | ${0}
`(
'should call the listenToEscape method $count times when dismissible is $dismissible',
({ dismissible, count }) => {
const spy = spyOn(service as any, 'listenToEscape');
service.info('', '', { dismissible });
expect(spy).toHaveBeenCalledTimes(count);
},
);
});
function clearElements(selector = '.confirmation') {

Loading…
Cancel
Save