Skip to content

Commit ac165be

Browse files
author
Sine Jespersen
committed
2314: sort playlists based on weight (or else drag and drop does not make any sense)
1 parent 5d1095a commit ac165be

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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.

src/components/playlist-drag-and-drop/playlist-drag-and-drop.jsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff 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]);

0 commit comments

Comments
 (0)