Skip to content

Commit e1ea106

Browse files
committed
fix: complete merge of feat/data-items-eval-context
1 parent 40e86f9 commit e1ea106

File tree

1 file changed

+16
-3
lines changed
  • src/app/shared/components/template/processors

1 file changed

+16
-3
lines changed

src/app/shared/components/template/processors/item.ts

+16-3
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,22 @@ export class ItemProcessor {
3636
*/
3737
private generateLoopItemRows(templateRows: FlowTypes.TemplateRow[], items: any[]) {
3838
const loopItemRows: FlowTypes.TemplateRow[] = [];
39-
for (const [index, item] of Object.entries(items)) {
40-
item._index = Number(index);
41-
const evalContext = { itemContext: item };
39+
const lastItemIndex = items.length - 1;
40+
for (const [indexKey, item] of Object.entries(items)) {
41+
const _index = Number(indexKey);
42+
const evalContext = {
43+
itemContext: {
44+
...item,
45+
// Assign row dynamic context to allow reference to rendered row metadata, including
46+
// item index, id, and whether first or last item in list
47+
_index,
48+
_id: item["id"],
49+
_first: _index === 0,
50+
_last: _index === lastItemIndex,
51+
},
52+
};
53+
console.log("first:", evalContext.itemContext._first);
54+
console.log("last:", evalContext.itemContext._last);
4255
for (const r of templateRows) {
4356
const itemRow = this.setRecursiveRowEvalContext(r, evalContext);
4457
loopItemRows.push(itemRow);

0 commit comments

Comments
 (0)