Skip to content
Snippets Groups Projects
json-renderer.component.ts 1.37 KiB
Newer Older
  • Learn to ignore specific revisions
  • François Agneray's avatar
    François Agneray committed
    /**
     * This file is part of Anis Client.
     *
     * @copyright Laboratoire d'Astrophysique de Marseille / CNRS
     *
     * For the full copyright and license information, please view the LICENSE
     * file that was distributed with this source code.
     */
    
    
    import { Component, ChangeDetectionStrategy, TemplateRef } from '@angular/core';
    
    François Agneray's avatar
    François Agneray committed
    import { BsModalService, BsModalRef } from 'ngx-bootstrap/modal';
    
    
    import { AbstractRendererComponent } from '../abstract-renderer.component';
    
    /**
     * @class
     * @classdesc JSON renderer component.
     */
    
    François Agneray's avatar
    François Agneray committed
    @Component({
        selector: 'app-json-renderer',
        templateUrl: 'json-renderer.component.html',
        changeDetection: ChangeDetectionStrategy.OnPush
    })
    
    export class JsonRendererComponent extends AbstractRendererComponent {
    
    François Agneray's avatar
    François Agneray committed
        modalRef: BsModalRef;
    
    
        constructor(private modalService: BsModalService) {
            super();
        }
    
        getConfig() {
    
            return super.getConfig();
    
    François Agneray's avatar
    François Agneray committed
    
        /**
         * Opens modal.
         *
         * @param  {TemplateRef<any>} template - The modal template to open.
         */
        openModal(template: TemplateRef<any>): void {
            this.modalRef = this.modalService.show(
                template,
                Object.assign({}, { class: 'modal-fit-content' })
            );
        }
    
    
        isEmpty() {
            if (!this.value || Object.keys(this.value).length === 0) {
                return false;
            } else {
                return true;
            }
        }
    
    François Agneray's avatar
    François Agneray committed
    }