File tree Expand file tree Collapse file tree 2 files changed +7
-4
lines changed
src/components/playlist-drag-and-drop Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ All notable changes to this project will be documented in this file.
1111 - Change bootstrap column class from ` col-md-8 ` -> ` col-md-12 `
1212 - update api.generated.ts to match [ related pr] ( https://github.com/os2display/display-api-service/pull/213 )
1313 - Add @rtk-incubator/rtk-query-codegen-openapi to package.json in ` src/redux/api `
14+ - Sort playlists based on weight in drag/drop component
1415
1516- [ #258 ] ( https://github.com/os2display/display-admin-client/pull/258 )
1617 - Fixed screen is vertical check.
Original file line number Diff line number Diff line change @@ -77,12 +77,14 @@ function PlaylistDragAndDrop({
7777 if ( selectedPlaylistsByRegion ) {
7878 setTotalItems ( selectedPlaylistsByRegion [ "hydra:totalItems" ] ) ;
7979 const newPlaylists = selectedPlaylistsByRegion [ "hydra:member" ] . map (
80- ( { playlist } ) => {
81- return playlist ;
82- }
80+ ( { playlist, weight } ) => ( { ...playlist , weight } )
8381 ) ;
8482
85- setSelectedData ( [ ...selectedData , ...newPlaylists ] ) ;
83+ const selected = [ ...selectedData , ...newPlaylists ] . sort (
84+ ( a , b ) => a . weight - b . weight
85+ ) ;
86+
87+ setSelectedData ( selected ) ;
8688 callbackToinitializePlaylists ( selectedPlaylistsByRegion ) ;
8789 }
8890 } , [ selectedPlaylistsByRegion ] ) ;
You can’t perform that action at this time.
0 commit comments