Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.

## [Unreleased]

- [#259](https://github.com/os2display/display-admin-client/pull/259)
- Add saving of playlists/groups with screen (as opposed to _after_)
- Clean up `screen-manager.jsx`
- Change bootstrap column class from `col-md-8` -> `col-md-12`
- update api.generated.ts to match [related pr](https://github.com/os2display/display-api-service/pull/213)
- Add @rtk-incubator/rtk-query-codegen-openapi to package.json in `src/redux/api`
- Sort playlists based on weight in drag/drop component

## [2.1.0] - 2024-10-23

- [#258](https://github.com/os2display/display-admin-client/pull/258)
Expand Down
9 changes: 2 additions & 7 deletions src/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,8 @@ body,
padding: 5em;
z-index: 1021;

.spinner-container {
display: flex;
position: fixed;

.loading-spinner {
margin-right: 1em;
}
.loading-spinner {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2024-10-02 at 20 03 11

margin-right: 0.6em;
}
}

Expand Down
38 changes: 33 additions & 5 deletions src/components/playlist-drag-and-drop/playlist-drag-and-drop.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,17 @@ import ScreenGanttChart from "../screen/util/screen-gantt-chart";
* @param {string} props.name - The id of the form element
* @param {string} props.screenId - The screen id for get request
* @param {string} props.regionId - The region id for get request
* @param {string} props.regionIdForInitializeCallback - The region id to add
* regions to formstateobject.
* @returns {object} A drag and drop component
*/
function PlaylistDragAndDrop({ handleChange, name, screenId, regionId }) {
function PlaylistDragAndDrop({
handleChange,
name,
screenId,
regionId,
regionIdForInitializeCallback,
}) {
const { t } = useTranslation("common", {
keyPrefix: "playlist-drag-and-drop",
});
Expand All @@ -49,16 +57,35 @@ function PlaylistDragAndDrop({ handleChange, name, screenId, regionId }) {
sharedWithMe: onlySharedPlaylists,
});

/**
* @param regionsAndPlaylists This method initializes playlists, so the
* initial formstate object in screen manager is not empty
*/
function callbackToinitializePlaylists(regionsAndPlaylists) {
handleChange({
target: {
id: regionIdForInitializeCallback,
value: regionsAndPlaylists["hydra:member"].map(
({ playlist }) => playlist
),
},
});
}

/** Set loaded data into form state. */
useEffect(() => {
if (selectedPlaylistsByRegion) {
setTotalItems(selectedPlaylistsByRegion["hydra:totalItems"]);
const newPlaylists = selectedPlaylistsByRegion["hydra:member"].map(
({ playlist }) => {
return playlist;
}
({ playlist, weight }) => ({ ...playlist, weight })
);

const selected = [...selectedData, ...newPlaylists].sort(
(a, b) => a.weight - b.weight
);
setSelectedData([...selectedData, ...newPlaylists]);

setSelectedData(selected);
callbackToinitializePlaylists(selectedPlaylistsByRegion);
}
}, [selectedPlaylistsByRegion]);

Expand Down Expand Up @@ -157,6 +184,7 @@ function PlaylistDragAndDrop({ handleChange, name, screenId, regionId }) {
PlaylistDragAndDrop.propTypes = {
name: PropTypes.string.isRequired,
screenId: PropTypes.string.isRequired,
regionIdForInitializeCallback: PropTypes.string.isRequired,
regionId: PropTypes.string.isRequired,
handleChange: PropTypes.func.isRequired,
};
Expand Down
16 changes: 13 additions & 3 deletions src/components/screen/screen-form.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ function ScreenForm({
);
if (localSelectedLayout) {
setSelectedLayout(localSelectedLayout);
// Initialize regions in the formstate object of screenmanager. used to save "empty" playlists, in the situation
// we are deleting all playlists from a screen region
handleInput({
target: { id: "regions", value: localSelectedLayout.regions },
});
}
}
}, [screen.layout, layoutOptions]);
Expand All @@ -84,6 +89,7 @@ function ScreenForm({
*/
const handleAdd = ({ target }) => {
const { value, id } = target;

setSelectedLayout(value);
handleInput({
target: { id, value: value.map((item) => item["@id"]).shift() },
Expand Down Expand Up @@ -250,7 +256,7 @@ function ScreenForm({
noSelectedString={t("nothing-selected-resolution")}
handleSelection={handleInput}
options={resolutionOptions}
selected={screen.resolution || ""}
selected={screen.resolution || []}
name="resolution"
singleSelect
/>
Expand All @@ -259,7 +265,7 @@ function ScreenForm({
noSelectedString={t("nothing-selected-orientation")}
handleSelection={handleInput}
options={orientationOptions}
selected={screen.orientation || ""}
selected={screen.orientation || []}
name="orientation"
singleSelect
/>
Expand Down Expand Up @@ -340,7 +346,11 @@ ScreenForm.propTypes = {
enableColorSchemeChange: PropTypes.bool,
layout: PropTypes.string,
location: PropTypes.string,
regions: PropTypes.arrayOf(PropTypes.string),
regions: PropTypes.arrayOf(
PropTypes.shape({
"@id": PropTypes.string,
})
),
screenUser: PropTypes.string,
size: PropTypes.string,
title: PropTypes.string,
Expand Down
Loading
Loading