File tree Expand file tree Collapse file tree 3 files changed +27
-6
lines changed
packages/react-sdk-components/src/components
SimpleTable/SimpleTableManual Expand file tree Collapse file tree 3 files changed +27
-6
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,26 @@ export function isEmptyObject(obj: Object): boolean {
22 return Object . keys ( obj ) . length === 0 ;
33}
44
5- export function getLocalizedNoRecordsMessage ( ) : string {
5+ /**
6+ * Get a localized value from the Generic Fields
7+ * @param path - The path within Generic Fields (e.g., 'CosmosFields.fields.lists')
8+ * @param key - The key of the string to localize
9+ * @returns The localized string or the key itself if no translation is found
10+ */
11+ export function getGenericFieldsLocalizedValue ( path : string , key : string ) : string {
612 const GENERIC_BUNDLE_KEY = PCore . getLocaleUtils ( ) . GENERIC_BUNDLE_KEY ;
7- return PCore . getLocaleUtils ( ) . localeStore [ GENERIC_BUNDLE_KEY ] ?. CosmosFields ?. fields ?. lists ?. [ 'No records found.' ] || 'No records found.' ;
13+ const localeStore = PCore . getLocaleUtils ( ) . localeStore [ GENERIC_BUNDLE_KEY ] ;
14+
15+ if ( ! localeStore ) return key ;
16+
17+ // Split the path and traverse the object
18+ const pathParts = path . split ( '.' ) ;
19+ let currentObj = localeStore ;
20+
21+ for ( const part of pathParts ) {
22+ if ( ! currentObj [ part ] ) return key ;
23+ currentObj = currentObj [ part ] ;
24+ }
25+
26+ return currentObj [ key ] || key ;
827}
Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ import { filterData } from '../../helpers/simpleTableHelpers';
4343import './ListView.css' ;
4444import { getDateFormatInfo } from '../../helpers/date-format-utils' ;
4545import { getCurrencyOptions } from '../../field/Currency/currency-utils' ;
46- import { getLocalizedNoRecordsMessage } from '../../helpers/common-utils' ;
46+ import { getGenericFieldsLocalizedValue } from '../../helpers/common-utils' ;
4747import { format } from '../../helpers/formatters' ;
4848
4949import useInit from './hooks' ;
@@ -1130,7 +1130,9 @@ export default function ListView(props: ListViewProps) {
11301130 } ) }
11311131 </ TableBody >
11321132 </ Table >
1133- { arRows && arRows . length === 0 && < div className = 'no-records' > { getLocalizedNoRecordsMessage ( ) } </ div > }
1133+ { arRows && arRows . length === 0 && (
1134+ < div className = 'no-records' > { getGenericFieldsLocalizedValue ( 'CosmosFields.fields.lists' , 'No records found.' ) } </ div >
1135+ ) }
11341136 </ TableContainer >
11351137 ) }
11361138 </ >
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ import createPConnectComponent from '../../../../bridge/react_pconnect';
2727import { Utils } from '../../../helpers/utils' ;
2828import { getReferenceList } from '../../../helpers/field-group-utils' ;
2929import { getDataPage } from '../../../helpers/data_page' ;
30- import { getLocalizedNoRecordsMessage } from '../../../helpers/common-utils' ;
30+ import { getGenericFieldsLocalizedValue } from '../../../helpers/common-utils' ;
3131import { buildFieldsForTable , filterData , getContext } from '../../../helpers/simpleTableHelpers' ;
3232import { PConnProps } from '../../../../types/PConnProps' ;
3333import { format } from '../../../helpers/formatters' ;
@@ -712,7 +712,7 @@ export default function SimpleTableManual(props: PropsWithChildren<SimpleTableMa
712712 </ Table >
713713 { ( ( readOnlyMode && ( ! rowData || rowData ?. length === 0 ) ) || ( editableMode && ( ! referenceList || referenceList ?. length === 0 ) ) ) && (
714714 < div className = 'no-records' id = 'no-records' >
715- { getLocalizedNoRecordsMessage ( ) }
715+ { getGenericFieldsLocalizedValue ( 'CosmosFields.fields.lists' , 'No records found.' ) }
716716 </ div >
717717 ) }
718718 </ TableContainer >
You can’t perform that action at this time.
0 commit comments