buildSeoActionFlowPlanNodes function
Implementation
List<SeoNode> buildSeoActionFlowPlanNodes(SeoActionFlowPlan plan) {
final form = plan.form;
final stepHeadingLevel = form.headingLevel < 6 ? form.headingLevel + 1 : 6;
final fallback = SeoNode(
tag: 'section',
attributes: const {'class': 'esen-seo-action-flow-summary'},
children: [
SeoNode(tag: 'h${form.headingLevel}', text: form.heading),
SeoNode(tag: 'p', text: form.description),
SeoNode(
tag: 'ol',
children: [
for (final step in plan.steps)
SeoNode(
tag: 'li',
children: [
SeoNode(tag: 'h$stepHeadingLevel', text: step.label),
SeoNode(tag: 'p', text: step.description),
SeoNode(
tag: 'ul',
children: [
for (final field in step.fields)
_actionFormFieldSummaryNode(field),
],
),
],
),
if (plan.review case final review?)
SeoNode(
tag: 'li',
children: [
SeoNode(tag: 'h$stepHeadingLevel', text: review.label),
SeoNode(tag: 'p', text: review.description),
SeoNode(
tag: 'ul',
children: [
for (final field in form.fields)
SeoNode(tag: 'li', text: field.label),
],
),
],
),
],
),
],
);
return [
buildInternalSeoActionFormNode(
fallback: fallback,
markup: SeoActionFormMarkup(
actionId: form.actionId,
headingLevel: form.headingLevel,
heading: form.heading,
description: form.description,
submitLabel: form.submitLabel,
pendingLabel: form.pendingLabel,
failureLabel: form.failureLabel,
statusLabel: form.statusLabel,
contextToken: form.contextToken,
fields: List.unmodifiable([
for (final field in form.fields) _actionFormMarkupField(field),
]),
flow: SeoActionFlowMarkup(
steps: List.unmodifiable([
for (final step in plan.steps)
SeoActionFlowMarkupStep(
label: step.label,
description: step.description,
firstFieldIndex: step.firstFieldIndex,
fieldCount: step.fields.length,
condition: step.condition == null
? null
: SeoActionFlowMarkupCondition(
fieldName: step.condition!.fieldName,
fieldIndex: step.condition!.fieldIndex,
value: step.condition!.value,
),
),
]),
previousLabel: plan.previousLabel,
nextLabel: plan.nextLabel,
progressLabel: plan.progressLabel,
review: plan.review == null
? null
: SeoActionFlowMarkupReview(
label: plan.review!.label,
description: plan.review!.description,
emptyValueLabel: plan.review!.emptyValueLabel,
consentAcceptedLabel: plan.review!.consentAcceptedLabel,
consentDeclinedLabel: plan.review!.consentDeclinedLabel,
),
),
),
),
];
}