Commit e1ea106 1 parent 40e86f9 commit e1ea106 Copy full SHA for e1ea106
File tree 1 file changed +16
-3
lines changed
src/app/shared/components/template/processors
1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -36,9 +36,22 @@ export class ItemProcessor {
36
36
*/
37
37
private generateLoopItemRows ( templateRows : FlowTypes . TemplateRow [ ] , items : any [ ] ) {
38
38
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 ) ;
42
55
for ( const r of templateRows ) {
43
56
const itemRow = this . setRecursiveRowEvalContext ( r , evalContext ) ;
44
57
loopItemRows . push ( itemRow ) ;
You can’t perform that action at this time.
0 commit comments