@ -33,7 +33,7 @@ import { ValidationErrorModel } from '@common/forms/validation/error-model/valid
import { TranslateService } from '@ngx-translate/core' ;
import * as FileSaver from 'file-saver' ;
import { Observable , of as observableOf , interval } from 'rxjs' ;
import { delay, map , takeUntil } from 'rxjs/operators' ;
import { catchError, delay, map , takeUntil } from 'rxjs/operators' ;
import { Principal } from "@app/core/model/auth/principal" ;
import { Role } from "@app/core/common/enum/role" ;
import { LockService } from '@app/core/services/lock/lock.service' ;
@ -185,6 +185,10 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
this . setIsUserOwner ( ) ;
if ( ! this . isUserOwner ) {
if ( this . isUserMember ( ) ) {
this . router . navigate ( [ 'plans' , 'overview' , itemId ] ) ;
}
this . isFinalized = true ;
this . formGroup . disable ( ) ;
}
@ -365,7 +369,15 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
setIsUserOwner() {
if ( this . dmp ) {
const principal : Principal = this . authentication . current ( ) ;
this . isUserOwner = principal . id === this . dmp . users . find ( x = > x . role === Role . Owner ) . id ;
this . isUserOwner = ! ! this . dmp . users . find ( x = > ( x . role === Role . Owner ) && ( x . id === principal . id ) ) ;
}
}
isUserMember ( ) : boolean {
try {
const principal : Principal = this . authentication . current ( ) ;
return ! ! this . dmp . users . find ( x = > ( x . role === Role . Member ) && ( x . id === principal . id ) ) ;
} catch {
return false ;
}
}