diff --git a/src/app/admin/admin-registries/metadata-schema/metadata-field-form/metadata-field-form.component.html b/src/app/admin/admin-registries/metadata-schema/metadata-field-form/metadata-field-form.component.html index c799d87b26..93a19405b4 100644 --- a/src/app/admin/admin-registries/metadata-schema/metadata-field-form/metadata-field-form.component.html +++ b/src/app/admin/admin-registries/metadata-schema/metadata-field-form/metadata-field-form.component.html @@ -1,4 +1,4 @@ -@if (registryService.getActiveMetadataField() | async) { +@if (activeMetadataField$ | async) {

{{messagePrefix + '.edit' | translate}}

} @else {

{{messagePrefix + '.create' | translate}}

diff --git a/src/app/admin/admin-registries/metadata-schema/metadata-field-form/metadata-field-form.component.ts b/src/app/admin/admin-registries/metadata-schema/metadata-field-form/metadata-field-form.component.ts index 63f93961be..541f95626b 100644 --- a/src/app/admin/admin-registries/metadata-schema/metadata-field-form/metadata-field-form.component.ts +++ b/src/app/admin/admin-registries/metadata-schema/metadata-field-form/metadata-field-form.component.ts @@ -19,7 +19,7 @@ import { TranslateModule, TranslateService, } from '@ngx-translate/core'; -import { combineLatest } from 'rxjs'; +import { Observable } from 'rxjs'; import { take } from 'rxjs/operators'; import { MetadataField } from '../../../../core/metadata/metadata-field.model'; @@ -109,6 +109,8 @@ export class MetadataFieldFormComponent implements OnInit, OnDestroy { */ @Output() submitForm: EventEmitter = new EventEmitter(); + activeMetadataField$: Observable; + constructor(public registryService: RegistryService, private formBuilderService: FormBuilderService, private translateService: TranslateService) { @@ -117,71 +119,65 @@ export class MetadataFieldFormComponent implements OnInit, OnDestroy { /** * Initialize the component, setting up the necessary Models for the dynamic form */ - ngOnInit() { - combineLatest([ - this.translateService.get(`${this.messagePrefix}.element`), - this.translateService.get(`${this.messagePrefix}.qualifier`), - this.translateService.get(`${this.messagePrefix}.scopenote`), - ]).subscribe(([element, qualifier, scopenote]) => { - this.element = new DynamicInputModel({ - id: 'element', - label: element, - name: 'element', - validators: { - required: null, - pattern: '^[^. ,]*$', - maxLength: 64, - }, - required: true, - errorMessages: { - pattern: 'error.validation.metadata.element.invalid-pattern', - maxLength: 'error.validation.metadata.element.max-length', - }, - }); - this.qualifier = new DynamicInputModel({ - id: 'qualifier', - label: qualifier, - name: 'qualifier', - validators: { - pattern: '^[^. ,]*$', - maxLength: 64, - }, - required: false, - errorMessages: { - pattern: 'error.validation.metadata.qualifier.invalid-pattern', - maxLength: 'error.validation.metadata.qualifier.max-length', - }, - }); - this.scopeNote = new DynamicTextAreaModel({ - id: 'scopeNote', - label: scopenote, - name: 'scopeNote', - required: false, - rows: 5, - }); - this.formModel = [ - new DynamicFormGroupModel( - { - id: 'metadatadatafieldgroup', - group:[this.element, this.qualifier, this.scopeNote], - }), - ]; - this.formGroup = this.formBuilderService.createFormGroup(this.formModel); - this.registryService.getActiveMetadataField().subscribe((field: MetadataField): void => { - if (field == null) { - this.clearFields(); - } else { - this.formGroup.patchValue({ - metadatadatafieldgroup: { - element: field.element, - qualifier: field.qualifier, - scopeNote: field.scopeNote, - }, - }); - this.element.disabled = true; - this.qualifier.disabled = true; - } - }); + ngOnInit(): void { + this.activeMetadataField$ = this.registryService.getActiveMetadataField(); + this.element = new DynamicInputModel({ + id: 'element', + label: this.translateService.instant(`${this.messagePrefix}.element`), + name: 'element', + validators: { + required: null, + pattern: '^[^. ,]*$', + maxLength: 64, + }, + required: true, + errorMessages: { + pattern: 'error.validation.metadata.element.invalid-pattern', + maxLength: 'error.validation.metadata.element.max-length', + }, + }); + this.qualifier = new DynamicInputModel({ + id: 'qualifier', + label: this.translateService.instant(`${this.messagePrefix}.qualifier`), + name: 'qualifier', + validators: { + pattern: '^[^. ,]*$', + maxLength: 64, + }, + required: false, + errorMessages: { + pattern: 'error.validation.metadata.qualifier.invalid-pattern', + maxLength: 'error.validation.metadata.qualifier.max-length', + }, + }); + this.scopeNote = new DynamicTextAreaModel({ + id: 'scopeNote', + label: this.translateService.instant(`${this.messagePrefix}.scopenote`), + name: 'scopeNote', + required: false, + rows: 5, + }); + this.formModel = [ + new DynamicFormGroupModel({ + id: 'metadatadatafieldgroup', + group:[this.element, this.qualifier, this.scopeNote], + }), + ]; + this.formGroup = this.formBuilderService.createFormGroup(this.formModel); + this.registryService.getActiveMetadataField().subscribe((field: MetadataField): void => { + if (field == null) { + this.clearFields(); + } else { + this.formGroup.patchValue({ + metadatadatafieldgroup: { + element: field.element, + qualifier: field.qualifier, + scopeNote: field.scopeNote, + }, + }); + this.element.disabled = true; + this.qualifier.disabled = true; + } }); } diff --git a/src/app/item-page/edit-item-page/item-authorizations/item-authorizations.component.html b/src/app/item-page/edit-item-page/item-authorizations/item-authorizations.component.html index 4aca189e16..5733bbf927 100644 --- a/src/app/item-page/edit-item-page/item-authorizations/item-authorizations.component.html +++ b/src/app/item-page/edit-item-page/item-authorizations/item-authorizations.component.html @@ -1,7 +1,7 @@
- - + + @for (bundle of (bundles$ | async); track bundle) { diff --git a/src/app/item-page/edit-item-page/item-authorizations/item-authorizations.component.spec.ts b/src/app/item-page/edit-item-page/item-authorizations/item-authorizations.component.spec.ts index 3181b0e766..15bd82b82a 100644 --- a/src/app/item-page/edit-item-page/item-authorizations/item-authorizations.component.spec.ts +++ b/src/app/item-page/edit-item-page/item-authorizations/item-authorizations.component.spec.ts @@ -169,17 +169,9 @@ describe('ItemAuthorizationsComponent test suite', () => { })); }); - it('should get the item UUID', () => { - - expect(comp.getItemUUID()).toBeObservable(cold('(a|)', { - a: item.id, - })); - - }); - it('should get the item\'s bundle', () => { - expect(comp.getItemBundles()).toBeObservable(cold('a', { + expect(comp.bundles$).toBeObservable(cold('a', { a: bundles, })); diff --git a/src/app/item-page/edit-item-page/item-authorizations/item-authorizations.component.ts b/src/app/item-page/edit-item-page/item-authorizations/item-authorizations.component.ts index 6e700fd48e..881de3d6c9 100644 --- a/src/app/item-page/edit-item-page/item-authorizations/item-authorizations.component.ts +++ b/src/app/item-page/edit-item-page/item-authorizations/item-authorizations.component.ts @@ -17,7 +17,6 @@ import { import { catchError, filter, - first, map, mergeMap, take, @@ -37,11 +36,11 @@ import { getFirstSucceededRemoteDataWithNotEmptyPayload, } from '../../../core/shared/operators'; import { AlertComponent } from '../../../shared/alert/alert.component'; +import { AlertType } from '../../../shared/alert/alert-type'; import { hasValue, isNotEmpty, } from '../../../shared/empty.util'; -import { NgForTrackByIdDirective } from '../../../shared/ng-for-track-by-id.directive'; import { ResourcePoliciesComponent } from '../../../shared/resource-policies/resource-policies.component'; import { followLink } from '../../../shared/utils/follow-link-config.model'; @@ -61,7 +60,6 @@ interface BundleBitstreamsMapEntry { ResourcePoliciesComponent, NgbCollapseModule, TranslateModule, - NgForTrackByIdDirective, AsyncPipe, AlertComponent, ], @@ -88,7 +86,7 @@ export class ItemAuthorizationsComponent implements OnInit, OnDestroy { * The target editing item * @type {Observable} */ - private item$: Observable; + item$: Observable; /** * Array to track all subscriptions and unsubscribe them onDestroy @@ -127,16 +125,13 @@ export class ItemAuthorizationsComponent implements OnInit, OnDestroy { */ private bitstreamPageSize = 4; - /** - * Initialize instance variables - * - * @param {LinkService} linkService - * @param {ActivatedRoute} route - * @param nameService - */ + itemName$: Observable; + + readonly AlertType = AlertType; + constructor( - private linkService: LinkService, - private route: ActivatedRoute, + protected linkService: LinkService, + protected route: ActivatedRoute, public nameService: DSONameService, ) { } @@ -146,36 +141,18 @@ export class ItemAuthorizationsComponent implements OnInit, OnDestroy { */ ngOnInit(): void { this.getBundlesPerItem(); + this.itemName$ = this.getItemName(); } /** - * Return the item's UUID + * Return the item's name */ - getItemUUID(): Observable { - return this.item$.pipe( - map((item: Item) => item.id), - first((UUID: string) => isNotEmpty(UUID)), - ); - } - - /** - * Return the item's name - */ - getItemName(): Observable { + private getItemName(): Observable { return this.item$.pipe( map((item: Item) => this.nameService.getName(item)), ); } - /** - * Return all item's bundles - * - * @return an observable that emits all item's bundles - */ - getItemBundles(): Observable { - return this.bundles$.asObservable(); - } - /** * Get all bundles per item * and all the bitstreams per bundle diff --git a/src/app/item-page/orcid-page/orcid-auth/orcid-auth.component.html b/src/app/item-page/orcid-page/orcid-auth/orcid-auth.component.html index d2f7bc04b6..6695226d5c 100644 --- a/src/app/item-page/orcid-page/orcid-auth/orcid-auth.component.html +++ b/src/app/item-page/orcid-page/orcid-auth/orcid-auth.component.html @@ -1,16 +1,16 @@

{{'person.orcid.registry.auth' | translate}}

- @if ((isLinkedToOrcid() | async)) { + @if ((isOrcidLinked$ | async)) {
- @if ((hasOrcidAuthorizations() | async)) { + @if ((hasOrcidAuthorizations$ | async)) {
{{ 'person.page.orcid.granted-authorizations'| translate }}
    - @for (auth of (getOrcidAuthorizations() | async); track auth) { + @for (auth of (profileAuthorizationScopes$ | async); track auth) {
  • {{getAuthorizationDescription(auth) | translate}}
  • @@ -26,16 +26,16 @@
    {{ 'person.page.orcid.missing-authorizations'| translate }}
    - @if ((hasMissingOrcidAuthorizations() | async) !== true) { - + @if ((hasMissingOrcidAuthorizations$ | async) !== true) { + {{'person.page.orcid.no-missing-authorizations-message' | translate}} } - @if ((hasMissingOrcidAuthorizations() | async)) { - + @if ((hasMissingOrcidAuthorizations$ | async)) { + {{'person.page.orcid.missing-authorizations-message' | translate}}
      - @for (auth of (getMissingOrcidAuthorizations() | async); track auth) { + @for (auth of (profileAuthorizationScopes$ | async); track auth) {
    • {{getAuthorizationDescription(auth) | translate }}
    • @@ -48,13 +48,13 @@
- @if ((onlyAdminCanDisconnectProfileFromOrcid() | async) && (ownerCanDisconnectProfileFromOrcid() | async) !== true) { + @if ((onlyAdminCanDisconnectProfileFromOrcid$ | async) && (ownerCanDisconnectProfileFromOrcid$ | async) !== true) { + [type]="AlertType.Warning" data-test="unlinkOnlyAdmin"> {{ 'person.page.orcid.remove-orcid-message' | translate}} } - @if ((ownerCanDisconnectProfileFromOrcid() | async)) { + @if ((ownerCanDisconnectProfileFromOrcid$ | async)) {
- @if ((hasMissingOrcidAuthorizations() | async)) { + @if ((hasMissingOrcidAuthorizations$ | async)) {
- - -
-
- @if ((hasOrcidAuthorizations() | async)) { -
-
-
{{ 'person.page.orcid.granted-authorizations'| translate }}
-
-
-
    - @for (auth of (getOrcidAuthorizations() | async); track auth) { -
  • - {{getAuthorizationDescription(auth) | translate}} -
  • - } -
-
-
-
-
- } -
-
-
{{ 'person.page.orcid.missing-authorizations'| translate }}
-
-
- @if ((hasMissingOrcidAuthorizations() | async) !== true) { - - {{'person.page.orcid.no-missing-authorizations-message' | translate}} - - } - @if ((hasMissingOrcidAuthorizations() | async)) { - - {{'person.page.orcid.missing-authorizations-message' | translate}} -
    - @for (auth of (getMissingOrcidAuthorizations() | async); track auth) { -
  • - {{getAuthorizationDescription(auth) | translate }} -
  • - } -
-
- } -
-
-
-
-
- @if ((onlyAdminCanDisconnectProfileFromOrcid() | async) && (ownerCanDisconnectProfileFromOrcid() | async) !== true) { - - {{ 'person.page.orcid.remove-orcid-message' | translate}} - - } - @if ((ownerCanDisconnectProfileFromOrcid() | async)) { -
-
- - @if ((hasMissingOrcidAuthorizations() | async)) { - - } -
-
- } -
-
- - -
-
-
orcid-logo
-
- {{ getOrcidNotLinkedMessage() | async }} -
-
-
-
- -
-
-
-
- diff --git a/src/app/item-page/orcid-page/orcid-auth/orcid-auth.component.ts b/src/app/item-page/orcid-page/orcid-auth/orcid-auth.component.ts index 2d39ee25a8..f4ed87f2c6 100644 --- a/src/app/item-page/orcid-page/orcid-auth/orcid-auth.component.ts +++ b/src/app/item-page/orcid-page/orcid-auth/orcid-auth.component.ts @@ -30,6 +30,7 @@ import { import { Item } from '../../../core/shared/item.model'; import { getFirstCompletedRemoteData } from '../../../core/shared/operators'; import { AlertComponent } from '../../../shared/alert/alert.component'; +import { AlertType } from '../../../shared/alert/alert-type'; import { BtnDisabledDirective } from '../../../shared/btn-disabled.directive'; import { NotificationsService } from '../../../shared/notifications/notifications.service'; import { createFailedRemoteDataObjectFromError$ } from '../../../shared/remote-data.utils'; @@ -56,43 +57,49 @@ export class OrcidAuthComponent implements OnInit, OnChanges { /** * The list of exposed orcid authorization scopes for the orcid profile */ - profileAuthorizationScopes: BehaviorSubject = new BehaviorSubject([]); + profileAuthorizationScopes$: BehaviorSubject = new BehaviorSubject([]); + + hasOrcidAuthorizations$: Observable; /** * The list of all orcid authorization scopes missing in the orcid profile */ - missingAuthorizationScopes: BehaviorSubject = new BehaviorSubject([]); + missingAuthorizationScopes: BehaviorSubject = new BehaviorSubject([]); + + hasMissingOrcidAuthorizations$: Observable; /** * The list of all orcid authorization scopes available */ - orcidAuthorizationScopes: BehaviorSubject = new BehaviorSubject([]); + orcidAuthorizationScopes: BehaviorSubject = new BehaviorSubject([]); /** * A boolean representing if unlink operation is processing */ - unlinkProcessing: BehaviorSubject = new BehaviorSubject(false); + unlinkProcessing: BehaviorSubject = new BehaviorSubject(false); /** * A boolean representing if orcid profile is linked */ - private isOrcidLinked$: BehaviorSubject = new BehaviorSubject(false); + isOrcidLinked$: BehaviorSubject = new BehaviorSubject(false); /** * A boolean representing if only admin can disconnect orcid profile */ - private onlyAdminCanDisconnectProfileFromOrcid$: BehaviorSubject = new BehaviorSubject(false); + onlyAdminCanDisconnectProfileFromOrcid$: BehaviorSubject = new BehaviorSubject(false); /** * A boolean representing if owner can disconnect orcid profile */ - private ownerCanDisconnectProfileFromOrcid$: BehaviorSubject = new BehaviorSubject(false); + ownerCanDisconnectProfileFromOrcid$: BehaviorSubject = new BehaviorSubject(false); /** * An event emitted when orcid profile is unliked successfully */ @Output() unlink: EventEmitter = new EventEmitter(); + readonly AlertType = AlertType; + constructor( private orcidAuthService: OrcidAuthService, private translateService: TranslateService, @@ -106,6 +113,8 @@ export class OrcidAuthComponent implements OnInit, OnChanges { this.orcidAuthorizationScopes.next(scopes); this.initOrcidAuthSettings(); }); + this.hasOrcidAuthorizations$ = this.hasOrcidAuthorizations(); + this.hasMissingOrcidAuthorizations$ = this.hasMissingOrcidAuthorizations(); } ngOnChanges(changes: SimpleChanges): void { @@ -118,18 +127,11 @@ export class OrcidAuthComponent implements OnInit, OnChanges { * Check if the list of exposed orcid authorization scopes for the orcid profile has values */ hasOrcidAuthorizations(): Observable { - return this.profileAuthorizationScopes.asObservable().pipe( + return this.profileAuthorizationScopes$.pipe( map((scopes: string[]) => scopes.length > 0), ); } - /** - * Return the list of exposed orcid authorization scopes for the orcid profile - */ - getOrcidAuthorizations(): Observable { - return this.profileAuthorizationScopes.asObservable(); - } - /** * Check if the list of exposed orcid authorization scopes for the orcid profile has values */ @@ -139,26 +141,12 @@ export class OrcidAuthComponent implements OnInit, OnChanges { ); } - /** - * Return the list of exposed orcid authorization scopes for the orcid profile - */ - getMissingOrcidAuthorizations(): Observable { - return this.profileAuthorizationScopes.asObservable(); - } - - /** - * Return a boolean representing if orcid profile is linked - */ - isLinkedToOrcid(): Observable { - return this.isOrcidLinked$.asObservable(); - } - - getOrcidNotLinkedMessage(): Observable { + getOrcidNotLinkedMessage(): string { const orcid = this.item.firstMetadataValue('person.identifier.orcid'); if (orcid) { - return this.translateService.get('person.page.orcid.orcid-not-linked-message', { 'orcid': orcid }); + return this.translateService.instant('person.page.orcid.orcid-not-linked-message', { 'orcid': orcid }); } else { - return this.translateService.get('person.page.orcid.no-orcid-message'); + return this.translateService.instant('person.page.orcid.no-orcid-message'); } } @@ -171,13 +159,6 @@ export class OrcidAuthComponent implements OnInit, OnChanges { return 'person.page.orcid.scope.' + scope.substring(1).replace('/', '-'); } - /** - * Return a boolean representing if only admin can disconnect orcid profile - */ - onlyAdminCanDisconnectProfileFromOrcid(): Observable { - return this.onlyAdminCanDisconnectProfileFromOrcid$.asObservable(); - } - /** * Return a boolean representing if owner can disconnect orcid profile */ @@ -243,7 +224,7 @@ export class OrcidAuthComponent implements OnInit, OnChanges { } private setOrcidAuthorizationsFromItem(): void { - this.profileAuthorizationScopes.next(this.orcidAuthService.getOrcidAuthorizationScopesByItem(this.item)); + this.profileAuthorizationScopes$.next(this.orcidAuthService.getOrcidAuthorizationScopesByItem(this.item)); } } diff --git a/src/app/item-page/orcid-page/orcid-queue/orcid-queue.component.html b/src/app/item-page/orcid-page/orcid-queue/orcid-queue.component.html index 014f995ae0..b86ddb4461 100644 --- a/src/app/item-page/orcid-page/orcid-queue/orcid-queue.component.html +++ b/src/app/item-page/orcid-page/orcid-queue/orcid-queue.component.html @@ -5,16 +5,16 @@

{{ 'person.orcid.registry.queue' | translate }}

- @if ((processing$ | async) !== true && (getList() | async)?.payload?.totalElements === 0) { + @if ((processing$ | async) !== true && (list$ | async)?.payload?.totalElements === 0) { {{ 'person.page.orcid.sync-queue.empty-message' | translate}} } - @if ((processing$ | async) !== true && (getList() | async)?.payload?.totalElements > 0) { + @if ((processing$ | async) !== true && (list$ | async)?.payload?.totalElements > 0) {
@@ -26,7 +26,7 @@ - @for (entry of (getList() | async)?.payload?.page; track entry) { + @for (entry of (list$ | async)?.payload?.page; track entry) { - @for (entry of (getList() | async)?.payload?.page; track entry) { - - - + @for (entry of list.page; track entry) { + + +
>> = new BehaviorSubject>>({} as any); + list$: BehaviorSubject>> = new BehaviorSubject>>({} as any); /** * The AlertType enumeration - * @type {AlertType} */ - AlertTypeEnum = AlertType; + readonly AlertTypeEnum = AlertType; /** * Array to track all subscriptions and unsubscribe them onDestroy @@ -132,13 +131,6 @@ export class OrcidQueueComponent implements OnInit, OnDestroy, OnChanges { ); } - /** - * Return the list of orcid queue records - */ - getList(): Observable>> { - return this.list$.asObservable(); - } - /** * Return the icon class for the queue object type * diff --git a/src/app/navbar/navbar.component.html b/src/app/navbar/navbar.component.html index 479f206f90..f7d48dc050 100644 --- a/src/app/navbar/navbar.component.html +++ b/src/app/navbar/navbar.component.html @@ -1,5 +1,5 @@
{{entry.id}}{{dsoNameService.getName(entry)}}
{{ entry.id }}{{ dsoNameService.getName(entry) }} @@ -15,7 +15,7 @@
+ [ngClass]="{'w-100': (isXs$ | async)}"> @if ((hasSections$ | async) !== true) {