Skip to content

Commit

Permalink
Merge branch 'jh/checkist-with-or' into jh/checklist-with-or-after-re…
Browse files Browse the repository at this point in the history
…factor
  • Loading branch information
jamdelion authored Dec 4, 2024
2 parents ef01ddd + 40b0d0d commit 6470404
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { ICONS } from "../../shared/icons";
import type { Checklist } from "../model";
import { toggleExpandableChecklist } from "../model";
import { ChecklistProps } from "../types";
import { Options } from "./components/Options";
import { Options } from "./Options";

export const ChecklistComponent: React.FC<ChecklistProps> = (props) => {
const type = TYPES.Checklist;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import React from "react";
import ImgInput from "ui/editor/ImgInput/ImgInput";
import SimpleMenu from "ui/editor/SimpleMenu";
import Input from "ui/shared/Input/Input";
import InputRow from "ui/shared/InputRow";
import InputRowItem from "ui/shared/InputRowItem";

import { FlagsSelect } from "../../shared/FlagsSelect";
import { OptionEditorProps } from "../types";

export const OptionEditor: React.FC<OptionEditorProps> = (props) => {
return (
<div style={{ width: "100%" }}>
<InputRow>
{props.value.id ? (
<input type="hidden" value={props.value.id} readOnly />
) : null}
<InputRowItem width="200%">
<Input
required
format="bold"
multiline
value={props.value.data.text || ""}
onChange={(ev) => {
props.onChange({
...props.value,
data: {
...props.value.data,
text: ev.target.value,
},
});
}}
placeholder="Option"
/>
</InputRowItem>

<ImgInput
img={props.value.data.img}
onChange={(img) => {
props.onChange({
...props.value,
data: {
...props.value.data,
img,
},
});
}}
/>

{typeof props.index !== "undefined" &&
props.groups &&
props.onMoveToGroup && (
<SimpleMenu
items={props.groups.map((group, groupIndex) => ({
label: `Move to ${group || `group ${groupIndex}`}`,
onClick: () => {
props.onMoveToGroup &&
typeof props.index === "number" &&
props.onMoveToGroup(props.index, groupIndex);
},
disabled: groupIndex === props.groupIndex,
}))}
/>
)}
</InputRow>

{props.showValueField && (
<InputRow>
<Input
format="data"
value={props.value.data.val || ""}
placeholder="Data Value"
onChange={(ev) => {
props.onChange({
...props.value,
data: {
...props.value.data,
val: ev.target.value,
},
});
}}
/>
</InputRow>
)}

<FlagsSelect
value={
Array.isArray(props.value.data.flag)
? props.value.data.flag
: [props.value.data.flag]
}
onChange={(ev) => {
props.onChange({
...props.value,
data: {
...props.value.data,
flag: ev,
},
});
}}
/>
</div>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import ErrorWrapper from "ui/shared/ErrorWrapper";
import { object } from "yup";

import { Props } from "../types";
import { AutoAnsweredChecklist } from "./components/AutoAnsweredChecklist";
import { AutoAnsweredChecklist } from "./AutoAnsweredChecklist";
import { getInitialExpandedGroups, toggleInArray } from "./helpers";

export enum ChecklistLayout {
Expand Down

0 comments on commit 6470404

Please sign in to comment.