mirror of
https://github.com/formbricks/formbricks.git
synced 2026-04-18 03:20:35 -05:00
logic editor UI fixes
This commit is contained in:
@@ -19,8 +19,6 @@ export const AdvancedSettings = ({
|
||||
questionIdx,
|
||||
localSurvey,
|
||||
updateQuestion,
|
||||
updateBlockLogic,
|
||||
updateBlockLogicFallback,
|
||||
selectedLanguageCode,
|
||||
}: AdvancedSettingsProps) => {
|
||||
const showOptionIds =
|
||||
@@ -31,16 +29,6 @@ export const AdvancedSettings = ({
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-4">
|
||||
{/* TODO: Re-enable ConditionalLogic in post-MVP */}
|
||||
{/* <ConditionalLogic
|
||||
question={question}
|
||||
updateQuestion={updateQuestion}
|
||||
updateBlockLogic={updateBlockLogic}
|
||||
updateBlockLogicFallback={updateBlockLogicFallback}
|
||||
localSurvey={localSurvey}
|
||||
questionIdx={questionIdx}
|
||||
/> */}
|
||||
|
||||
<UpdateQuestionId
|
||||
question={question}
|
||||
questionIdx={questionIdx}
|
||||
|
||||
@@ -40,6 +40,7 @@ interface LogicEditorActionsProps {
|
||||
block: TSurveyBlock;
|
||||
updateBlockLogic: (blockIdx: number, logic: TSurveyBlockLogic[]) => void;
|
||||
blockIdx: number;
|
||||
isLast?: boolean;
|
||||
}
|
||||
|
||||
export function LogicEditorActions({
|
||||
@@ -49,6 +50,7 @@ export function LogicEditorActions({
|
||||
block,
|
||||
updateBlockLogic,
|
||||
blockIdx,
|
||||
isLast,
|
||||
}: LogicEditorActionsProps) {
|
||||
const actions = logicItem.actions;
|
||||
const { t } = useTranslation();
|
||||
@@ -111,7 +113,7 @@ export function LogicEditorActions({
|
||||
{t("environments.surveys.edit.then")}
|
||||
</div>
|
||||
|
||||
<div className="flex grow flex-col gap-y-2 border-b border-slate-200 last:pb-3">
|
||||
<div className={cn("flex grow flex-col gap-y-2 last:pb-3", isLast && "border-b border-slate-200")}>
|
||||
{actions?.map((action, idx) => (
|
||||
<div className="flex items-center gap-x-2" key={action.id}>
|
||||
<div className="flex w-10 shrink-0 items-center justify-end">
|
||||
|
||||
@@ -111,6 +111,7 @@ export function LogicEditor({
|
||||
updateBlockLogic={updateBlockLogic}
|
||||
localSurvey={localSurvey}
|
||||
blockIdx={blockIdx}
|
||||
isLast={isLast}
|
||||
/>
|
||||
|
||||
{isLast ? (
|
||||
|
||||
@@ -949,14 +949,16 @@ export const getActionTargetOptions = (
|
||||
const allElements = localSurvey.blocks?.flatMap((b) => b.elements) ?? [];
|
||||
|
||||
// Calculate which elements come after the current block
|
||||
let elementsBeforeCurrentBlock = 0;
|
||||
for (let i = 0; i < blockIdx; i++) {
|
||||
elementsBeforeCurrentBlock += localSurvey.blocks[i].elements.length;
|
||||
let elementsUpToAndIncludingCurrentBlock = 0;
|
||||
for (let i = 0; i <= blockIdx; i++) {
|
||||
elementsUpToAndIncludingCurrentBlock += localSurvey.blocks[i].elements.length;
|
||||
}
|
||||
|
||||
// For requireAnswer, show elements after the current block
|
||||
// For requireAnswer, show elements after the current block (not including current block)
|
||||
if (action.objective === "requireAnswer") {
|
||||
const elementsAfterCurrentBlock = allElements.filter((_, idx) => idx > elementsBeforeCurrentBlock);
|
||||
const elementsAfterCurrentBlock = allElements.filter(
|
||||
(_, idx) => idx >= elementsUpToAndIncludingCurrentBlock
|
||||
);
|
||||
const nonRequiredElements = elementsAfterCurrentBlock.filter((element) => !element.required);
|
||||
|
||||
// Return element IDs for requireAnswer
|
||||
|
||||
Reference in New Issue
Block a user