Browse Source

Merge pull request #6294 from abpframework/feat/4444

Created a new token named SUPPRESS_UNSAVED_CHANGES_WARNING to suppress unsaved changes warning popup on save forms
pull/6290/head
Bunyamin Coskuner 6 years ago
committed by GitHub
parent
commit
50d364ff70
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      npm/ng-packs/packages/theme-shared/src/lib/components/modal/modal.component.ts
  2. 1
      npm/ng-packs/packages/theme-shared/src/lib/tokens/index.ts
  3. 6
      npm/ng-packs/packages/theme-shared/src/lib/tokens/suppress-unsaved-changes-warning.token.ts

10
npm/ng-packs/packages/theme-shared/src/lib/components/modal/modal.component.ts

@ -4,8 +4,10 @@ import {
ContentChild,
ElementRef,
EventEmitter,
Inject,
Input,
OnDestroy,
Optional,
Output,
Renderer2,
TemplateRef,
@ -18,6 +20,7 @@ import { fadeAnimation } from '../../animations/modal.animations';
import { Confirmation } from '../../models/confirmation';
import { ConfirmationService } from '../../services/confirmation.service';
import { ModalService } from '../../services/modal.service';
import { SUPPRESS_UNSAVED_CHANGES_WARNING } from '../../tokens/suppress-unsaved-changes-warning.token';
import { ButtonComponent } from '../button/button.component';
export type ModalSize = 'sm' | 'md' | 'lg' | 'xl';
@ -57,6 +60,8 @@ export class ModalComponent implements OnDestroy {
@Input() size: ModalSize = 'lg';
@Input() suppressUnsavedChangesWarning = this.suppressUnsavedChangesWarningToken;
@ContentChild(ButtonComponent, { static: false, read: ButtonComponent })
abpSubmit: ButtonComponent;
@ -104,6 +109,9 @@ export class ModalComponent implements OnDestroy {
private confirmationService: ConfirmationService,
private modalService: ModalService,
private subscription: SubscriptionService,
@Optional()
@Inject(SUPPRESS_UNSAVED_CHANGES_WARNING)
private suppressUnsavedChangesWarningToken: boolean,
) {
this.initToggleStream();
}
@ -139,7 +147,7 @@ export class ModalComponent implements OnDestroy {
close() {
if (this.busy) return;
if (this.isFormDirty) {
if (this.isFormDirty && !this.suppressUnsavedChangesWarning) {
if (this.isConfirmationOpen) return;
this.isConfirmationOpen = true;

1
npm/ng-packs/packages/theme-shared/src/lib/tokens/index.ts

@ -1,3 +1,4 @@
export * from './append-content.token';
export * from './http-error.token';
export * from './lazy-styles.token';
export * from './suppress-unsaved-changes-warning.token';

6
npm/ng-packs/packages/theme-shared/src/lib/tokens/suppress-unsaved-changes-warning.token.ts

@ -0,0 +1,6 @@
import { InjectionToken } from '@angular/core';
// TODO: Should be documented
export const SUPPRESS_UNSAVED_CHANGES_WARNING = new InjectionToken<boolean>(
'SUPPRESS_UNSAVED_CHANGES_WARNING',
);
Loading…
Cancel
Save