A-ha! Yes that was my initial intent with save!value from the otherwise useless line 46 :). Also do like the updatedictionary() theory for specific value updates vs rebuilding the entire local!boxes map on each click, albeit a plugin usage. Which probably 99% of customers do have installed.
I did note in the 21.2 webinar today that we are getting an OOTB a!update() function to handle these CDT updates at specific indexes soon, about time!
a!localVariables(
local!boxes: a!forEach(
items: enumerate(5),
expression: a!map(
label: concat("Box ",fv!index),
visible: fv!isFirst
)
),
a!forEach(
items: local!boxes,
expression: {
a!cardLayout(
style: "ACCENT",
marginBelow: if(fv!item.visible,"NONE","STANDARD"),
showBorder: false,
contents: {
a!columnsLayout(
columns: {
a!columnLayout(
contents: {
a!richTextDisplayField(
labelPosition: "COLLAPSED",
value: a!richTextItem(
text: fv!item.label,
style: "STRONG"
)
)
}
),
a!columnLayout(
contents: {
a!richTextDisplayField(
align: "RIGHT",
labelPosition: "COLLAPSED",
value: a!richTextIcon(
icon: if(fv!item.visible,"angle-down","angle-right"),
size: "MEDIUM"
)
)
}
)
}
)
},
link: a!dynamicLink(
value: not(fv!item.visible),
saveInto: {
a!localVariables(
local!clickIndex: fv!index,
a!save(
local!boxes,
a!forEach(
items: local!boxes,
expression: a!map(
label: fv!item.label,
visible: if(
fv!index=local!clickIndex,
save!value,
false
)
)
)
)
)
}
)
),
a!cardLayout(
showWhen: fv!item.visible,
marginBelow: "STANDARD",
contents: {
a!textField(label: concat("Data ",fv!index))
}
)
}
)
)