@@ -91,8 +91,8 @@ export class SimpleTableManualComponent extends BaseComponent {
9191 presets,
9292 allowActions,
9393 allowTableEdit,
94- allowRowDelete,
95- allowRowEdit,
94+ allowRowDelete : allowRowDeleteExpression ,
95+ allowRowEdit : allowRowEditExpression ,
9696 label : labelProp ,
9797 propertyLabel,
9898 editMode,
@@ -108,10 +108,13 @@ export class SimpleTableManualComponent extends BaseComponent {
108108 const conditions = this . #calculateConditions( editMode , allowActions , allowTableEdit )
109109
110110 this . referenceListStr = getContext ( this . pConn ) . referenceListStr ;
111- this . props . label = this . pConn . getInheritedProps ( ) . label ?? labelProp ?? propertyLabel ;
111+ this . props . label = this . pConn . getInheritedProps ( ) . label || labelProp || propertyLabel ;
112112 this . targetClassLabel = targetClassLabel ;
113113 this . props . addButtonLabel = targetClassLabel ? `+ Add ${ targetClassLabel } ` : "+ Add" ;
114- this . referenceList = referenceList ;
114+ this . referenceList = referenceList . map ( ( element ) => {
115+ element . allowEdit = conditions . allowEditRow && evaluateAllowRowAction ( allowRowEditExpression , element )
116+ return element ;
117+ } ) ;
115118 this . contextClass = this . #getContextClass( configProps ) ;
116119
117120 this . pConn . setReferenceList ( getReferenceList ( this . pConn ) ) ;
@@ -141,8 +144,18 @@ export class SimpleTableManualComponent extends BaseComponent {
141144 this . props . columnLabels = this . #getColumnLabels( fieldDefs , resolvedFields ) ;
142145
143146 if ( ( ! this . #listsEqual( this . prevReferenceList , this . referenceList ) ) ) {
144- this . #buildRows( rawFields , editableMode , conditions . allowDeleteRow , allowRowDelete , conditions . allowEditRow , allowRowEdit ) ;
147+ this . #buildRows( rawFields ) ;
145148 }
149+ this . props . rows = this . editableRows . map ( ( row , rowIndex ) => {
150+ const allowDelete = conditions . allowDeleteRow && evaluateAllowRowAction ( allowRowDeleteExpression , this . referenceList [ rowIndex ] )
151+ const showEditButton = editableMode && this . allowEditingInModal && this . referenceList [ rowIndex ] . allowEdit
152+ const showDeleteButton = editableMode && allowDelete
153+ return {
154+ cellComponentIds : row . cells . map ( ( cell ) => cell . component . compId ) ,
155+ showEditButton : showEditButton ,
156+ showDeleteButton : showDeleteButton
157+ }
158+ } ) ;
146159 this . prevReferenceList = this . referenceList ;
147160 this . componentsManager . onComponentPropsUpdate ( this )
148161 }
@@ -200,13 +213,10 @@ export class SimpleTableManualComponent extends BaseComponent {
200213 }
201214 }
202215
203- #buildRows( rawFields , editableMode , allowDelete , allowRowDeleteExpression , allowEdit , allowRowEditExpression ) {
216+ #buildRows( rawFields ) {
204217 const context = this . pConn . getContextName ( ) ;
205218 const newEditableRows = [ ] ;
206219 this . referenceList . forEach ( ( element , rowIndex ) => {
207- const showDeleteButton = editableMode && allowDelete && evaluateAllowRowAction ( allowRowDeleteExpression , element ) ;
208- const showEditButton = editableMode && allowEdit && evaluateAllowRowAction ( allowRowEditExpression , element ) && this . allowEditingInModal ;
209-
210220 const editableRow = this . editableRows [ rowIndex ] ;
211221 const newEditableCells = [ ] ;
212222 rawFields ?. forEach ( ( item , cellIndex ) => {
@@ -216,7 +226,7 @@ export class SimpleTableManualComponent extends BaseComponent {
216226 config : {
217227 ...item . config ,
218228 label : '' ,
219- displayMode : this . readOnlyMode || this . allowEditingInModal ? 'DISPLAY_ONLY' : undefined
229+ displayMode : this . readOnlyMode || this . allowEditingInModal || ! element . allowEdit ? 'DISPLAY_ONLY' : undefined
220230 }
221231 } ;
222232 const referenceListData = getReferenceList ( this . pConn ) ;
@@ -238,20 +248,9 @@ export class SimpleTableManualComponent extends BaseComponent {
238248 newEditableCells . push ( { component : newComponent } )
239249 }
240250 } ) ;
241- newEditableRows . push ( {
242- cells : newEditableCells ,
243- showEditButton : showEditButton ,
244- showDeleteButton : showDeleteButton
245- } ) ;
251+ newEditableRows . push ( { cells : newEditableCells } ) ;
246252 } ) ;
247253 this . editableRows = newEditableRows ;
248- this . props . rows = newEditableRows . map ( ( row ) => {
249- return {
250- cellComponentIds : row . cells . map ( ( cell ) => cell . component . compId ) ,
251- showEditButton : row . showEditButton ,
252- showDeleteButton : row . showDeleteButton
253- }
254- } ) ;
255254 }
256255
257256 #addSimpleTableRow( ) {
0 commit comments