@@ -16,7 +16,7 @@ import { ComponentMapperComponent } from '../../../_bridge/component-mapper/comp
1616import { AngularPConnectData , AngularPConnectService } from '../../../_bridge/angular-pconnect' ;
1717import { DatapageService } from '../../../_services/datapage.service' ;
1818import { getReferenceList } from '../../../_helpers/field-group-utils' ;
19- import { buildFieldsForTable , filterDataByCommonFields , filterDataByDate , getContext } from './helpers' ;
19+ import { buildFieldsForTable , evaluateAllowRowAction , filterDataByCommonFields , filterDataByDate , getContext } from './helpers' ;
2020import { Utils } from '../../../_helpers/utils' ;
2121import { getSeconds } from '../../../_helpers/common' ;
2222
@@ -36,7 +36,9 @@ interface SimpleTableManualProps {
3636 contextClass ?: string ;
3737 propertyLabel ?: string ;
3838 fieldMetadata ?: any ;
39+ allowActions ?: any ;
3940 allowTableEdit ?: boolean ;
41+ allowRowDelete ?: any ;
4042 editMode ?: string ;
4143 addAndEditRowsWithin ?: any ;
4244 viewForAddAndEditModal ?: any ;
@@ -231,7 +233,9 @@ export class SimpleTableManualComponent implements OnInit, OnDestroy {
231233 renderMode,
232234 children, // destructure children into an array var: "resolvedFields"
233235 presets,
236+ allowActions,
234237 allowTableEdit,
238+ allowRowDelete,
235239 label : labelProp ,
236240 propertyLabel,
237241 fieldMetadata,
@@ -245,12 +249,22 @@ export class SimpleTableManualComponent implements OnInit, OnDestroy {
245249 targetClassLabel
246250 } = this . configProps$ ;
247251
252+ const simpleTableManualProps : any = { } ;
253+ if ( this . checkIfAllowActionsOrRowEditingExist ( allowActions ) && editMode ) {
254+ simpleTableManualProps . hideAddRow = allowActions ?. allowAdd === false ;
255+ simpleTableManualProps . hideDeleteRow = allowActions ?. allowDelete === false ;
256+ simpleTableManualProps . hideEditRow = allowActions ?. allowEdit === false ;
257+ simpleTableManualProps . disableDragDrop = allowActions ?. allowDragDrop === false ;
258+ } else if ( allowTableEdit === false ) {
259+ simpleTableManualProps . hideAddRow = true ;
260+ simpleTableManualProps . hideDeleteRow = true ;
261+ simpleTableManualProps . disableDragDrop = true ;
262+ }
263+
248264 this . referenceListStr = getContext ( this . pConn$ ) . referenceListStr ;
249265 this . label = labelProp || propertyLabel ;
250266 this . parameters = fieldMetadata ?. datasource ?. parameters ;
251267 this . targetClassLabel = targetClassLabel ;
252- const hideAddRow = allowTableEdit === false ;
253- const hideDeleteRow = allowTableEdit === false ;
254268 let { contextClass } = this . configProps$ ;
255269 this . referenceList = referenceList ;
256270 if ( ! contextClass ) {
@@ -287,10 +301,10 @@ export class SimpleTableManualComponent implements OnInit, OnDestroy {
287301 this . readOnlyMode = renderMode === 'ReadOnly' ;
288302 this . editableMode = renderMode === 'Editable' ;
289303 const isDisplayModeEnabled = displayMode === 'DISPLAY_ONLY' ;
290- this . showAddRowButton = ! this . readOnlyMode && ! hideAddRow ;
304+ this . showAddRowButton = ! this . readOnlyMode && ! simpleTableManualProps . hideAddRow ;
291305 this . allowEditingInModal =
292306 ( editMode ? editMode === 'modal' : addAndEditRowsWithin === 'modal' ) && ! ( renderMode === 'ReadOnly' || isDisplayModeEnabled ) ;
293- const showDeleteButton = this . editableMode && ! hideDeleteRow ;
307+ const showDeleteButton = this . editableMode && ! simpleTableManualProps . hideDeleteRow && evaluateAllowRowAction ( allowRowDelete , this . rowData ) ;
294308 this . defaultView = editModeConfig ? editModeConfig . defaultView : viewForAddAndEditModal ;
295309 this . bUseSeparateViewForEdit = editModeConfig ? editModeConfig . useSeparateViewForEdit : useSeparateViewForEdit ;
296310 this . editView = editModeConfig ? editModeConfig . editView : viewForEditModal ;
@@ -356,6 +370,10 @@ export class SimpleTableManualComponent implements OnInit, OnDestroy {
356370 // ties the 3 data structures together.
357371 }
358372
373+ checkIfAllowActionsOrRowEditingExist ( newflagobject ) {
374+ return ( newflagobject && Object . keys ( newflagobject ) . length > 0 ) || this . pConn$ . getComponentConfig ( ) . allowRowEdit ;
375+ }
376+
359377 initializeDefaultPageInstructions ( ) {
360378 if ( this . isInitialized ) {
361379 this . isInitialized = false ;
0 commit comments