@@ -3,7 +3,7 @@ import { PaginationComponentOptions } from '../../../shared/pagination/paginatio
33import { ResponsiveTableSizes } from '../../../shared/responsive-table-sizes/responsive-table-sizes' ;
44import { ResponsiveColumnSizes } from '../../../shared/responsive-table-sizes/responsive-column-sizes' ;
55import { RemoteData } from '../../../core/data/remote-data' ;
6- import { isNotEmpty , hasValue , hasNoValue } from '../../../shared/empty.util' ;
6+ import { hasValue , hasNoValue } from '../../../shared/empty.util' ;
77import { Bundle } from '../../../core/shared/bundle.model' ;
88import { NotificationsService } from '../../../shared/notifications/notifications.service' ;
99import { TranslateService } from '@ngx-translate/core' ;
@@ -25,6 +25,8 @@ import { BundleDataService } from '../../../core/data/bundle-data.service';
2525import { RequestService } from '../../../core/data/request.service' ;
2626import { LiveRegionService } from '../../../shared/live-region/live-region.service' ;
2727
28+ export const MOVE_KEY = 'item.edit.bitstreams.notifications.move' ;
29+
2830/**
2931 * Interface storing all the information necessary to create a row in the bitstream edit table
3032 */
@@ -164,6 +166,10 @@ export class ItemBitstreamsService {
164166 if ( hasValue ( selected ) ) {
165167 this . updateSelectedBitstream ( null ) ;
166168 this . announceClear ( selected . bitstream . name ) ;
169+
170+ if ( selected . currentPosition !== selected . originalPosition ) {
171+ this . displaySuccessNotification ( MOVE_KEY ) ;
172+ }
167173 }
168174 }
169175
@@ -265,7 +271,7 @@ export class ItemBitstreamsService {
265271 this . isPerformingMoveRequest = true ;
266272 this . bundleService . patch ( bundle , [ moveOperation ] ) . pipe (
267273 getFirstCompletedRemoteData ( ) ,
268- tap ( ( response : RemoteData < Bundle > ) => this . displayNotifications ( 'item.edit.bitstreams.notifications.move' , [ response ] ) ) ,
274+ tap ( ( response : RemoteData < Bundle > ) => this . displayFailedResponseNotifications ( MOVE_KEY , [ response ] ) ) ,
269275 switchMap ( ( ) => this . requestService . setStaleByHrefSubstring ( bundle . self ) ) ,
270276 take ( 1 ) ,
271277 ) . subscribe ( ( ) => {
@@ -321,19 +327,51 @@ export class ItemBitstreamsService {
321327 * @param responses The returned responses to display notifications for
322328 */
323329 displayNotifications ( key : string , responses : RemoteData < any > [ ] ) {
324- if ( isNotEmpty ( responses ) ) {
325- const failedResponses = responses . filter ( ( response : RemoteData < Bundle > ) => hasValue ( response ) && response . hasFailed ) ;
326- const successfulResponses = responses . filter ( ( response : RemoteData < Bundle > ) => hasValue ( response ) && response . hasSucceeded ) ;
327-
328- failedResponses . forEach ( ( response : RemoteData < Bundle > ) => {
329- this . notificationsService . error ( this . translateService . instant ( `${ key } .failed.title` ) , response . errorMessage ) ;
330- } ) ;
331- if ( successfulResponses . length > 0 ) {
332- this . notificationsService . success ( this . translateService . instant ( `${ key } .saved.title` ) , this . translateService . instant ( `${ key } .saved.content` ) ) ;
333- }
330+ this . displayFailedResponseNotifications ( key , responses ) ;
331+ this . displaySuccessFulResponseNotifications ( key , responses ) ;
332+ }
333+
334+ /**
335+ * Display an error notification for each failed response with their message
336+ * @param key The i18n key for the notification messages
337+ * @param responses The returned responses to display notifications for
338+ */
339+ displayFailedResponseNotifications ( key : string , responses : RemoteData < any > [ ] ) {
340+ const failedResponses = responses . filter ( ( response : RemoteData < Bundle > ) => hasValue ( response ) && response . hasFailed ) ;
341+ failedResponses . forEach ( ( response : RemoteData < Bundle > ) => {
342+ this . displayErrorNotification ( key , response . errorMessage ) ;
343+ } ) ;
344+ }
345+
346+ /**
347+ * Display an error notification with the provided key and message
348+ * @param key The i18n key for the notification messages
349+ * @param errorMessage The error message to display
350+ */
351+ displayErrorNotification ( key : string , errorMessage : string ) {
352+ this . notificationsService . error ( this . translateService . instant ( `${ key } .failed.title` ) , errorMessage ) ;
353+ }
354+
355+ /**
356+ * Display a success notification in case there's at least one successful response
357+ * @param key The i18n key for the notification messages
358+ * @param responses The returned responses to display notifications for
359+ */
360+ displaySuccessFulResponseNotifications ( key : string , responses : RemoteData < any > [ ] ) {
361+ const successfulResponses = responses . filter ( ( response : RemoteData < Bundle > ) => hasValue ( response ) && response . hasSucceeded ) ;
362+ if ( successfulResponses . length > 0 ) {
363+ this . displaySuccessNotification ( key ) ;
334364 }
335365 }
336366
367+ /**
368+ * Display a success notification with the provided key
369+ * @param key The i18n key for the notification messages
370+ */
371+ displaySuccessNotification ( key : string ) {
372+ this . notificationsService . success ( this . translateService . instant ( `${ key } .saved.title` ) , this . translateService . instant ( `${ key } .saved.content` ) ) ;
373+ }
374+
337375 /**
338376 * Removes the bitstreams marked for deletion from the Bundles emitted by the provided observable.
339377 * @param bundles$
0 commit comments