Keep every picked card on the finished Rule, and wait for its words before Continue.

This commit is contained in:
adilallo committed 2026-11-22 17:56:38 -07:00
1 parent a846169960
commit a2815ae05f
16 files changed
+417 -114

No files matched your search

+13 -21
View File
@@ -8,11 +8,10 @@ import type {
import type { CommunityRuleSection } from "../../app/components/type/CommunityRule/CommunityRule.types";
import { resolveMethodPresetIdFromLabel } from "./buildFinalReviewCategories";
import {
communicationPresetFor,
conflictManagementPresetFor,
decisionApproachPresetFor,
membershipPresetFor,
mergeCoreValueDetailWithPresets,
emptyCommunicationDetails,
emptyConflictManagementDetails,
emptyDecisionApproachDetails,
emptyMembershipDetails,
publishedMethodDisplayLabel,
} from "./finalReviewChipPresets";
import { isDocumentEntry } from "./documentEntryGuards";
@@ -61,12 +60,12 @@ export function buildCoreValuesForDocument(state: CreateFlowState): Array<{
return snap
.filter((r) => selected.has(r.id))
.map((r) => {
const merged = mergeCoreValueDetailWithPresets(r.id, r.label, details[r.id]);
const saved = details[r.id];
return {
chipId: r.id,
label: r.label,
meaning: merged.meaning,
signals: merged.signals,
meaning: typeof saved?.meaning === "string" ? saved.meaning : "",
signals: typeof saved?.signals === "string" ? saved.signals : "",
};
});
}
@@ -278,10 +277,8 @@ function publishedRowSupportText(
/**
* Merge `selected*MethodIds` with any saved `{group}MethodDetailsById`
* overrides authored on the final-review screen. Preset defaults from the
* shipped `messages/en/create/customRule/*.json` seed any sub-fields the
* user didn't edit so consumers of `document.methodSelections` always see
* a complete payload per method.
* overrides authored on the final-review screen. Blank parts stay blank —
* library presets are not filled in for text the pen holder never wrote.
*/
export function buildMethodSelectionsForDocument(
state: CreateFlowState,
@@ -297,7 +294,6 @@ export function buildMethodSelectionsForDocument(
);
if (commIds.length > 0) {
out.communication = commIds.map((id) => {
const preset = communicationPresetFor(id);
const override = state.communicationMethodDetailsById?.[id];
const supportText = publishedRowSupportText(
id,
@@ -310,7 +306,7 @@ export function buildMethodSelectionsForDocument(
id,
state.customMethodCardMetaById,
),
sections: override ? { ...preset, ...override } : preset,
sections: override ?? emptyCommunicationDetails(),
...(supportText ? { supportText } : {}),
};
});
@@ -322,7 +318,6 @@ export function buildMethodSelectionsForDocument(
);
if (memIds.length > 0) {
out.membership = memIds.map((id) => {
const preset = membershipPresetFor(id);
const override = state.membershipMethodDetailsById?.[id];
const supportText = publishedRowSupportText(
id,
@@ -335,7 +330,7 @@ export function buildMethodSelectionsForDocument(
id,
state.customMethodCardMetaById,
),
sections: override ? { ...preset, ...override } : preset,
sections: override ?? emptyMembershipDetails(),
...(supportText ? { supportText } : {}),
};
});
@@ -347,13 +342,11 @@ export function buildMethodSelectionsForDocument(
);
if (daIds.length > 0) {
out.decisionApproaches = daIds.map((id) => {
const preset = decisionApproachPresetFor(id);
const override = state.decisionApproachDetailsById?.[id];
const supportText = publishedRowSupportText(
id,
state.customMethodCardMetaById,
);
const merged = override ? { ...preset, ...override } : preset;
return {
id,
label: publishedMethodDisplayLabel(
@@ -362,7 +355,7 @@ export function buildMethodSelectionsForDocument(
state.customMethodCardMetaById,
),
sections: withoutUnpublishedDecisionConsensus(
{ ...merged },
{ ...(override ?? emptyDecisionApproachDetails()) },
state.customMethodCardFieldBlocksById?.[id],
) as DecisionApproachDetailEntry,
...(supportText ? { supportText } : {}),
@@ -376,7 +369,6 @@ export function buildMethodSelectionsForDocument(
);
if (cmIds.length > 0) {
out.conflictManagement = cmIds.map((id) => {
const preset = conflictManagementPresetFor(id);
const override = state.conflictManagementDetailsById?.[id];
const supportText = publishedRowSupportText(
id,
@@ -389,7 +381,7 @@ export function buildMethodSelectionsForDocument(
id,
state.customMethodCardMetaById,
),
sections: override ? { ...preset, ...override } : preset,
sections: override ?? emptyConflictManagementDetails(),
...(supportText ? { supportText } : {}),
};
});