diff --git a/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.html b/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.html index e96507cb5..f26d1fa67 100644 --- a/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.html +++ b/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.html @@ -13,16 +13,16 @@ more_horiz - - - @@ -58,14 +58,14 @@ view_agenda {{ 'SIDE-BAR.GENERAL' | translate }} - + work_outline {{ 'DMP-LISTING.COLUMNS.GRANT' | translate }} - + diff --git a/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.ts b/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.ts index 950ea4fa9..ef5a0d350 100644 --- a/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.ts +++ b/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.ts @@ -4,7 +4,6 @@ import { FormGroup } from '@angular/forms'; import { MatDialog } from '@angular/material/dialog'; import { ActivatedRoute, Params, Router } from '@angular/router'; import { DmpStatus } from '@app/core/common/enum/dmp-status'; -import { Status } from '@app/core/common/enum/Status'; import { DataTableRequest } from '@app/core/model/data-table/data-table-request'; import { DmpProfileDefinition } from '@app/core/model/dmp-profile/dmp-profile'; import { DmpProfileListing } from '@app/core/model/dmp-profile/dmp-profile-listing'; @@ -19,7 +18,7 @@ import { AuthService } from '@app/core/services/auth/auth.service'; import { DmpProfileService } from '@app/core/services/dmp/dmp-profile.service'; import { DmpService } from '@app/core/services/dmp/dmp.service'; import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service'; -import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog/confirmation-dialog.component'; +import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog/confirmation-dialog.component'; import { DmpEditorModel } from '@app/ui/dmp/editor/dmp-editor.model'; import { DmpFinalizeDialogComponent, DmpFinalizeDialogInput } from '@app/ui/dmp/editor/dmp-finalize-dialog/dmp-finalize-dialog.component'; import { FunderFormModel } from '@app/ui/dmp/editor/grant-tab/funder-form-model'; @@ -35,7 +34,8 @@ import { TranslateService } from '@ngx-translate/core'; import * as FileSaver from 'file-saver'; import { Observable, of as observableOf } from 'rxjs'; import { map, takeUntil } from 'rxjs/operators'; -import { Guid } from '@common/types/guid'; +import { Principal } from "@app/core/model/auth/Principal"; +import { Role } from "@app/core/common/enum/role"; @Component({ selector: 'app-dmp-editor-component', @@ -61,6 +61,7 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC filteredOptions: DmpProfileListing[]; selectedDmpProfileDefinition: DmpProfileDefinition; DynamicDmpFieldResolverComponent: any; + isUserOwner: boolean = true; constructor( private dmpProfileService: DmpProfileService, @@ -70,6 +71,7 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC private language: TranslateService, private dialog: MatDialog, private uiNotificationService: UiNotificationService, + private authentication: AuthService, private authService: AuthService, private formService: FormService ) { @@ -108,6 +110,11 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC this.dmp.funder = new FunderFormModel(); this.dmp.fromModel(data); this.formGroup = this.dmp.buildForm(); + this.setIsUserOwner(); + if (this.isUserOwner) { + this.isFinalized = true; + this.formGroup.disable(); + } //this.registerFormEventsForDmpProfile(this.dmp.definition); if (!this.editMode || this.dmp.status === DmpStatus.Finalized) { this.isFinalized = true; @@ -201,6 +208,13 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC return this.authService.current() != null; } + setIsUserOwner() { + if (this.dmp) { + const principal: Principal = this.authentication.current(); + this.isUserOwner = principal.id === this.dmp.users.find(x => x.role === Role.Owner).id; + } + } + registerFormEventsForNewItem() { this.breadCrumbs = observableOf([ { diff --git a/dmp-frontend/src/app/ui/dmp/editor/dynamic-field-resolver/dynamic-dmp-field-resolver.component.ts b/dmp-frontend/src/app/ui/dmp/editor/dynamic-field-resolver/dynamic-dmp-field-resolver.component.ts index d95540f87..23ff93644 100644 --- a/dmp-frontend/src/app/ui/dmp/editor/dynamic-field-resolver/dynamic-dmp-field-resolver.component.ts +++ b/dmp-frontend/src/app/ui/dmp/editor/dynamic-field-resolver/dynamic-dmp-field-resolver.component.ts @@ -26,6 +26,7 @@ export class DynamicDmpFieldResolverComponent implements OnInit, OnDestroy { @Input() dmpProfileId: string; @Input() dmpProfileDefinition: DmpProfileDefinition; @Input() formGroup: FormGroup; + @Input() isUserOwner: boolean; constructor( private dmpProfileService: DmpProfileService diff --git a/dmp-frontend/src/app/ui/dmp/editor/general-tab/general-tab.component.html b/dmp-frontend/src/app/ui/dmp/editor/general-tab/general-tab.component.html index 2683c7562..a1090650e 100644 --- a/dmp-frontend/src/app/ui/dmp/editor/general-tab/general-tab.component.html +++ b/dmp-frontend/src/app/ui/dmp/editor/general-tab/general-tab.component.html @@ -68,7 +68,7 @@ - + diff --git a/dmp-frontend/src/app/ui/dmp/editor/general-tab/general-tab.component.ts b/dmp-frontend/src/app/ui/dmp/editor/general-tab/general-tab.component.ts index 1990eb528..63c146f4b 100644 --- a/dmp-frontend/src/app/ui/dmp/editor/general-tab/general-tab.component.ts +++ b/dmp-frontend/src/app/ui/dmp/editor/general-tab/general-tab.component.ts @@ -30,6 +30,7 @@ export class GeneralTabComponent extends BaseComponent implements OnInit { @Input() formGroup: FormGroup = null; @Input() isNewVersion: boolean; + @Input() isUserOwner: boolean; profilesAutoCompleteConfiguration: MultipleAutoCompleteConfiguration = { filterFn: this.filterProfiles.bind(this), @@ -80,6 +81,10 @@ export class GeneralTabComponent extends BaseComponent implements OnInit { if (this.isNewVersion) { this.formGroup.get('label').disable(); } + + if (!this.isUserOwner) { + this.formGroup.disable(); + } } registerFormEventsForDmpProfile(definitionProperties?: DmpProfileDefinition): void { diff --git a/dmp-frontend/src/app/ui/dmp/editor/grant-tab/grant-tab.component.html b/dmp-frontend/src/app/ui/dmp/editor/grant-tab/grant-tab.component.html index e4f7ae5a2..b2b8c4356 100644 --- a/dmp-frontend/src/app/ui/dmp/editor/grant-tab/grant-tab.component.html +++ b/dmp-frontend/src/app/ui/dmp/editor/grant-tab/grant-tab.component.html @@ -24,7 +24,7 @@
-
+
settings_backup_restore {{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.ACTIONS.EXIST-FUNDER' | translate}} @@ -63,7 +63,7 @@
-
+
settings_backup_restore {{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.ACTIONS.EXIST-GRANT' | translate}} @@ -104,7 +104,7 @@
-
+
settings_backup_restore {{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.ACTIONS.EXIST-PROJECT' | translate}} diff --git a/dmp-frontend/src/app/ui/dmp/editor/grant-tab/grant-tab.component.ts b/dmp-frontend/src/app/ui/dmp/editor/grant-tab/grant-tab.component.ts index 9920011fd..cf9d454ff 100644 --- a/dmp-frontend/src/app/ui/dmp/editor/grant-tab/grant-tab.component.ts +++ b/dmp-frontend/src/app/ui/dmp/editor/grant-tab/grant-tab.component.ts @@ -26,6 +26,7 @@ export class GrantTabComponent extends BaseComponent implements OnInit { @Input() isFinalized: boolean; @Input() isNewVersion: boolean; @Input() isNew: boolean; + @Input() isUserOwner: boolean; isCreateNew = false; isCreateNewProject = false; @@ -143,7 +144,7 @@ export class GrantTabComponent extends BaseComponent implements OnInit { this.grantformGroup.get('existGrant').disable(); this.grantformGroup.get('label').enable(); this.grantformGroup.get('description').enable(); - } else if (this.isFinalized || this.isNewVersion) { + } else if (this.isFinalized || this.isNewVersion || !this.isUserOwner) { this.grantformGroup.get('existGrant').disable(); this.grantformGroup.get('label').disable(); this.grantformGroup.get('description').disable(); @@ -161,7 +162,7 @@ export class GrantTabComponent extends BaseComponent implements OnInit { this.projectFormGroup.get('existProject').disable(); this.projectFormGroup.get('label').enable(); this.projectFormGroup.get('description').enable(); - } else if (this.isFinalized || this.isNewVersion) { + } else if (this.isFinalized || this.isNewVersion || !this.isUserOwner) { this.projectFormGroup.get('existProject').disable(); this.projectFormGroup.get('label').disable(); this.projectFormGroup.get('description').disable(); @@ -178,7 +179,7 @@ export class GrantTabComponent extends BaseComponent implements OnInit { if (this.isCreateNewFunder) { this.funderFormGroup.get('existFunder').disable(); this.funderFormGroup.get('label').enable(); - } else if (this.isFinalized || this.isNewVersion) { + } else if (this.isFinalized || this.isNewVersion || !this.isUserOwner) { this.funderFormGroup.get('existFunder').disable(); this.funderFormGroup.get('label').disable(); } else {