mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
Merge pull request #2766 from amgciadev/fix-2765-b
Fix missing Register DOI button if configuration enabled
This commit is contained in:
@@ -107,7 +107,19 @@ export class ItemStatusComponent implements OnInit {
|
|||||||
// Observable for configuration determining whether the Register DOI feature is enabled
|
// Observable for configuration determining whether the Register DOI feature is enabled
|
||||||
let registerConfigEnabled$: Observable<boolean> = this.configurationService.findByPropertyName('identifiers.item-status.register-doi').pipe(
|
let registerConfigEnabled$: Observable<boolean> = this.configurationService.findByPropertyName('identifiers.item-status.register-doi').pipe(
|
||||||
getFirstCompletedRemoteData(),
|
getFirstCompletedRemoteData(),
|
||||||
map((enabledRD: RemoteData<ConfigurationProperty>) => enabledRD.hasSucceeded && enabledRD.payload.values.length > 0)
|
map((response: RemoteData<ConfigurationProperty>) => {
|
||||||
|
// 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;
|
||||||
|
}
|
||||||
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -117,7 +129,7 @@ export class ItemStatusComponent implements OnInit {
|
|||||||
* The value is supposed to be a href for the button
|
* The value is supposed to be a href for the button
|
||||||
*/
|
*/
|
||||||
const currentUrl = this.getCurrentUrl(item);
|
const currentUrl = this.getCurrentUrl(item);
|
||||||
const inititalOperations: ItemOperation[] = [
|
const initialOperations: ItemOperation[] = [
|
||||||
new ItemOperation('authorizations', `${currentUrl}/authorizations`, FeatureID.CanManagePolicies, true),
|
new ItemOperation('authorizations', `${currentUrl}/authorizations`, FeatureID.CanManagePolicies, true),
|
||||||
new ItemOperation('mappedCollections', `${currentUrl}/mapper`, FeatureID.CanManageMappings, true),
|
new ItemOperation('mappedCollections', `${currentUrl}/mapper`, FeatureID.CanManageMappings, true),
|
||||||
item.isWithdrawn
|
item.isWithdrawn
|
||||||
@@ -130,7 +142,7 @@ export class ItemStatusComponent implements OnInit {
|
|||||||
new ItemOperation('delete', `${currentUrl}/delete`, FeatureID.CanDelete, true)
|
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.
|
* When the identifier data stream changes, determine whether the register DOI button should be shown or not.
|
||||||
@@ -170,12 +182,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
|
// Switch map pushes the register DOI operation onto a copy of the base array then returns to the pipe
|
||||||
switchMap((showDoi: boolean) => {
|
switchMap((showDoi: boolean) => {
|
||||||
const ops = [...inititalOperations];
|
const ops = [...initialOperations];
|
||||||
if (showDoi) {
|
if (showDoi) {
|
||||||
const op = new ItemOperation('register-doi', `${currentUrl}/register-doi`, FeatureID.CanRegisterDOI, true);
|
const op = new ItemOperation('register-doi', `${currentUrl}/register-doi`, FeatureID.CanRegisterDOI, true);
|
||||||
ops.splice(ops.length - 1, 0, op); // Add item before last
|
ops.splice(ops.length - 1, 0, op); // Add item before last
|
||||||
}
|
}
|
||||||
return inititalOperations;
|
return ops;
|
||||||
}),
|
}),
|
||||||
concatMap((op: ItemOperation) => {
|
concatMap((op: ItemOperation) => {
|
||||||
if (hasValue(op.featureID)) {
|
if (hasValue(op.featureID)) {
|
||||||
|
Reference in New Issue
Block a user