Skip to content

Commit

Permalink
fix: added annotation infobar
Browse files Browse the repository at this point in the history
  • Loading branch information
irmastnt committed Apr 26, 2024
1 parent 9186424 commit 73441c4
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 4 deletions.
Expand Up @@ -18,7 +18,14 @@ <h3 class="label mat-headline-6" *ngIf="isAnnotation">
(regionDeleted)="regionDeleted.emit()">
</app-resource-toolbar>
</div>

<div class="infobar mat-caption" *ngIf="isAnnotation && (resourceAttachedUser || resource.res.creationDate)">
Created
<span *ngIf="resourceAttachedUser">
by {{(resourceAttachedUser.username ? resourceAttachedUser.username : resourceAttachedUser.givenName + ' ' +
resourceAttachedUser.familyName)}}
</span>
<span *ngIf="resource.res.creationDate"> on {{resource.res.creationDate | date}}</span>
</div>
<!-- list of properties -->
<div class="properties-container">
<div class="properties" *ngIf="resource.resProps.length > 0; else noProperties">
Expand Down
Expand Up @@ -31,6 +31,12 @@
}
}

.infobar {
text-align: right;
padding-right: 6px;
line-height: 36px;
}

.clipboard-arkurl {
width: 264px;
height: 32px;
Expand Down
Expand Up @@ -32,9 +32,10 @@ import {
} from '@dasch-swiss/dsp-js';
import { DspApiConnectionToken } from '@dasch-swiss/vre/shared/app-config';
import { SortingService } from '@dasch-swiss/vre/shared/app-helper-services';
import { ResourceSelectors } from '@dasch-swiss/vre/shared/app-state';
import { Select } from '@ngxs/store';
import { GetAttachedUserAction, ResourceSelectors } from '@dasch-swiss/vre/shared/app-state';
import { Actions, Select, Store, ofActionSuccessful } from '@ngxs/store';
import { Observable, Subject, Subscription, forkJoin } from 'rxjs';
import { take } from 'rxjs/operators';
import { DspResource } from '../dsp-resource';
import { RepresentationConstants } from '../representation/file-representation';
import { IncomingService } from '../services/incoming.service';
Expand Down Expand Up @@ -135,6 +136,7 @@ export class PropertiesComponent implements OnInit, OnChanges, OnDestroy {
hasIncomingLinkIri = Constants.HasIncomingLinkValue;
pageEvent: PageEvent;
loading = false;
resourceAttachedUser: ReadUser;

@Select(ResourceSelectors.showAllProps) showAllProps$: Observable<boolean>;

Expand All @@ -146,7 +148,9 @@ export class PropertiesComponent implements OnInit, OnChanges, OnDestroy {
private _valueOperationEventService: ValueOperationEventService,
private _valueService: ValueService,
private _sortingService: SortingService,
private _cd: ChangeDetectorRef
private _cd: ChangeDetectorRef,
private _store: Store,
private _actions$: Actions
) {}

ngOnInit(): void {
Expand Down Expand Up @@ -203,6 +207,8 @@ export class PropertiesComponent implements OnInit, OnChanges, OnDestroy {
this.deleteValueFromResource(deletedValue.deletedValue);
})
);

this._getResourceAttachedData(this.resource);
}

ngOnChanges(): void {
Expand Down Expand Up @@ -528,4 +534,17 @@ export class PropertiesComponent implements OnInit, OnChanges, OnDestroy {
this._cd.markForCheck();
});
}

private _getResourceAttachedData(resource: DspResource): void {
this._actions$
.pipe(ofActionSuccessful(GetAttachedUserAction))
.pipe(take(1))
.subscribe(() => {
const attachedUsers = this._store.selectSnapshot(ResourceSelectors.attachedUsers);
this.resourceAttachedUser = attachedUsers[resource.res.id].value.find(
u => u.id === resource.res.attachedToUser
);
});
this._store.dispatch(new GetAttachedUserAction(resource.res.id, resource.res.attachedToUser));
}
}

0 comments on commit 73441c4

Please sign in to comment.