@@ -135,7 +135,7 @@ export class ItemBitstreamsService {
135135 */
136136 protected selectionAction$ : BehaviorSubject < SelectionAction > = new BehaviorSubject ( null ) ;
137137
138- protected isPerformingMoveRequest = false ;
138+ protected isPerformingMoveRequest : BehaviorSubject < boolean > = new BehaviorSubject ( false ) ;
139139
140140 constructor (
141141 protected notificationsService : NotificationsService ,
@@ -237,7 +237,7 @@ export class ItemBitstreamsService {
237237 cancelSelection ( ) {
238238 const selected = this . getSelectedBitstream ( ) ;
239239
240- if ( hasNoValue ( selected ) || this . isPerformingMoveRequest ) {
240+ if ( hasNoValue ( selected ) || this . getPerformingMoveRequest ( ) ) {
241241 return ;
242242 }
243243
@@ -263,7 +263,7 @@ export class ItemBitstreamsService {
263263 moveSelectedBitstreamUp ( ) {
264264 const selected = this . getSelectedBitstream ( ) ;
265265
266- if ( hasNoValue ( selected ) || this . isPerformingMoveRequest ) {
266+ if ( hasNoValue ( selected ) || this . getPerformingMoveRequest ( ) ) {
267267 return ;
268268 }
269269
@@ -288,7 +288,7 @@ export class ItemBitstreamsService {
288288 moveSelectedBitstreamDown ( ) {
289289 const selected = this . getSelectedBitstream ( ) ;
290290
291- if ( hasNoValue ( selected ) || this . isPerformingMoveRequest ) {
291+ if ( hasNoValue ( selected ) || this . getPerformingMoveRequest ( ) ) {
292292 return ;
293293 }
294294
@@ -315,7 +315,7 @@ export class ItemBitstreamsService {
315315 * @param finish Optional: Function to execute once the response has been received
316316 */
317317 performBitstreamMoveRequest ( bundle : Bundle , fromIndex : number , toIndex : number , finish ?: ( ) => void ) {
318- if ( this . isPerformingMoveRequest ) {
318+ if ( this . getPerformingMoveRequest ( ) ) {
319319 console . warn ( 'Attempted to perform move request while previous request has not completed yet' ) ;
320320 return ;
321321 }
@@ -326,18 +326,33 @@ export class ItemBitstreamsService {
326326 path : `/_links/bitstreams/${ toIndex } /href` ,
327327 } ;
328328
329- this . isPerformingMoveRequest = true ;
329+ this . announceLoading ( ) ;
330+ this . isPerformingMoveRequest . next ( true ) ;
330331 this . bundleService . patch ( bundle , [ moveOperation ] ) . pipe (
331332 getFirstCompletedRemoteData ( ) ,
332333 tap ( ( response : RemoteData < Bundle > ) => this . displayFailedResponseNotifications ( MOVE_KEY , [ response ] ) ) ,
333334 switchMap ( ( ) => this . requestService . setStaleByHrefSubstring ( bundle . self ) ) ,
334335 take ( 1 ) ,
335336 ) . subscribe ( ( ) => {
336- this . isPerformingMoveRequest = false ;
337+ this . isPerformingMoveRequest . next ( false ) ;
337338 finish ?.( ) ;
338339 } ) ;
339340 }
340341
342+ /**
343+ * Whether the service currently is processing a 'move' request
344+ */
345+ getPerformingMoveRequest ( ) : boolean {
346+ return this . isPerformingMoveRequest . value ;
347+ }
348+
349+ /**
350+ * Returns an observable which emits when the service starts, or ends, processing a 'move' request
351+ */
352+ getPerformingMoveRequest$ ( ) : Observable < boolean > {
353+ return this . isPerformingMoveRequest ;
354+ }
355+
341356 /**
342357 * Returns the pagination options to use when fetching the bundles
343358 */
@@ -542,4 +557,12 @@ export class ItemBitstreamsService {
542557 { bitstream : bitstreamName } ) ;
543558 this . liveRegionService . addMessage ( message ) ;
544559 }
560+
561+ /**
562+ * Adds a message to the live region mentioning that the
563+ */
564+ announceLoading ( ) {
565+ const message = this . translateService . instant ( 'item.edit.bitstreams.edit.live.loading' ) ;
566+ this . liveRegionService . addMessage ( message ) ;
567+ }
545568}
0 commit comments