From 02b5a489b539c555d557d8f78d03a88b30470fc6 Mon Sep 17 00:00:00 2001 From: mdelez <60604010+mdelez@users.noreply.github.com> Date: Thu, 18 Aug 2022 14:42:00 +0200 Subject: [PATCH] feat(ontology): ontology editor read mode (DEV-1183) (#799) * feat(ontology): ontology editor can now be viewed by project members in read mode * feat(ontology): allow project members to access ontology editor via the old dashboard --- .../beta/settings/settings.component.ts | 3 - .../project/ontology/ontology.component.html | 20 +++--- .../project/ontology/ontology.component.ts | 15 +++-- .../property-info/property-info.component.ts | 8 ++- .../resource-class-info.component.html | 67 ++++++++++--------- .../resource-class-info.component.spec.ts | 6 +- .../resource-class-info.component.ts | 2 + src/app/project/project.component.html | 16 +++-- 8 files changed, 82 insertions(+), 55 deletions(-) diff --git a/src/app/project/beta/settings/settings.component.ts b/src/app/project/beta/settings/settings.component.ts index 9da9a128ca..9ba3a28eaf 100644 --- a/src/app/project/beta/settings/settings.component.ts +++ b/src/app/project/beta/settings/settings.component.ts @@ -16,11 +16,8 @@ export class SettingsComponent implements OnInit { constructor() { } ngOnInit(): void { - // we need only two items from the old project navigation // collaboration this.navigation.push(AppGlobal.projectNav[1]); - // permissions - this.navigation.push(AppGlobal.projectNav[2]); } } diff --git a/src/app/project/ontology/ontology.component.html b/src/app/project/ontology/ontology.component.html index 3667f7dae6..886322e909 100644 --- a/src/app/project/ontology/ontology.component.html +++ b/src/app/project/ontology/ontology.component.html @@ -1,4 +1,4 @@ -
+
@@ -41,7 +41,8 @@

- + -

-
+
- + \ No newline at end of file diff --git a/src/app/project/ontology/ontology.component.ts b/src/app/project/ontology/ontology.component.ts index 63aedf8f9f..0f0c10a4de 100644 --- a/src/app/project/ontology/ontology.component.ts +++ b/src/app/project/ontology/ontology.component.ts @@ -19,7 +19,8 @@ import { PropertyDefinition, ReadOntology, ReadProject, - UpdateOntology + UpdateOntology, + UserResponse } from '@dasch-swiss/dsp-js'; import { CacheService } from 'src/app/main/cache/cache.service'; import { DspApiConnectionToken } from 'src/app/main/declarations/dsp-api-tokens'; @@ -58,9 +59,10 @@ export class OntologyComponent implements OnInit { // permissions of logged-in user session: Session; - // system admin or project admin is by default false + // system admin, project admin, and project member are by default false sysAdmin = false; projectAdmin = false; + projectMember = false; // project shortcode; as identifier in project cache service projectCode: string; @@ -194,8 +196,13 @@ export class OntologyComponent implements OnInit { // is logged-in user projectAdmin? this.projectAdmin = this.sysAdmin ? this.sysAdmin : this.session.user.projectAdmin.some(e => e === this.project.id); - // get the ontologies for this project - this.initOntologiesList(); + this._dspApiConnection.admin.usersEndpoint.getUserByUsername(this.session.user.name).subscribe( + (userResponse: ApiResponseData) => { + this.projectMember = userResponse.body.user.projects.some(p => p.shortcode === this.project.shortcode); + + // get the ontologies for this project + this.initOntologiesList(); + }); this.ontologyForm = this._fb.group({ ontology: new FormControl({ diff --git a/src/app/project/ontology/property-info/property-info.component.ts b/src/app/project/ontology/property-info/property-info.component.ts index 7e4b59c2d1..ce137dd520 100644 --- a/src/app/project/ontology/property-info/property-info.component.ts +++ b/src/app/project/ontology/property-info/property-info.component.ts @@ -102,6 +102,8 @@ export class PropertyInfoComponent implements OnChanges, AfterContentInit { @Input() lastModificationDate?: string; + @Input() userCanEdit: boolean; // is user a project admin or sys admin? + // event emitter when the lastModificationDate changed; bidirectional binding with lastModificationDate parameter @Output() lastModificationDateChange: EventEmitter = new EventEmitter(); @@ -315,8 +317,10 @@ export class PropertyInfoComponent implements OnChanges, AfterContentInit { * show action bubble with various CRUD buttons when hovered over. */ mouseEnter() { - this.canBeDeleted(); - this.showActionBubble = true; + if (this.userCanEdit) { + this.canBeDeleted(); + this.showActionBubble = true; + } } /** diff --git a/src/app/project/ontology/resource-class-info/resource-class-info.component.html b/src/app/project/ontology/resource-class-info/resource-class-info.component.html index 640d1847af..dd7eb3da54 100644 --- a/src/app/project/ontology/resource-class-info/resource-class-info.component.html +++ b/src/app/project/ontology/resource-class-info/resource-class-info.component.html @@ -18,7 +18,8 @@ - @@ -29,22 +30,28 @@ - + + + - - + - - @@ -56,40 +63,40 @@ -
- {{i + 1}}) - + {{i + 1}}) + + drag_indicator - +
- + -

There is no property assigned to this class yet.

+

There are no properties assigned to this class yet.

- + add @@ -105,9 +112,8 @@ - @@ -115,10 +121,11 @@
- + - @@ -126,4 +133,4 @@ - + \ No newline at end of file diff --git a/src/app/project/ontology/resource-class-info/resource-class-info.component.spec.ts b/src/app/project/ontology/resource-class-info/resource-class-info.component.spec.ts index 044332fdd0..2d04ef9873 100644 --- a/src/app/project/ontology/resource-class-info/resource-class-info.component.spec.ts +++ b/src/app/project/ontology/resource-class-info/resource-class-info.component.spec.ts @@ -30,7 +30,7 @@ import { ResourceClassInfoComponent } from './resource-class-info.component'; * Property is of type simple text */ @Component({ - template: '' + template: '' }) class HostComponent implements OnInit { @@ -41,6 +41,8 @@ class HostComponent implements OnInit { resourceClass: ClassDefinition; + userCanEdit: boolean; + constructor( private _cache: CacheService, private _sortingService: SortingService @@ -72,6 +74,8 @@ class HostComponent implements OnInit { } ); + this.userCanEdit = true; + } } diff --git a/src/app/project/ontology/resource-class-info/resource-class-info.component.ts b/src/app/project/ontology/resource-class-info/resource-class-info.component.ts index 69c9bf6f85..aacd84e222 100644 --- a/src/app/project/ontology/resource-class-info/resource-class-info.component.ts +++ b/src/app/project/ontology/resource-class-info/resource-class-info.component.ts @@ -57,6 +57,8 @@ export class ResourceClassInfoComponent implements OnInit { @Input() lastModificationDate?: string; + @Input() userCanEdit: boolean; // is user a project admin or sys admin? + // event emitter when the lastModificationDate changed; bidirectional binding with lastModificationDate parameter @Output() lastModificationDateChange: EventEmitter = new EventEmitter(); diff --git a/src/app/project/project.component.html b/src/app/project/project.component.html index ad72e5ab2a..2569ba63e2 100644 --- a/src/app/project/project.component.html +++ b/src/app/project/project.component.html @@ -1,11 +1,11 @@
-