argos/dmp-frontend/src/app/datasets/editor/dataset-editor.component.ts

118 lines
3.5 KiB
TypeScript
Raw Normal View History

2018-11-27 18:33:17 +01:00
import { AfterViewInit, Component, Input, ViewEncapsulation } from '@angular/core';
2018-10-05 17:00:54 +02:00
import { FormGroup } from '@angular/forms';
2018-11-27 18:33:17 +01:00
import { MatSnackBar } from '@angular/material';
import { Router } from '@angular/router';
import { TranslateService } from '@ngx-translate/core';
2018-10-05 17:00:54 +02:00
import { DatasetModel } from '../../models/datasets/DatasetModel';
2017-12-18 15:28:08 +01:00
@Component({
2018-10-05 17:00:54 +02:00
selector: 'app-dataset-editor-component',
templateUrl: 'dataset-editor.component.html',
styleUrls: ['./dataset-editor.component.scss'],
encapsulation: ViewEncapsulation.None
2017-12-18 15:28:08 +01:00
})
export class DatasetEditorComponent implements AfterViewInit {
2018-10-05 17:00:54 +02:00
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() {
2018-11-27 18:33:17 +01:00
/* this.route.params.pipe(takeUntil(this._destroyed)).subscribe((params: Params) => {
2018-10-05 17:00:54 +02:00
const itemId = params['id'];
if (itemId != null) {
this.isNew = false;
this.datasetService.getSingle(itemId).map(data => data as DatasetModel)
2018-11-27 18:33:17 +01:00
.pipe(takeUntil(this._destroyed))
2018-10-05 17:00:54 +02:00
.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;
2018-11-27 18:33:17 +01:00
// this.externalSourcesService.searchDMPOrganizations(value).pipe(takeUntil(this._destroyed)).subscribe(items => {
2018-10-05 17:00:54 +02:00
// 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;
2018-11-27 18:33:17 +01:00
// this.externalSourcesService.searchDMPResearchers(value).pipe(takeUntil(this._destroyed)).subscribe(items => {
2018-10-05 17:00:54 +02:00
// 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;
2018-11-27 18:33:17 +01:00
// this.externalSourcesService.searchDatasetService(value).pipe(takeUntil(this._destroyed)).subscribe(items => {
2018-10-05 17:00:54 +02:00
// this.filteredServices = items;
// this.filteredServicesAsync = false;
// // this.filteredOrganisations = items.filter((filteredObj: any) => {
// // return this.objectsModel ? this.objectsModel.indexOf(filteredObj) < 0 : true;
// // });
// });
// }
// }
2018-05-28 11:50:42 +02:00
}