UNPKG

ng-zorro-antd

Version:

An enterprise-class UI components based on Ant Design and Angular

132 lines 14.9 kB
/** * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE */ import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core'; import { isPromise } from 'ng-zorro-antd/core/util'; import { Subject } from 'rxjs'; import { takeUntil } from 'rxjs/operators'; import { NzI18nService } from 'ng-zorro-antd/i18n'; import { NzModalRef } from './modal-ref'; import { ModalOptions } from './modal-types'; export class NzModalFooterComponent { constructor(i18n, config) { this.i18n = i18n; this.config = config; this.buttonsFooter = false; this.buttons = []; this.cancelTriggered = new EventEmitter(); this.okTriggered = new EventEmitter(); this.destroy$ = new Subject(); if (Array.isArray(config.nzFooter)) { this.buttonsFooter = true; this.buttons = config.nzFooter.map(mergeDefaultOption); } this.i18n.localeChange.pipe(takeUntil(this.destroy$)).subscribe(() => { this.locale = this.i18n.getLocaleData('Modal'); }); } onCancel() { this.cancelTriggered.emit(); } onOk() { this.okTriggered.emit(); } /** * Returns the value of the specified key. * If it is a function, run and return the return value of the function. */ getButtonCallableProp(options, prop) { const value = options[prop]; const componentInstance = this.modalRef.getContentComponent(); return typeof value === 'function' ? value.apply(options, componentInstance && [componentInstance]) : value; } /** * Run function based on the type and set its `loading` prop if needed. */ onButtonClick(options) { const loading = this.getButtonCallableProp(options, 'loading'); if (!loading) { const result = this.getButtonCallableProp(options, 'onClick'); if (options.autoLoading && isPromise(result)) { options.loading = true; result.then(() => (options.loading = false)).catch(() => (options.loading = false)); } } } ngOnDestroy() { this.destroy$.next(); this.destroy$.complete(); } } NzModalFooterComponent.decorators = [ { type: Component, args: [{ selector: 'div[nz-modal-footer]', exportAs: 'NzModalFooterBuiltin', template: ` <ng-container *ngIf="config.nzFooter; else defaultFooterButtons"> <ng-container *nzStringTemplateOutlet="config.nzFooter; context: { $implicit: config.nzComponentParams, modalRef: modalRef }"> <div *ngIf="!buttonsFooter" [innerHTML]="config.nzTitle"></div> <ng-container *ngIf="buttonsFooter"> <button *ngFor="let button of buttons" nz-button (click)="onButtonClick(button)" [hidden]="!getButtonCallableProp(button, 'show')" [nzLoading]="getButtonCallableProp(button, 'loading')" [disabled]="getButtonCallableProp(button, 'disabled')" [nzType]="button.type!" [nzDanger]="button.danger" [nzShape]="button.shape!" [nzSize]="button.size!" [nzGhost]="button.ghost!" > {{ button.label }} </button> </ng-container> </ng-container> </ng-container> <ng-template #defaultFooterButtons> <button *ngIf="config.nzCancelText !== null" [attr.cdkFocusInitial]="config.nzAutofocus === 'cancel' || null" nz-button (click)="onCancel()" [nzLoading]="!!config.nzCancelLoading" [disabled]="config.nzCancelDisabled" > {{ config.nzCancelText || locale.cancelText }} </button> <button *ngIf="config.nzOkText !== null" [attr.cdkFocusInitial]="config.nzAutofocus === 'ok' || null" nz-button [nzType]="config.nzOkType!" [nzDanger]="config.nzOkDanger" (click)="onOk()" [nzLoading]="!!config.nzOkLoading" [disabled]="config.nzOkDisabled" > {{ config.nzOkText || locale.okText }} </button> </ng-template> `, host: { class: 'ant-modal-footer' }, changeDetection: ChangeDetectionStrategy.Default },] } ]; NzModalFooterComponent.ctorParameters = () => [ { type: NzI18nService }, { type: ModalOptions } ]; NzModalFooterComponent.propDecorators = { cancelTriggered: [{ type: Output }], okTriggered: [{ type: Output }], modalRef: [{ type: Input }] }; function mergeDefaultOption(options) { return Object.assign({ type: null, size: 'default', autoLoading: true, show: true, loading: false, disabled: false }, options); } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibW9kYWwtZm9vdGVyLmNvbXBvbmVudC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL2NvbXBvbmVudHMvbW9kYWwvbW9kYWwtZm9vdGVyLmNvbXBvbmVudC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7O0dBR0c7QUFFSCxPQUFPLEV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plXT1cImJ1dHRvbi5zaXplIVwiXG4gICAgICAgICAgICBbbnpHaG9zdF09XCJidXR0b24uZ2hvc3QhXCJcbiAgICAgICAgICA+XG4gICAgICAgICAgICB7eyBidXR0b24ubGFiZWwgfX1cbiAgICAgICAgICA8L2J1dHRvbj5cbiAgICAgICAgPC9uZy1jb250YWluZXI+XG4gICAgICA8L25nLWNvbnRhaW5lcj5cbiAgICA8L25nLWNvbnRhaW5lcj5cbiAgICA8bmctdGVtcGxhdGUgI2RlZmF1bHRGb290ZXJCdXR0b25zPlxuICAgICAgPGJ1dHRvblxuICAgICAgICAqbmdJZj1cImNvbmZpZy5uekNhbmNlbFRleHQgIT09IG51bGxcIlxuICAgICAgICBbYXR0ci5jZGtGb2N1c0luaXRpYWxdPVwiY29uZmlnLm56QXV0b2ZvY3VzID09PSAnY2FuY2VsJyB8fCBudWxsXCJcbiAgICAgICAgbnotYnV0dG9uXG4gICAgICAgIChjbGljayk9XCJvbkNhbmNlbCgpXCJcbiAgICAgICAgW256TG9hZGluZ109XCIhIWNvbmZpZy5uekNhbmNlbExvYWRpbmdcIlxuICAgICAgICBbZGlzYWJsZWRdPVwiY29uZmlnLm56Q2FuY2VsRGlzYWJsZWRcIlxuICAgICAgPlxuICAgICAgICB7eyBjb25maWcubnpDYW5jZWxUZXh0IHx8IGxvY2FsZS5jYW5jZWxUZXh0IH19XG4gICAgICA8L2J1dHRvbj5cbiAgICAgIDxidXR0b25cbiAgICAgICAgKm5nSWY9XCJjb25maWcubnpPa1RleHQgIT09IG51bGxcIlxuICAgICAgICBbYXR0ci5jZGtGb2N1c0luaXRpYWxdPVwiY29uZmlnLm56QXV0b2ZvY3VzID09PSAnb2snIHx8IG51bGxcIlxuICAgICAgICBuei1idXR0b25cbiAgICAgICAgW256VHlwZV09XCJjb25maWcubnpPa1R5cGUhXCJcbiAgICAgICAgW256RGFuZ2VyXT1cImNvbmZpZy5uek9rRGFuZ2VyXCJcbiAgICAgICAgKGNsaWNrKT1cIm9uT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