22<%
33 var tableColumnsEnumName = classify(name) + 'Column';
44 var cmpFileName = dasherize(name);
5+ var hasCustomRowActions = options.customRowActions.length > 0;
6+ var customRowActionNames = options.customRowActions.map(action => `'${action.replace(/\.[^/.]+$/, '')}'`);
57%>
68import {
79 AfterViewInit,
@@ -96,17 +98,23 @@ export enum <%= tableColumnsEnumName %> {
9698 <% if (options.addRowCheckboxes) { %>CHECKBOX = 'checkboxes',<% } %>
9799 <%= enumPropertyDefinitions %>
98100 <%= enumCustomColumns %>
99- <% if (options.customRowActions.length > 0 ) { %>CUSTOM_ROW_ACTIONS = 'customRowActions',<% } %>
101+ <% if (hasCustomRowActions ) { %>CUSTOM_ROW_ACTIONS = 'customRowActions',<% } %>
100102 COLUMNS_MENU = 'columnsMenu'
101103}
102104
103105export const NON_DATA_COLUMNS: <%= tableColumnsEnumName %>[] = [
104- <% if (options.customRowActions.length > 0 ) { %>
106+ <% if (hasCustomRowActions ) { %>
105107 <%= tableColumnsEnumName %>.CUSTOM_ROW_ACTIONS,
106108 <% } %>
107109 <%= tableColumnsEnumName %>.COLUMNS_MENU
108110];
109111
112+ <% if (hasCustomRowActions) { %>
113+ type RowAction = <%= customRowActionNames.join(' | ') %>;
114+ export type <%= options.aspectModelTypeName %>ActionsResolvers = Partial<Record<RowAction, (rowData: <%= options.aspectModelTypeName %>) => boolean>> | undefined;
115+ <% } %>
116+
117+
110118
111119@Component({
112120 selector: '<%= options.selector %>',
@@ -160,6 +168,10 @@ export class <%= classify(name) %>Component implements OnInit, AfterViewInit, Af
160168 @Input() maxExportRows: number = 0;
161169 <% } %>
162170
171+ <% if (hasCustomRowActions) { %>
172+ @Input() actionResolvers: <%= options.aspectModelTypeName %>ActionsResolvers = {};
173+ <% } %>
174+
163175 @Output() rowClickEvent = new EventEmitter<any>();
164176 @Output() rowDblClickEvent = new EventEmitter<any>();
165177 @Output() rowRightClickEvent = new EventEmitter<any>();
@@ -169,7 +181,7 @@ export class <%= classify(name) %>Component implements OnInit, AfterViewInit, Af
169181 @Output() downloadEvent = new EventEmitter<{error: boolean, success: boolean, inProgress: boolean}>();
170182 @Output() rowSelectionEvent = new EventEmitter<any>();
171183
172- <% if (options.customRowActions.length > 0 ) { %>
184+ <% if (hasCustomRowActions ) { %>
173185 @Output() customActionEvent = new EventEmitter<any>();
174186 <% } %>
175187 <% if (options.customCommandBarActions.length > 0) { %>
@@ -383,9 +395,15 @@ export class <%= classify(name) %>Component implements OnInit, AfterViewInit, Af
383395 this.rowRightClickEvent.emit({ data: row, mousePosition: mousePositionOnClick });
384396 }
385397
386- if ($event.type === 'click') {
387- this.rowClickEvent.emit({ data: row })
388- }
398+ <% if (hasCustomRowActions) { %>
399+ if ($event.type === 'click' && this.isAvailableRowAction('forward-right', row)) {
400+ this.rowClickEvent.emit({ data: row })
401+ }
402+ <% } else {%>
403+ if ($event.type === 'click') {
404+ this.rowClickEvent.emit({ data: row })
405+ }
406+ <% }%>
389407
390408 return false;
391409 }
@@ -438,7 +456,7 @@ export class <%= classify(name) %>Component implements OnInit, AfterViewInit, Af
438456 <% } %>
439457 <% } %>
440458
441- <% if (options.customRowActions.length > 0 ) { %>
459+ <% if (hasCustomRowActions ) { %>
442460 executeCustomAction($event: MouseEvent, action: string, row:any): void{
443461 if(this.customRowActionsLength <= this.visibleRowActionsIcons) {
444462 $event.stopPropagation();
@@ -635,7 +653,7 @@ export class <%= classify(name) %>Component implements OnInit, AfterViewInit, Af
635653
636654 displayedColumnsTmp.push(...columns);
637655
638- <% if (options.customRowActions.length > 0 ) { %>
656+ <% if (hasCustomRowActions ) { %>
639657 displayedColumnsTmp.push({name: <%= tableColumnsEnumName %>['CUSTOM_ROW_ACTIONS'], selected: true});
640658 <% } %>
641659
@@ -657,6 +675,14 @@ export class <%= classify(name) %>Component implements OnInit, AfterViewInit, Af
657675 }
658676 <% } %>
659677
678+ protected isAvailableRowAction(action: RowAction, rowData: <%= options.aspectModelTypeName %>): boolean {
679+ if (!this.actionResolvers || !this.actionResolvers[action]) {
680+ return true;
681+ }
682+
683+ return this.actionResolvers[action](rowData) ?? true;
684+ }
685+
660686 <% if (options.hasSearchBar) { %>
661687 private initializeHighlightConfig(): void {
662688 const configStorage = this.storageService.getItem(this.<%= options.localStorageKeyConfig %>);
0 commit comments