buildSeoEditorialWorkflowPlanNodes function
Implementation
List<SeoNode> buildSeoEditorialWorkflowPlanNodes(
SeoEditorialWorkflowComponentPlan plan,
) {
final id = plan.interactionId;
final state = plan.initial.state;
final view = plan.initial.view;
final sectionLevel = (plan.headingLevel + 1).clamp(1, 6);
return [
SeoNode(
tag: 'section',
attributes: {
'class': 'esen-seo-editorial-workflow',
if (id != null) ...{
'id': id,
'data-esen-component': 'editorial-workflow',
'data-esen-layout-stable': 'true',
'data-esen-label': plan.interactionLabel,
'data-esen-status-label': plan.statusLabel,
'data-esen-progress-label': plan.progressLabel,
'data-esen-history-label': plan.historyLabel,
'data-esen-submit-label': plan.submitLabel,
'data-esen-approve-label': plan.approveLabel,
'data-esen-reject-label': plan.rejectLabel,
'data-esen-publish-label': plan.publishLabel,
'data-esen-initial-stage': '${state.stage.index}',
'data-esen-initial-history':
state.history.map((stage) => stage.index).join(','),
},
},
children: [
SeoNode(tag: 'h${plan.headingLevel}', text: plan.heading),
if (id != null) _workflowPlaceholder(plan),
SeoNode(
tag: 'p',
attributes: const {'class': 'esen-seo-editorial-workflow-status'},
children: [
SeoNode(tag: 'strong', text: '${plan.statusLabel}: '),
SeoNode(
tag: 'span',
text: view.statusText,
attributes: {
if (id != null) 'data-esen-workflow-status-text': '',
},
),
],
),
SeoNode(
tag: 'p',
children: [
SeoNode(
tag: 'span',
text: view.summaryText,
attributes: {
if (id != null) 'data-esen-workflow-summary': '',
},
),
],
),
SeoNode(
tag: 'ol',
attributes: {
'class': 'esen-seo-editorial-workflow-progress',
'aria-label': plan.progressLabel,
if (id != null) 'data-esen-workflow-progress': '',
},
children: [
for (final stage in SeoEditorialWorkflowStage.values)
SeoNode(
tag: 'li',
text: plan.stages[stage.index].label,
attributes: {
if (id != null)
'data-esen-workflow-progress-stage': '${stage.index}',
if (stage == state.stage) ...{
'aria-current': 'step',
if (id != null) 'data-esen-initial-current': 'true',
},
},
),
],
),
for (final stage in SeoEditorialWorkflowStage.values)
SeoNode(
tag: 'section',
attributes: {
if (id != null) ...{
'id': '$id-stage-${stage.index}',
'data-esen-workflow-stage-region': '${stage.index}',
if (stage == state.stage) 'data-esen-initial-active': 'true',
},
},
children: [
SeoNode(
tag: 'h$sectionLevel',
text: plan.stages[stage.index].label,
attributes: {
if (id != null) 'data-esen-workflow-stage-name': '',
},
),
...plan.stages[stage.index].nodes,
],
),
SeoNode(tag: 'h$sectionLevel', text: plan.historyLabel),
SeoNode(
tag: 'ol',
attributes: {
'class': 'esen-seo-editorial-workflow-history',
if (id != null) 'data-esen-workflow-history': '',
},
children: [
for (final stage in state.history)
SeoNode(
tag: 'li',
text: plan.stages[stage.index].label,
attributes: {
if (id != null)
'data-esen-workflow-history-stage': '${stage.index}',
},
),
],
),
if (id != null)
SeoNode(
tag: 'span',
attributes: const {
'class': 'esen-seo-editorial-workflow-announcement',
'data-esen-workflow-announcement': '',
'aria-live': 'polite',
'aria-atomic': 'true',
},
),
],
),
];
}