-
-
+
- )
+ );
}
- function handleTableChange (id: string, rows: PropsUITableRow[]): void {
- const tablesCopy = tablesOut.current.slice(0)
- const index = tablesCopy.findIndex(table => table.id === id)
+ function handleTableChange(id: string, rows: PropsUITableRow[]): void {
+ const tablesCopy = tablesOut.current.slice(0);
+ const index = tablesCopy.findIndex((table) => table.id === id);
if (index > -1) {
- const { title, head, body: oldBody, deletedRowCount: oldDeletedRowCount } = tablesCopy[index]
- const body: PropsUITableBody = { __type__: 'PropsUITableBody', rows }
- const deletedRowCount = oldDeletedRowCount + (oldBody.rows.length - rows.length)
- tablesCopy[index] = { __type__: 'PropsUITable', id, head, body, title, deletedRowCount }
+ const {
+ title,
+ head,
+ body: oldBody,
+ deletedRowCount: oldDeletedRowCount,
+ } = tablesCopy[index];
+ const body: PropsUITableBody = { __type__: "PropsUITableBody", rows };
+ const deletedRowCount =
+ oldDeletedRowCount + (oldBody.rows.length - rows.length);
+ tablesCopy[index] = {
+ __type__: "PropsUITable",
+ id,
+ head,
+ body,
+ title,
+ deletedRowCount,
+ };
}
- tablesOut.current = tablesCopy
+ tablesOut.current = tablesCopy;
}
- function handleDonate (): void {
- setWaiting(true)
- const value = serializeConsentData()
- resolve?.({ __type__: 'PayloadJSON', value })
+ function handleDonate(): void {
+ setWaiting(true);
+ const value = serializeConsentData();
+ resolve?.({ __type__: "PayloadJSON", value });
}
- function handleCancel (): void {
- resolve?.({ __type__: 'PayloadFalse', value: false })
+ function handleCancel(): void {
+ resolve?.({ __type__: "PayloadFalse", value: false });
}
- function serializeConsentData (): string {
- const array = serializeTables().concat(serializeMetaData())
- return JSON.stringify(array)
+ function serializeConsentData(): string {
+ const array = serializeTables().concat(serializeMetaData());
+ return JSON.stringify(array);
}
- function serializeMetaData (): any[] {
- return serializeMetaTables().concat(serializeDeletedMetaData())
+ function serializeMetaData(): any[] {
+ return serializeMetaTables().concat(serializeDeletedMetaData());
}
- function serializeTables (): any[] {
- return tablesOut.current.map((table) => serializeTable(table))
+ function serializeTables(): any[] {
+ return tablesOut.current.map((table) => serializeTable(table));
}
- function serializeMetaTables (): any[] {
- return metaTables.current.map((table) => serializeTable(table))
+ function serializeMetaTables(): any[] {
+ return metaTables.current.map((table) => serializeTable(table));
}
- function serializeDeletedMetaData (): any {
+ function serializeDeletedMetaData(): any {
const rawData = tablesOut.current
.filter(({ deletedRowCount }) => deletedRowCount > 0)
- .map(({ id, deletedRowCount }) => `User deleted ${deletedRowCount} rows from table: ${id}`)
+ .map(
+ ({ id, deletedRowCount }) =>
+ `User deleted ${deletedRowCount} rows from table: ${id}`
+ );
- const data = JSON.stringify(rawData)
- return { user_omissions: data }
+ const data = JSON.stringify(rawData);
+ return { user_omissions: data };
}
- function serializeTable ({ id, head, body: { rows } }: PropsUITable): any {
- const data = rows.map((row) => serializeRow(row, head))
- return { [id]: data }
+ function serializeTable({ id, head, body: { rows } }: PropsUITable): any {
+ const data = rows.map((row) => serializeRow(row, head));
+ return { [id]: data };
}
- function serializeRow (row: PropsUITableRow, head: PropsUITableHead): any {
- assert(row.cells.length === head.cells.length, `Number of cells in row (${row.cells.length}) should be equals to number of cells in head (${head.cells.length})`)
- const keys = head.cells.map((cell) => cell.text)
- const values = row.cells.map((cell) => cell.text)
- return _.fromPairs(_.zip(keys, values))
+ function serializeRow(row: PropsUITableRow, head: PropsUITableHead): any {
+ assert(
+ row.cells.length === head.cells.length,
+ `Number of cells in row (${row.cells.length}) should be equals to number of cells in head (${head.cells.length})`
+ );
+ const keys = head.cells.map((cell) => cell.text);
+ const values = row.cells.map((cell) => cell.text);
+ return _.fromPairs(_.zip(keys, values));
}
return (
<>
-
-
+
+
{tablesIn.current.map((table) => renderTable(table))}
>
- )
-}
+ );
+};
const donateQuestionLabel = new TextBundle()
- .add('en', 'Do you want to donate the above data?')
- .add('de', 'Möchten Sie die oben genannten Daten spenden?')
- .add('nl', 'Wilt u de bovenstaande gegevens doneren?')
+ .add("en", "Do you want to donate the above data?")
+ .add("nl", "Wilt u de bovenstaande gegevens doneren?");
const donateButtonLabel = new TextBundle()
- .add('en', 'Yes, donate')
- .add('de', 'Ja, spenden')
- .add('nl', 'Ja, doneer')
+ .add("en", "Yes, donate")
+ .add("nl", "Ja, doneer");
-const cancelButtonLabel = new TextBundle()
- .add('en', 'No')
- .add('de', 'Nein')
- .add('nl', 'Nee')
+const cancelButtonLabel = new TextBundle().add("en", "No").add("nl", "Nee");
const description = new TextBundle()
- .add('en', 'Determine whether you would like to donate the data below. Carefully check the data and adjust when required. With your donation you contribute to the previously described research. Thank you in advance.')
- .add('de', 'Legen Sie fest, ob Sie die untenstehenden Daten spenden möchten. Überprüfen Sie die Daten sorgfältig und passen Sie sie bei Bedarf an. Mit Ihrer Spende tragen Sie zur zuvor beschriebenen Forschung bei. Vielen Dank im Voraus.')
- .add('nl', 'Bepaal of u de onderstaande gegevens wilt doneren. Bekijk de gegevens zorgvuldig en pas zo nodig aan. Met uw donatie draagt u bij aan het eerder beschreven onderzoek. Alvast hartelijk dank.')
+ .add(
+ "en",
+ "Determine whether you would like to donate the data below. Carefully check the data and adjust when required. With your donation you contribute to the previously described research. Thank you in advance."
+ )
+ .add(
+ "nl",
+ "Bepaal of u de onderstaande gegevens wilt doneren. Bekijk de gegevens zorgvuldig en pas zo nodig aan. Met uw donatie draagt u bij aan het eerder beschreven onderzoek. Alvast hartelijk dank."
+ );
diff --git a/src/framework/visualisation/react/ui/prompts/file_input.tsx b/src/framework/visualisation/react/ui/prompts/file_input.tsx
index 37f582a5..bcda6e9a 100644
--- a/src/framework/visualisation/react/ui/prompts/file_input.tsx
+++ b/src/framework/visualisation/react/ui/prompts/file_input.tsx
@@ -7,6 +7,7 @@ import { ReactFactoryContext } from '../../factory'
import { PropsUIPromptFileInput } from '../../../../types/prompts'
import { PrimaryButton } from '../elements/button'
import { BodyLarge, BodySmall } from '../elements/text'
+import { JSX } from 'react'
type Props = Weak
& ReactFactoryContext
diff --git a/src/framework/visualisation/react/ui/prompts/progress.tsx b/src/framework/visualisation/react/ui/prompts/progress.tsx
index dced309e..59615bf4 100644
--- a/src/framework/visualisation/react/ui/prompts/progress.tsx
+++ b/src/framework/visualisation/react/ui/prompts/progress.tsx
@@ -3,6 +3,7 @@ import { Translator } from '../../../../translator'
import { ReactFactoryContext } from '../../factory'
import { PropsUIPromptProgress } from '../../../../types/prompts'
import { ProgressBar } from '../elements/progress_bar'
+import { JSX } from 'react'
type Props = Weak & ReactFactoryContext
diff --git a/src/framework/visualisation/react/ui/prompts/radio_input.tsx b/src/framework/visualisation/react/ui/prompts/radio_input.tsx
index f5f7628a..d585c32f 100644
--- a/src/framework/visualisation/react/ui/prompts/radio_input.tsx
+++ b/src/framework/visualisation/react/ui/prompts/radio_input.tsx
@@ -1,84 +1,95 @@
-import * as React from 'react'
-import { Weak } from '../../../../helpers'
-import { PropsUIRadioItem, Translatable } from '../../../../types/elements'
-import TextBundle from '../../../../text_bundle'
-import { Translator } from '../../../../translator'
-import { ReactFactoryContext } from '../../factory'
-import { PropsUIPromptRadioInput } from '../../../../types/prompts'
-import { RadioItem } from '../elements/radio_item'
-import { PrimaryButton } from '../elements/button'
+import * as React from "react";
+import { Weak } from "../../../../helpers";
+import { PropsUIRadioItem, Translatable } from "../../../../types/elements";
+import TextBundle from "../../../../text_bundle";
+import { Translator } from "../../../../translator";
+import { ReactFactoryContext } from "../../factory";
+import { PropsUIPromptRadioInput } from "../../../../types/prompts";
+import { RadioItem } from "../elements/radio_item";
+import { PrimaryButton } from "../elements/button";
+import { JSX } from "react";
interface Copy {
- title: string
- description: string
- continueButton: string
+ title: string;
+ description: string;
+ continueButton: string;
}
-type Props = Weak & ReactFactoryContext
+type Props = Weak & ReactFactoryContext;
-function prepareCopy ({ title, description, locale }: Props): Copy {
+function prepareCopy({ title, description, locale }: Props): Copy {
return {
title: Translator.translate(title, locale),
description: Translator.translate(description, locale),
- continueButton: Translator.translate(continueButtonLabel(), locale)
- }
+ continueButton: Translator.translate(continueButtonLabel(), locale),
+ };
}
export const RadioInput = (props: Props): JSX.Element => {
- const [selectedId, setSelectedId] = React.useState(-1)
- const [waiting, setWaiting] = React.useState(false)
- const [checked, setChecked] = React.useState(false)
+ const [selectedId, setSelectedId] = React.useState(-1);
+ const [waiting, setWaiting] = React.useState(false);
+ const [checked, setChecked] = React.useState(false);
- const { items, resolve } = props
- const { title, description, continueButton } = prepareCopy(props)
+ const { items, resolve } = props;
+ const { title, description, continueButton } = prepareCopy(props);
- function handleSelect (id: number): void {
- setSelectedId(id)
- setChecked(true)
+ function handleSelect(id: number): void {
+ setSelectedId(id);
+ setChecked(true);
}
- function handleConfirm (): void {
+ function handleConfirm(): void {
if (!waiting) {
- setWaiting(true)
- const item = items.at(selectedId)
+ setWaiting(true);
+ const item = items.at(selectedId);
if (item !== undefined) {
- resolve?.({ __type__: 'PayloadString', value: item.value })
+ resolve?.({ __type__: "PayloadString", value: item.value });
}
}
}
- function renderItems (items: PropsUIRadioItem[]): JSX.Element[] {
- return items.map((item, index) => handleSelect(index)} id={index} value={item.value} selected={selectedId === index} />)
+ function renderItems(items: PropsUIRadioItem[]): JSX.Element[] {
+ return items.map((item, index) => (
+ handleSelect(index)}
+ id={index}
+ value={item.value}
+ selected={selectedId === index}
+ />
+ ));
}
return (
<>
-
+
{title}
-
-
-
+
+
+
{description}
-
+
-
-
-
+
+
>
- )
-}
+ );
+};
const continueButtonLabel = (): Translatable => {
- return new TextBundle()
- .add('en', 'Continue')
- .add('de', 'Weiter')
- .add('nl', 'Doorgaan')
-}
+ return new TextBundle().add("en", "Continue").add("nl", "Doorgaan");
+};
diff --git a/src/test/visualisationEngine.test.tsx b/src/test/visualisationEngine.test.tsx
deleted file mode 100644
index 74e917a2..00000000
--- a/src/test/visualisationEngine.test.tsx
+++ /dev/null
@@ -1,7 +0,0 @@
-import { render } from '@testing-library/react'
-
-test('renders hello world', () => {
- render(
)
- // const element = screen.getByText(/Hello, world!/i)
- // expect(element).toBeInTheDocument()
-})