logic editor UI fixes

This commit is contained in:
pandeymangg
2025-11-17 16:41:15 +05:30
parent 85fb7ca956
commit 018e2883ff
4 changed files with 11 additions and 18 deletions

View File

@@ -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}

View File

@@ -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">

View File

@@ -111,6 +111,7 @@ export function LogicEditor({
updateBlockLogic={updateBlockLogic}
localSurvey={localSurvey}
blockIdx={blockIdx}
isLast={isLast}
/>
{isLast ? (

View File

@@ -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