Skip to content

Commit afad693

Browse files
committed
Merge branch 'feat/data-items-eval-context' into feat/set-item-at-index
2 parents 8b3b134 + 5ac9814 commit afad693

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/app/shared/components/template/components/data-items/data-items.component.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,15 @@ export class TmplDataItemsComponent extends TemplateBaseComponent implements OnD
9393
[index: string]: any;
9494
}
9595
) {
96-
const lastRowIndex = rows.length - 1;
97-
return rows.map((r, i) => {
96+
const rowIds = Object.values(dataList).map((v) => v.id);
97+
const lastRowIndex = rowIds.length - 1;
98+
return rows.map((r) => {
9899
// Reassign metadata fields previously assigned by item as rendered row count may have changed
100+
const itemIndex = rowIds.indexOf(r);
99101
r._evalContext.itemContext = {
100102
...r._evalContext.itemContext,
101-
_first: i === 0,
102-
_last: i === lastRowIndex,
103+
_first: itemIndex === 0,
104+
_last: itemIndex === lastRowIndex,
103105
};
104106
// Update any action list set_item args to contain name of current data list and item id
105107
// and set_items action to include all currently displayed rows

0 commit comments

Comments
 (0)