blob: 9fad876892c01a28673379fc7425ac95ce01f00a [file] [log] [blame]
/********************************************************************************
* 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, Input, OnInit } from '@angular/core';
import { DialogService } from 'primeng/api';
import { Observable } from 'rxjs';
import { Attribute, MDMLink } from '@navigator/node';
import { ContextAttributeIdentifier } from '@details/model/details.model';
import { FileExplorerDialogComponent } from '../file-explorer-dialog/file-explorer-dialog.component';
@Component({
selector: 'file-link-sequence-editor',
templateUrl: './file-link-sequence-editor.component.html'
})
export class FileLinkSequenceEditorComponent implements OnInit {
@Input() ident: ContextAttributeIdentifier;
@Input() attribute: Attribute;
public link: MDMLink;
public links: MDMLink[];
constructor(private dialogService: DialogService) { }
ngOnInit() {
if (this.attribute != undefined && this.attribute.value != undefined) {
if (this.getValues() != undefined) {
this.links = (this.getValues<MDMLink[]>()).map(l => Object.assign(new MDMLink(), l));
}
}
setTimeout(() => {
this.onShowFileExplorerDialog();
});
}
private getValues<T>() {
if (this.attribute != undefined && this.attribute.value != undefined) {
const tmp = this.ident.contextGroup != undefined ? this.attribute.value[this.ident.contextGroup] : this.attribute.value;
return tmp !== '' ? tmp : undefined;
}
}
public onShowFileExplorerDialog() {
let title = 'File upload wizard for ' + this.ident.contextComponent.name;
if (this.attribute != undefined) {
title += '.' + this.attribute.name;
}
const ref = this.dialogService.open(FileExplorerDialogComponent, {
data: {
contextDescribable: this.ident.contextDescribable,
contextComponent: this.ident.contextComponent,
attribute: this.attribute,
contextGroup: this.ident.contextGroup,
contextType: this.ident.contextType,
readOnly: false
},
header: title,
width: '70%'
});
}
}