Removes preview status of DMP at Dataset Public Editor.

This commit is contained in:
apapachristou 2019-10-17 10:43:28 +03:00
parent 52cfc6cde6
commit c1a6a8d30e
1 changed files with 17 additions and 10 deletions

View File

@ -1,5 +1,5 @@
import { of as observableOf, Observable } from 'rxjs'; import { of as observableOf, Observable } from 'rxjs';
import { map, catchError, takeUntil } from 'rxjs/operators'; import { map, catchError, takeUntil } from 'rxjs/operators';
import { Component, OnInit, ViewChild } from '@angular/core'; import { Component, OnInit, ViewChild } from '@angular/core';
import { FormControl, FormGroup } from '@angular/forms'; import { FormControl, FormGroup } from '@angular/forms';
import { MatDialog } from '@angular/material/dialog'; import { MatDialog } from '@angular/material/dialog';
@ -89,9 +89,9 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
this.dmpAutoCompleteConfiguration = { this.dmpAutoCompleteConfiguration = {
filterFn: this.searchDmp.bind(this), filterFn: this.searchDmp.bind(this),
initialItems: (extraData) => this.searchDmp(''), initialItems: (extraData) => this.searchDmp(''),
displayFn: (item) => (item['status'] ? this.language.instant('TYPES.DATASET-STATUS.FINALISED').toUpperCase() : this.language.instant('TYPES.DATASET-STATUS.DRAFT').toUpperCase()) + ': ' + item['label'], displayFn: (item) => this.getDatasetDisplay(item),
titleFn: (item) => item['label'], titleFn: (item) => item['label'],
iconFn: (item) => item['status'] ? 'lock' : 'lock_open' iconFn: (item) => this.publicMode ? '' : (item['status'] ? 'lock' : 'lock_open')
}; };
const params = this.route.snapshot.params; const params = this.route.snapshot.params;
@ -136,11 +136,11 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
// this.availableProfiles = this.datasetWizardModel.dmp.profiles; // this.availableProfiles = this.datasetWizardModel.dmp.profiles;
}, },
error => { error => {
this.uiNotificationService.snackBarNotification(this.language.instant('DATASET-WIZARD.MESSAGES.DATAESET-NOT-FOUND'), SnackBarNotificationLevel.Error); this.uiNotificationService.snackBarNotification(this.language.instant('DATASET-WIZARD.MESSAGES.DATAESET-NOT-FOUND'), SnackBarNotificationLevel.Error);
this.router.navigate(['/plans']); this.router.navigate(['/plans']);
return observableOf(null); return observableOf(null);
}); });
} else if (dmpId != null) { } else if (dmpId != null) {
this.isNew = true; this.isNew = true;
this.dmpService.getSingle(dmpId).pipe(map(data => data as DmpModel)) this.dmpService.getSingle(dmpId).pipe(map(data => data as DmpModel))
@ -368,6 +368,13 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
this.router.navigate(['/datasets']); this.router.navigate(['/datasets']);
} }
getDatasetDisplay(item: any): string {
if (!this.publicMode) {
return (item['status'] ? this.language.instant('TYPES.DATASET-STATUS.FINALISED').toUpperCase() : this.language.instant('TYPES.DATASET-STATUS.DRAFT').toUpperCase()) + ': ' + item['label'];
}
else { return item['label']; }
}
getDefinition() { getDefinition() {
// if (this.formGroup.invalid) { setTimeout(() => this.stepper.selectedIndex = 0); return; } // if (this.formGroup.invalid) { setTimeout(() => this.stepper.selectedIndex = 0); return; }
this.datasetWizardService.getDefinition(this.formGroup.get('profile').value) this.datasetWizardService.getDefinition(this.formGroup.get('profile').value)
@ -437,7 +444,7 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
} }
hasNotReversableStatus(): boolean { hasNotReversableStatus(): boolean {
if (this.formGroup.get('dmp').value) { if (this.formGroup.get('dmp').value && !this.publicMode) {
return (this.formGroup.get('dmp').value.status == DmpStatus.Finalized && this.formGroup.get('status').value == DatasetStatus.Finalized); return (this.formGroup.get('dmp').value.status == DmpStatus.Finalized && this.formGroup.get('status').value == DatasetStatus.Finalized);
} else { } else {
return false; return false;