mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-08 18:44:14 +00:00
[TLC-249] Attempting art's sub fix (doesn't work)
This commit is contained in:
@@ -3,7 +3,7 @@ import { fadeIn, fadeInOut } from '../../../shared/animations/fade';
|
|||||||
import { Item } from '../../../core/shared/item.model';
|
import { Item } from '../../../core/shared/item.model';
|
||||||
import { ActivatedRoute } from '@angular/router';
|
import { ActivatedRoute } from '@angular/router';
|
||||||
import { ItemOperation } from '../item-operation/itemOperation.model';
|
import { ItemOperation } from '../item-operation/itemOperation.model';
|
||||||
import {distinctUntilChanged, first, map, mergeMap, toArray} from 'rxjs/operators';
|
import { distinctUntilChanged, first, map, mergeMap, switchMap, take, toArray } from 'rxjs/operators';
|
||||||
import { BehaviorSubject, Observable, from as observableFrom, Subscription, combineLatest } from 'rxjs';
|
import { BehaviorSubject, Observable, from as observableFrom, Subscription, combineLatest } from 'rxjs';
|
||||||
import { RemoteData } from '../../../core/data/remote-data';
|
import { RemoteData } from '../../../core/data/remote-data';
|
||||||
import { getItemEditRoute, getItemPageRoute } from '../../item-page-routing-paths';
|
import { getItemEditRoute, getItemPageRoute } from '../../item-page-routing-paths';
|
||||||
@@ -174,27 +174,36 @@ export class ItemStatusComponent implements OnInit {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Subscribe to changes from the showRegister check and rebuild operations list accordingly
|
// Subscribe to changes from the showRegister check and rebuild operations list accordingly
|
||||||
this.subs.push(showRegister$.subscribe((show) => {
|
this.subs.push(showRegister$.pipe(
|
||||||
|
switchMap((show: boolean) => {
|
||||||
|
console.dir('show? ' + show);
|
||||||
// Copy the static array first so we don't keep appending to it
|
// Copy the static array first so we don't keep appending to it
|
||||||
let tmp_operations = [...operations];
|
let tmp_operations = [...operations];
|
||||||
if (show) {
|
if (show) {
|
||||||
// Push the new Register DOI item operation
|
// Push the new Register DOI item operation
|
||||||
tmp_operations.push(new ItemOperation('register-doi', this.getCurrentUrl(item) + '/register-doi', FeatureID.CanRegisterDOI));
|
tmp_operations.push(new ItemOperation('register-doi', this.getCurrentUrl(item) + '/register-doi', FeatureID.CanRegisterDOI));
|
||||||
}
|
}
|
||||||
|
// emit the operations one at a time
|
||||||
|
return tmp_operations
|
||||||
|
}),
|
||||||
// Check authorisations and merge into new operations list
|
// Check authorisations and merge into new operations list
|
||||||
observableFrom(tmp_operations).pipe(
|
mergeMap((operation: ItemOperation) => {
|
||||||
mergeMap((operation) => {
|
console.dir("operation! " + (operation.featureID));
|
||||||
if (hasValue(operation.featureID)) {
|
if (hasValue(operation.featureID)) {
|
||||||
return this.authorizationService.isAuthorized(operation.featureID, item.self).pipe(
|
return this.authorizationService.isAuthorized(operation.featureID, item.self).pipe(
|
||||||
distinctUntilChanged(),
|
//distinctUntilChanged(),
|
||||||
map((authorized) => new ItemOperation(operation.operationKey, operation.operationUrl, operation.featureID, !authorized, authorized))
|
map((authorized) => new ItemOperation(operation.operationKey, operation.operationUrl, operation.featureID, !authorized, authorized))
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return [operation];
|
return [operation];
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
toArray()
|
//take(operations.length + 1),
|
||||||
).subscribe((ops) => this.operations$.next(ops));
|
// wait until all observables have completed and emit them all as a single array
|
||||||
|
toArray(),
|
||||||
|
).subscribe((ops: ItemOperation[]) => {
|
||||||
|
console.dir('next!');
|
||||||
|
this.operations$.next(ops);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user