|
|
@ -9,11 +9,13 @@ import { |
|
|
Renderer2, |
|
|
Renderer2, |
|
|
TemplateRef, |
|
|
TemplateRef, |
|
|
ViewChild, |
|
|
ViewChild, |
|
|
|
|
|
ViewChildren, |
|
|
} from '@angular/core'; |
|
|
} from '@angular/core'; |
|
|
import { fromEvent, Subject, timer } from 'rxjs'; |
|
|
import { fromEvent, Subject, timer } from 'rxjs'; |
|
|
import { debounceTime, filter, take, takeUntil } from 'rxjs/operators'; |
|
|
import { filter, take, takeUntil } from 'rxjs/operators'; |
|
|
import { ConfirmationService } from '../../services/confirmation.service'; |
|
|
|
|
|
import { Toaster } from '../../models/toaster'; |
|
|
import { Toaster } from '../../models/toaster'; |
|
|
|
|
|
import { ConfirmationService } from '../../services/confirmation.service'; |
|
|
|
|
|
import { ButtonComponent } from '../button/button.component'; |
|
|
|
|
|
|
|
|
export type ModalSize = 'sm' | 'md' | 'lg' | 'xl'; |
|
|
export type ModalSize = 'sm' | 'md' | 'lg' | 'xl'; |
|
|
|
|
|
|
|
|
@ -49,24 +51,35 @@ export class ModalComponent implements OnDestroy { |
|
|
this.renderer.addClass(this.modalContent.nativeElement, 'fade-out-top'); |
|
|
this.renderer.addClass(this.modalContent.nativeElement, 'fade-out-top'); |
|
|
setTimeout(() => { |
|
|
setTimeout(() => { |
|
|
this.setVisible(value); |
|
|
this.setVisible(value); |
|
|
// this.renderer.removeClass(this.modalContent.nativeElement, 'fade-out-top');
|
|
|
|
|
|
this.ngOnDestroy(); |
|
|
this.ngOnDestroy(); |
|
|
}, ANIMATION_TIMEOUT - 10); |
|
|
}, ANIMATION_TIMEOUT - 10); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Input() |
|
|
|
|
|
get busy(): boolean { |
|
|
|
|
|
return this._busy; |
|
|
|
|
|
} |
|
|
|
|
|
set busy(value: boolean) { |
|
|
|
|
|
if (this.abpSubmit && this.abpSubmit instanceof ButtonComponent) { |
|
|
|
|
|
this.abpSubmit.loading = value; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this._busy = value; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@Input() centered: boolean = false; |
|
|
@Input() centered: boolean = false; |
|
|
|
|
|
|
|
|
@Input() modalClass: string = ''; |
|
|
@Input() modalClass: string = ''; |
|
|
|
|
|
|
|
|
@Input() size: ModalSize = 'lg'; |
|
|
@Input() size: ModalSize = 'lg'; |
|
|
|
|
|
|
|
|
@Output() visibleChange = new EventEmitter<boolean>(); |
|
|
|
|
|
|
|
|
|
|
|
@Input() height: number; |
|
|
@Input() height: number; |
|
|
|
|
|
|
|
|
@Input() minHeight: number; |
|
|
@Input() minHeight: number; |
|
|
|
|
|
|
|
|
|
|
|
@Output() visibleChange = new EventEmitter<boolean>(); |
|
|
|
|
|
|
|
|
@Output() init = new EventEmitter<void>(); |
|
|
@Output() init = new EventEmitter<void>(); |
|
|
|
|
|
|
|
|
@ContentChild('abpHeader', { static: false }) abpHeader: TemplateRef<any>; |
|
|
@ContentChild('abpHeader', { static: false }) abpHeader: TemplateRef<any>; |
|
|
@ -77,10 +90,16 @@ export class ModalComponent implements OnDestroy { |
|
|
|
|
|
|
|
|
@ContentChild('abpClose', { static: false, read: ElementRef }) abpClose: ElementRef<any>; |
|
|
@ContentChild('abpClose', { static: false, read: ElementRef }) abpClose: ElementRef<any>; |
|
|
|
|
|
|
|
|
|
|
|
@ContentChild(ButtonComponent, { static: false, read: ButtonComponent }) abpSubmit: ButtonComponent; |
|
|
|
|
|
|
|
|
@ViewChild('abpModalContent', { static: false }) modalContent: ElementRef; |
|
|
@ViewChild('abpModalContent', { static: false }) modalContent: ElementRef; |
|
|
|
|
|
|
|
|
|
|
|
@ViewChildren('abp-button') abpButtons; |
|
|
|
|
|
|
|
|
_visible: boolean = false; |
|
|
_visible: boolean = false; |
|
|
|
|
|
|
|
|
|
|
|
_busy: boolean = false; |
|
|
|
|
|
|
|
|
showModal: boolean = false; |
|
|
showModal: boolean = false; |
|
|
|
|
|
|
|
|
isOpenConfirmation: boolean = false; |
|
|
isOpenConfirmation: boolean = false; |
|
|
@ -108,16 +127,6 @@ export class ModalComponent implements OnDestroy { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
listen() { |
|
|
listen() { |
|
|
fromEvent(document, 'keyup') |
|
|
|
|
|
.pipe( |
|
|
|
|
|
takeUntil(this.destroy$), |
|
|
|
|
|
debounceTime(250), |
|
|
|
|
|
filter((key: KeyboardEvent) => key && key.code === 'Escape' && this.closable), |
|
|
|
|
|
) |
|
|
|
|
|
.subscribe(_ => { |
|
|
|
|
|
this.close(); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
setTimeout(() => { |
|
|
setTimeout(() => { |
|
|
if (!this.abpClose) return; |
|
|
if (!this.abpClose) return; |
|
|
|
|
|
|
|
|
@ -129,10 +138,13 @@ export class ModalComponent implements OnDestroy { |
|
|
.subscribe(() => this.close()); |
|
|
.subscribe(() => this.close()); |
|
|
}, 0); |
|
|
}, 0); |
|
|
|
|
|
|
|
|
|
|
|
window.location.hash = '#abp-modal'; |
|
|
this.init.emit(); |
|
|
this.init.emit(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
close() { |
|
|
close() { |
|
|
|
|
|
if (!this.closable || this.busy) return; |
|
|
|
|
|
|
|
|
const nodes = getFlatNodes( |
|
|
const nodes = getFlatNodes( |
|
|
(this.modalContent.nativeElement.querySelector('#abp-modal-body') as HTMLElement).childNodes, |
|
|
(this.modalContent.nativeElement.querySelector('#abp-modal-body') as HTMLElement).childNodes, |
|
|
); |
|
|
); |
|
|
@ -155,10 +167,8 @@ export class ModalComponent implements OnDestroy { |
|
|
} else { |
|
|
} else { |
|
|
this.visible = false; |
|
|
this.visible = false; |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
onClickBackdrop() { |
|
|
window.location.hash = 'body'; |
|
|
this.close(); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|