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
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ All notable changes to this project will be documented in this file.
- Fix data fetching bug + tests
- Refactored screen layout commands.
- Moved list components (search and checkboxes) around.
- Replaced lodash functions with native ones.
- Aligned environment variable names.
- Aligned with v. 2.6.0.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
usePutV2PlaylistsByIdMutation,
usePostV2PlaylistsMutation,
} from "../../../shared/redux/enhanced-api.ts";
import { set } from "lodash/object";

/**
* The shared manager component.
Expand Down Expand Up @@ -280,7 +281,7 @@ function PlaylistCampaignManager({
*/
const handleInput = ({ target }) => {
const localFormStateObject = { ...formStateObject };
localFormStateObject[target.id] = target.value;
set(localFormStateObject, target.id, target.value);
setFormStateObject(localFormStateObject);
};

Expand Down
3 changes: 2 additions & 1 deletion assets/admin/components/screen/screen-manager.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
displayError,
} from "../util/list/toast-component/display-toast";
import idFromUrl from "../util/helpers/id-from-url";
import { set } from "lodash/object";

/**
* The screen manager component.
Expand Down Expand Up @@ -95,7 +96,7 @@ function ScreenManager({
const handleInput = ({ target }) => {
let localFormStateObject = { ...formStateObject };
localFormStateObject = JSON.parse(JSON.stringify(localFormStateObject));
localFormStateObject[target.id] = target.value;
set(localFormStateObject, target.id, target.value);
setFormStateObject(localFormStateObject);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Col, Row } from "react-bootstrap";
import { useTranslation } from "react-i18next";
import FileSelector from "../file-selector";
import FormInput from "../../../util/forms/form-input";
import { set } from "lodash/object";

/**
* Contact form.
Expand All @@ -27,7 +28,7 @@ function ContactForm({
*/
const onInput = ({ target }) => {
const localContact = { ...contact };
localContact[target.name] = target.value;
set(localContact, target.name, target.value);
onChange(localContact);
};

Expand Down
5 changes: 3 additions & 2 deletions assets/admin/components/slide/content/feed-selector.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import ContentForm from "./content-form";
import MultiselectFromEndpoint from "./multiselect-from-endpoint";
import PosterSelectorV1 from "./poster/poster-selector-v1";
import PosterSelectorV2 from "./poster/poster-selector-v2";
import { set } from "lodash/object";

/**
* Feed selector.
Expand Down Expand Up @@ -99,12 +100,12 @@ function FeedSelector({
const configuration = { ...value.configuration };

if (target !== null) {
configuration[target.id] = target.value;
set(configuration, target.id, target.value);
}

if (targets !== null) {
targets.forEach(({ id, value: targetValue }) => {
configuration[id] = targetValue;
set(configuration, id, targetValue);
});
}

Expand Down
33 changes: 20 additions & 13 deletions assets/admin/components/slide/slide-manager.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
} from "../util/list/toast-component/display-toast";
import idFromUrl from "../util/helpers/id-from-url";
import localStorageKeys from "../util/local-storage-keys";
import { get, set } from "lodash/object";

/**
* The slide manager component.
Expand Down Expand Up @@ -153,7 +154,7 @@ function SlideManager({
*/
const handleInput = ({ target }) => {
const localFormStateObject = { ...formStateObject };
localFormStateObject[target.id] = target.value;
set(localFormStateObject, target.id, target.value);
setFormStateObject(localFormStateObject);
};

Expand Down Expand Up @@ -206,7 +207,7 @@ function SlideManager({
const value =
target.type === "number" ? target.valueAsNumber : target.value;
const localFormStateObject = { ...formStateObject };
localFormStateObject.content[target.id] = value;
set(localFormStateObject.content, target.id, value);
setFormStateObject(localFormStateObject);
};

Expand Down Expand Up @@ -351,12 +352,12 @@ function SlideManager({
// It is an already added temp file.
if (entry.tempId) {
newField.push(entry.tempId);
localMediaData[entry.tempId] = entry;
set(localMediaData, entry.tempId, entry);
}
// It is a new temp file.
else {
if (!Array.isArray(localFormStateObject.content[fieldId])) {
localFormStateObject.content[fieldId] = [];
set(localFormStateObject.content, fieldId, []);
}

// Create a tempId for the media.
Expand All @@ -367,7 +368,7 @@ function SlideManager({

const newEntry = { ...entry };
newEntry.tempId = tempId;
localMediaData[tempId] = newEntry;
set(localMediaData, tempId, newEntry);
}
}
// Previously selected file.
Expand All @@ -381,16 +382,18 @@ function SlideManager({
if (
!Object.prototype.hasOwnProperty.call(localMediaData, entry["@id"])
) {
localMediaData[entry["@id"]] = entry;
set(localMediaData, entry["@id"], entry);

localFormStateObject.media.push(entry["@id"]);
}
}
});
}

localFormStateObject.content[fieldId] = newField;
localFormStateObject.media = [...new Set([...localFormStateObject.media])];
set(localFormStateObject.content, fieldId, newField);
set(localFormStateObject, "media", [
...new Set([...localFormStateObject.media]),
]);

setFormStateObject(localFormStateObject);
setMediaData(localMediaData);
Expand All @@ -402,7 +405,7 @@ function SlideManager({

// Setup submittingMedia list.
mediaFields.forEach((fieldName) => {
const fieldData = formStateObject.content[fieldName];
const fieldData = get(formStateObject.content, fieldName);

if (fieldData) {
if (Array.isArray(fieldData)) {
Expand Down Expand Up @@ -552,10 +555,14 @@ function SlideManager({
newFormStateObject.media.push(savedMediaData["@id"]);

// Replace TEMP-- id with real id.
newFormStateObject.content[submittedMedia.fieldName] =
newFormStateObject.content[submittedMedia.fieldName].map((mediaId) =>
mediaId === submittedMedia.tempId ? savedMediaData["@id"] : mediaId,
);
set(
newFormStateObject.content,
submittedMedia.fieldName,
get(newFormStateObject.content, submittedMedia.fieldName).map(
(mediaId) =>
mediaId === submittedMedia.tempId ? savedMediaData["@id"] : mediaId,
),
);

const newMediaData = { ...mediaData };
newMediaData[savedMediaData["@id"]] = savedMediaData;
Expand Down
3 changes: 2 additions & 1 deletion assets/admin/components/util/table/table-body.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Fragment } from "react";
import useModal from "../../../context/modal-context/modal-context-hook";
import { get } from "lodash/object";

/**
* @param {object} props The props.
Expand All @@ -22,7 +23,7 @@ function TableBody({ columns, data }) {
return column.content(item);
}

let cellData = item[column.path];
let cellData = get(item, column.path);

if (column.dataFunction) {
cellData = column.dataFunction(cellData);
Expand Down
9 changes: 5 additions & 4 deletions assets/client/data-sync/pull-strategy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import isPublished from "../util/isPublished";
import logger from "../logger/logger";
import ApiHelper from "./api-helper";
import { cloneDeep } from "lodash";

/**
* PullStrategy.
Expand Down Expand Up @@ -135,7 +136,7 @@ class PullStrategy {
async getSlidesForRegions(regions) {
return new Promise((resolve, reject) => {
const promises = [];
const regionData = structuredClone(regions);
const regionData = cloneDeep(regions);

// @TODO: Fix eslint-raised issues.
// eslint-disable-next-line guard-for-in,no-restricted-syntax
Expand Down Expand Up @@ -199,7 +200,7 @@ class PullStrategy {
return;
}

const newScreen = structuredClone(screen);
const newScreen = cloneDeep(screen);

newScreen.hasActiveCampaign = false;

Expand Down Expand Up @@ -303,7 +304,7 @@ class PullStrategy {
const dataEntrySlidesData = dataEntryPlaylist.slidesData;

for (const slideKey of Object.keys(dataEntrySlidesData)) {
const slide = structuredClone(dataEntrySlidesData[slideKey]);
const slide = cloneDeep(dataEntrySlidesData[slideKey]);

let previousSlide = null;

Expand All @@ -314,7 +315,7 @@ class PullStrategy {
this.lastestScreenData.regionData[regionKey][playlistKey]
.slidesData[slideKey]
) {
previousSlide = structuredClone(
previousSlide = cloneDeep(
this.lastestScreenData.regionData[regionKey][playlistKey]
.slidesData[slideKey],
);
Expand Down
3 changes: 2 additions & 1 deletion assets/client/service/schedule-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import isPublished from "../util/isPublished";
import logger from "../logger/logger";
import ClientConfigLoader from "../util/client-config-loader.js";
import ScheduleUtils from "../util/schedule";
import { cloneDeep } from "lodash";

/**
* ScheduleService.
Expand Down Expand Up @@ -213,7 +214,7 @@ class ScheduleService {
return;
}

const newSlide = structuredClone(slide);
const newSlide = cloneDeep(slide);

// Execution id is the product of region, playlist and slide id, to ensure uniqueness in the client.
const executionId = Md5(regionId + playlist["@id"] + slide["@id"]);
Expand Down
7 changes: 1 addition & 6 deletions assets/tests/template/template-calendar.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ const fixTime = async (page) => {
await page.clock.install({ time: newDate });
};

const fixTimeToNow = async (page) => {
const newDate = new Date();
await page.clock.install({ time: newDate });
};

test("calendar-0-multiple-days: ui tests", async ({ page }) => {
await fixTime(page);

Expand Down Expand Up @@ -236,7 +231,7 @@ test("calendar-0-single-booking: ui tests", async ({ page }) => {
});

test("calendar-1-single-booking: ui tests", async ({ page }) => {
await fixTimeToNow(page);
await fixTime(page);
await page.goto("/template/calendar-1-single-booking");
await expect(page.getByText("Ledigt")).toHaveCount(1);
await expect(page.getByText("Ledigt")).toBeVisible();
Expand Down
Loading
Loading