You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
argos/dmp-frontend/src/app/datasets/editor/dataset-editor.component.ts

118 lines
3.5 KiB
TypeScript

import { AfterViewInit, Component, Input, ViewEncapsulation } from '@angular/core';
import { FormGroup } from '@angular/forms';
import { MatSnackBar } from '@angular/material';
import { Router } from '@angular/router';
import { TranslateService } from '@ngx-translate/core';
import { DatasetModel } from '../../models/datasets/DatasetModel';
@Component({
selector: 'app-dataset-editor-component',
templateUrl: 'dataset-editor.component.html',
styleUrls: ['./dataset-editor.component.scss'],
encapsulation: ViewEncapsulation.None
})
export class DatasetEditorComponent implements AfterViewInit {
isNew = true;
dataset: DatasetModel;
@Input() formGroup: FormGroup = null;
// filtereddataRepositoriesAsync: boolean = false;
// filteredRegistriesAsync: boolean = false;
// filteredServicesAsync: boolean = false;
// filtereddataRepositories: ExternalSourcesItemModel[];
// filteredRegistries: ExternalSourcesItemModel[];
// filteredServices: ExternalSourcesItemModel[];
constructor(
public snackBar: MatSnackBar,
public router: Router,
public language: TranslateService,
) {
}
ngAfterViewInit() {
/* this.route.params.pipe(takeUntil(this._destroyed)).subscribe((params: Params) => {
const itemId = params['id'];
if (itemId != null) {
this.isNew = false;
this.datasetService.getSingle(itemId).map(data => data as DatasetModel)
.pipe(takeUntil(this._destroyed))
.subscribe(data => {
this.dataset = new JsonSerializer<DatasetModel>().fromJSONObject(data, DatasetModel);
this.formGroup = this.dataset.buildForm();
});
} else {
this.dataset = new DatasetModel();
setTimeout(() => {
this.formGroup = this.dataset.buildForm();
});
}
}); */
}
public cancel(): void {
this.router.navigate(['/datasets']);
}
// filterdataRepositories(value: string): void {
// this.filtereddataRepositories = undefined;
// if (value) {
// this.filtereddataRepositoriesAsync = true;
// this.externalSourcesService.searchDMPOrganizations(value).pipe(takeUntil(this._destroyed)).subscribe(items => {
// this.filtereddataRepositories = items;
// this.filtereddataRepositoriesAsync = false;
// // this.filteredOrganisations = items.filter((filteredObj: any) => {
// // return this.objectsModel ? this.objectsModel.indexOf(filteredObj) < 0 : true;
// // });
// });
// }
// }
// filterRegistries(value: string): void {
// this.filteredRegistries = undefined;
// if (value) {
// this.filteredRegistriesAsync = true;
// this.externalSourcesService.searchDMPResearchers(value).pipe(takeUntil(this._destroyed)).subscribe(items => {
// this.filteredRegistries = items;
// this.filteredRegistriesAsync = false;
// // this.filteredOrganisations = items.filter((filteredObj: any) => {
// // return this.objectsModel ? this.objectsModel.indexOf(filteredObj) < 0 : true;
// // });
// });
// }
// }
// filterServices(value: string): void {
// this.filteredServices = undefined;
// if (value) {
// this.filteredServicesAsync = true;
// this.externalSourcesService.searchDatasetService(value).pipe(takeUntil(this._destroyed)).subscribe(items => {
// this.filteredServices = items;
// this.filteredServicesAsync = false;
// // this.filteredOrganisations = items.filter((filteredObj: any) => {
// // return this.objectsModel ? this.objectsModel.indexOf(filteredObj) < 0 : true;
// // });
// });
// }
// }
}