From e77898eaacb3489f9bdd077a709c90ca66ca0dec Mon Sep 17 00:00:00 2001 From: Agustina Martinez Date: Tue, 23 Jan 2024 21:47:29 +0000 Subject: [PATCH 1/3] Update item-status.component.ts Fix initialOperations typo and return ops with register doi op --- .../edit-item-page/item-status/item-status.component.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/app/item-page/edit-item-page/item-status/item-status.component.ts b/src/app/item-page/edit-item-page/item-status/item-status.component.ts index 8e04985c184..d3a5e033d71 100644 --- a/src/app/item-page/edit-item-page/item-status/item-status.component.ts +++ b/src/app/item-page/edit-item-page/item-status/item-status.component.ts @@ -117,7 +117,7 @@ export class ItemStatusComponent implements OnInit { * The value is supposed to be a href for the button */ const currentUrl = this.getCurrentUrl(item); - const inititalOperations: ItemOperation[] = [ + const initialOperations: ItemOperation[] = [ new ItemOperation('authorizations', `${currentUrl}/authorizations`, FeatureID.CanManagePolicies, true), new ItemOperation('mappedCollections', `${currentUrl}/mapper`, FeatureID.CanManageMappings, true), item.isWithdrawn @@ -130,7 +130,7 @@ export class ItemStatusComponent implements OnInit { new ItemOperation('delete', `${currentUrl}/delete`, FeatureID.CanDelete, true) ]; - this.operations$.next(inititalOperations); + this.operations$.next(initialOperations); /** * When the identifier data stream changes, determine whether the register DOI button should be shown or not. @@ -170,12 +170,12 @@ export class ItemStatusComponent implements OnInit { }), // Switch map pushes the register DOI operation onto a copy of the base array then returns to the pipe switchMap((showDoi: boolean) => { - const ops = [...inititalOperations]; + const ops = [...initialOperations]; if (showDoi) { const op = new ItemOperation('register-doi', `${currentUrl}/register-doi`, FeatureID.CanRegisterDOI, true); ops.splice(ops.length - 1, 0, op); // Add item before last } - return inititalOperations; + return ops; }), concatMap((op: ItemOperation) => { if (hasValue(op.featureID)) { From 3e33785311444682eaf1f38ffc0bb8e0b3e3f353 Mon Sep 17 00:00:00 2001 From: Kim Shepherd Date: Wed, 7 Feb 2024 11:55:44 +1300 Subject: [PATCH 2/3] Improve cfg handling in item-status.component.ts --- .../item-status/item-status.component.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/app/item-page/edit-item-page/item-status/item-status.component.ts b/src/app/item-page/edit-item-page/item-status/item-status.component.ts index d3a5e033d71..759045b3dca 100644 --- a/src/app/item-page/edit-item-page/item-status/item-status.component.ts +++ b/src/app/item-page/edit-item-page/item-status/item-status.component.ts @@ -3,7 +3,7 @@ import { fadeIn, fadeInOut } from '../../../shared/animations/fade'; import { Item } from '../../../core/shared/item.model'; import { ActivatedRoute } from '@angular/router'; import { ItemOperation } from '../item-operation/itemOperation.model'; -import { concatMap, distinctUntilChanged, first, map, mergeMap, switchMap, toArray } from 'rxjs/operators'; +import {concatMap, distinctUntilChanged, first, map, mergeMap, switchMap, tap, toArray} from 'rxjs/operators'; import { BehaviorSubject, combineLatest, Observable, of, Subscription } from 'rxjs'; import { RemoteData } from '../../../core/data/remote-data'; import { getItemEditRoute, getItemPageRoute } from '../../item-page-routing-paths'; @@ -17,6 +17,7 @@ import { ConfigurationProperty } from '../../../core/shared/configuration-proper import { ConfigurationDataService } from '../../../core/data/configuration-data.service'; import { IdentifierData } from '../../../shared/object-list/identifier-data/identifier-data.model'; import { OrcidAuthService } from '../../../core/orcid/orcid-auth.service'; +import {getDSORoute} from "../../../app-routing-paths"; @Component({ selector: 'ds-item-status', @@ -107,7 +108,19 @@ export class ItemStatusComponent implements OnInit { // Observable for configuration determining whether the Register DOI feature is enabled let registerConfigEnabled$: Observable = this.configurationService.findByPropertyName('identifiers.item-status.register-doi').pipe( getFirstCompletedRemoteData(), - map((enabledRD: RemoteData) => enabledRD.hasSucceeded && enabledRD.payload.values.length > 0) + map((response: RemoteData) => { + // Return true if a successful response with a 'true' value was retrieved, otherwise return false + if (response.hasSucceeded) { + const payload = response.payload; + if (payload.values.length > 0 && hasValue(payload.values[0])) { + return payload.values[0] === 'true'; + } else { + return false; + } + } else { + return false; + } + }) ); /** From 68475d1ed61bd231de1a1efdb2feb3bf638108c2 Mon Sep 17 00:00:00 2001 From: Kim Shepherd Date: Wed, 7 Feb 2024 12:09:16 +1300 Subject: [PATCH 3/3] Improve cfg handling in item-status.component.ts --- .../edit-item-page/item-status/item-status.component.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/app/item-page/edit-item-page/item-status/item-status.component.ts b/src/app/item-page/edit-item-page/item-status/item-status.component.ts index 759045b3dca..8b4dc88d9d1 100644 --- a/src/app/item-page/edit-item-page/item-status/item-status.component.ts +++ b/src/app/item-page/edit-item-page/item-status/item-status.component.ts @@ -3,7 +3,7 @@ import { fadeIn, fadeInOut } from '../../../shared/animations/fade'; import { Item } from '../../../core/shared/item.model'; import { ActivatedRoute } from '@angular/router'; import { ItemOperation } from '../item-operation/itemOperation.model'; -import {concatMap, distinctUntilChanged, first, map, mergeMap, switchMap, tap, toArray} from 'rxjs/operators'; +import {concatMap, distinctUntilChanged, first, map, mergeMap, switchMap, toArray} from 'rxjs/operators'; import { BehaviorSubject, combineLatest, Observable, of, Subscription } from 'rxjs'; import { RemoteData } from '../../../core/data/remote-data'; import { getItemEditRoute, getItemPageRoute } from '../../item-page-routing-paths'; @@ -17,7 +17,6 @@ import { ConfigurationProperty } from '../../../core/shared/configuration-proper import { ConfigurationDataService } from '../../../core/data/configuration-data.service'; import { IdentifierData } from '../../../shared/object-list/identifier-data/identifier-data.model'; import { OrcidAuthService } from '../../../core/orcid/orcid-auth.service'; -import {getDSORoute} from "../../../app-routing-paths"; @Component({ selector: 'ds-item-status',