| /******************************************************************************** |
| * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation |
| * |
| * See the NOTICE file(s) distributed with this work for additional |
| * information regarding copyright ownership. |
| * |
| * This program and the accompanying materials are made available under the |
| * terms of the Eclipse Public License v. 2.0 which is available at |
| * http://www.eclipse.org/legal/epl-2.0. |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| * |
| ********************************************************************************/ |
| |
| import { Component, OnInit, Input } from '@angular/core'; |
| |
| import { DialogService } from 'primeng/api'; |
| |
| import { ContextAttributeIdentifier } from '@details/model/details.model'; |
| import { MDMLink } from '@navigator/node'; |
| import { FileLinkEditorDialogComponent } from '../file-link-editor-dialog/file-link-editor-dialog.component'; |
| import { FileService } from '@file-explorer/services/file.service'; |
| |
| @Component({ |
| selector: 'mdm5-file-link-editor', |
| templateUrl: './file-link-editor.component.html' |
| }) |
| export class FileLinkEditorComponent implements OnInit { |
| |
| @Input() ident: ContextAttributeIdentifier; |
| |
| public link: MDMLink; |
| constructor(private dialogService: DialogService) { } |
| |
| ngOnInit() { |
| if (this.ident.attribute != undefined && this.ident.attribute.value != undefined) { |
| this.link = Object.assign(new MDMLink(), this.getValue<MDMLink>()); |
| } |
| setTimeout(() => { |
| this.showFileExplorerDialog(); |
| }); |
| } |
| |
| private getValue<T>() { |
| if (this.ident.attribute != undefined && this.ident.attribute.value != undefined) { |
| return <T> (this.ident.contextGroup != undefined ? this.ident.attribute.value[this.ident.contextGroup] : this.ident.attribute.value); |
| } |
| } |
| |
| public showFileExplorerDialog() { |
| let title = 'File upload wizard for ' + this.ident.contextComponent.name; |
| if (this.ident.attribute != undefined) { |
| title += '.' + this.ident.attribute.name; |
| } |
| |
| const ref = this.dialogService.open(FileLinkEditorDialogComponent, { |
| data: { |
| ident: this.ident |
| }, |
| header: title, |
| width: '650px' |
| }); |
| } |
| } |