Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { getDataPage } from '../../helpers/data_page';
import handleEvent from '../../helpers/event-utils';
import { getComponentFromMap } from '../../../bridge/helpers/sdk_component_map';
import type { PConnFieldProps } from '../../../types/PConnProps';
import { useDeepMemo } from '../Multiselect/utils';

interface IOption {
key: string;
Expand Down Expand Up @@ -124,6 +125,10 @@ export default function Dropdown(props: DropdownProps) {
}
columns = preProcessColumns(columns);

const memoizedParameters = useDeepMemo(() => {
return parameters;
}, [parameters]);

useEffect(() => {
if (theDatasource) {
const list = Utils.getOptionList(props, getPConnect().getDataObject('')); // 1st arg empty string until typedef marked correctly
Expand Down Expand Up @@ -156,7 +161,7 @@ export default function Dropdown(props: DropdownProps) {
setOptions(optionsData);
});
}
}, []);
}, [memoizedParameters]);

const metaData = Array.isArray(fieldMetadata) ? fieldMetadata.filter(field => field?.classID === className)[0] : fieldMetadata;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
import type { PConnProps } from '../../../types/PConnProps';

interface EmbeddedDataMultiProps extends PConnProps {
addEditAction?: string;
addEditView?: string;
displayAs?: string;
editAction?: string;
editMode?: string;
editType?: string;
editView?: string;
readOnly?: boolean;
repeatingView?: string;
targetObjectClass?: string;
useSeparateActionForEdit?: boolean;
useSeparateViewForEdit?: boolean;
}

export default function EmbeddedDataMulti(props: EmbeddedDataMultiProps) {
const {
getPConnect,
addEditAction,
addEditView,
displayAs,
editAction,
editMode,
editType,
editView,
readOnly = false,
repeatingView,
targetObjectClass,
useSeparateActionForEdit,
useSeparateViewForEdit
} = props;

const pConn = getPConnect();
const rawMetadata = pConn.getRawMetadata() as any;
const rawMetadataConfig = rawMetadata?.config;

if (!rawMetadataConfig) {
return null;
}

const renderMode = readOnly ? 'ReadOnly' : 'Editable';

let columnsChildren;
if (displayAs === 'table' || displayAs === 'simpleTable') {
columnsChildren = [
{
children: rawMetadataConfig.columns || [],
name: 'Columns',
type: 'Region'
}
];
}

let regionWithView: unknown[] = [];
if (displayAs === 'repeatingView') {
regionWithView = [
{
children: [
{
type: 'reference',
config: {
type: 'view',
name: repeatingView
}
}
],
name: 'view',
type: 'Region'
}
];
}

const { pagelistValue } = rawMetadataConfig;
const authorContext = pagelistValue?.startsWith('@P') ? pagelistValue?.substring(3) : pagelistValue;

const simpleTableComponent = pConn.createComponent({
type: 'View',
config: {
template: 'SimpleTable',
type: 'multirecordlist',
authorContext,
name: authorContext?.substring(1),
renderMode,
multiRecordDisplayAs: displayAs === 'repeatingView' ? 'fieldGroup' : displayAs,
referenceList: pagelistValue,
contextClass: targetObjectClass,
editMode,
editModeConfig: {
editType,
defaultView: addEditView,
defaultAction: addEditAction,
useSeparateViewForEdit,
useSeparateActionForEdit,
editView,
editAction
},
label: rawMetadataConfig.label,
children: columnsChildren,
displayField: rawMetadataConfig.displayField,
uniqueField: rawMetadataConfig.uniqueField,
targetClassLabel: rawMetadataConfig.targetClassLabel,
targetClassLabelOption: rawMetadataConfig.targetClassLabelOption,
fieldHeader: rawMetadataConfig.repeatingViewHeadingSource,
heading: rawMetadataConfig.repeatingViewHeading,
allowActions: {
allowAdd: rawMetadataConfig.allowAdd ?? true,
allowEdit: rawMetadataConfig.allowEdit ?? true,
allowDelete: rawMetadataConfig.allowDelete ?? true,
allowDragDrop: rawMetadataConfig.allowDragDrop ?? true
},
allowRowDelete: rawMetadataConfig.allowRowDelete ?? true,
allowRowEdit: rawMetadataConfig.allowRowEdit ?? true,
displayAs: displayAs === 'repeatingView' ? 'fieldGroup' : displayAs
},
children: regionWithView
} as any);

return <>{simpleTableComponent}</>;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "EmbeddedDataMulti",
"description": "Embedded Data Multi",
"type": "Field",
"subtype": "EMBEDDEDDATA",
"properties": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './EmbeddedDataMulti';
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,32 @@ export default function Multiselect(props) {
}
];
let secondaryColumns: any = [];
if (secondaryFields) {
secondaryColumns = secondaryFields.map(secondaryField => ({
value: secondaryField,
// Read columnsFormatter from raw (unresolved) metadata to get field property paths
// (e.g. "@P .pyLabel") instead of resolved data values (e.g. "New Complex Fields").
// This matches Constellation's approach: pConn.getRawMetadata()?.config?.columnsFormatter
const columnsFormatter = (getPConnect().getRawMetadata()?.config as any)?.columnsFormatter;
const secondaryFieldsFromFormatter = columnsFormatter
? columnsFormatter
.map(item => {
const property = item?.config?.value;
if (typeof property === 'string') {
if (property.startsWith('@USER ')) return property.substring(6);
if (property.startsWith('@P ')) return property.substring(3);
return property;
}
return undefined;
})
.filter(Boolean)
: undefined;
const updatedSecondaryFields = secondaryFieldsFromFormatter || secondaryFields;
if (updatedSecondaryFields) {
secondaryColumns = updatedSecondaryFields.map(secondaryField => ({
value: typeof secondaryField === 'string' ? secondaryField : undefined,
display: 'true',
secondary: 'true',
useForSearch: 'true'
}));
secondaryColumns = secondaryColumns.filter(col => col.value);
} else {
secondaryColumns = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ const useDeepMemo = (memoFn, key) => {
const preProcessColumns = columns => {
return columns?.map(col => {
const tempColObj = { ...col };
tempColObj.value = col.value && col.value.startsWith('.') ? col.value.substring(1) : col.value;
if (tempColObj.setProperty) {
if (typeof col.value === 'string') {
tempColObj.value = col.value.startsWith('.') ? col.value.substring(1) : col.value;
}
if (typeof col.setProperty === 'string') {
tempColObj.setProperty = col.setProperty && col.setProperty.startsWith('.') ? col.setProperty.substring(1) : col.setProperty;
}
return tempColObj;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,15 @@ export default function ObjectReference(props: ObjectReferenceProps) {
return getPConnect().createComponent({
type: 'SimpleTableSelect',
config: {
...(mode === 'single'
? {
selectionKey: rawViewMetadata.config.value,
value: rawViewMetadata.config.value,
contextPage: rawViewMetadata.config.contextPage
}
: {
readonlyContextList: rawViewMetadata.config.pagelistValue
}),
dataRelationshipContext: contextPageValue,
defaultRowHeight: rawViewMetadata.config.defaultRowHeight,
displayAs: tableDisplayAs,
Expand Down Expand Up @@ -466,6 +475,52 @@ export default function ObjectReference(props: ObjectReferenceProps) {
return getPConnect().createComponent(componentMeta);
};

const buildEmbeddedInsightTableChild = (rawConfig: any, referenceType: string, propsToUse: any) => {
const insightModel = propsToUse.insightModel;
const insightColumns: any[] = insightModel?.query?.columns ?? [];

const columnChildren = insightColumns
.filter((col: any) => col.type === 'column' && col.field)
.map((col: any) => ({
type: 'TextInput',
config: {
value: `@P .${col.field.fieldID}`,
label: col.field.name || col.field.fieldID
}
}));

const presets = [
{
children: [{ children: columnChildren, name: 'Columns', type: 'Region' }],
config: {},
id: 'P_',
label: '',
name: 'presets',
template: 'Table'
}
];
console.log('Building EmbeddedInsightTable child with config', rawConfig);
const componentMeta = {
type: 'SimpleTableManual',
config: {
contextClass: rawConfig.targetObjectClass,
presets,
label: propsToUse.label,
readonlyContextList: rawConfig.pagelistValue,
referenceList: rawConfig.pagelistValue,
renderMode: 'ReadOnly',
dataPageName: rawConfig.referenceList,
fieldMetadata: {
datasource: {
parameters: rawConfig.parameters ?? {}
}
}
}
};

return getPConnect().createComponent(componentMeta);
};

const recreatedFirstChild = useMemo(() => {
const type = rawViewMetadata.config.componentType;

Expand Down Expand Up @@ -497,6 +552,11 @@ export default function ObjectReference(props: ObjectReferenceProps) {
return buildCardsChild();
}

// EmbeddedInsightTable type
if (type === 'EmbeddedInsightTable') {
return buildEmbeddedInsightTableChild(rawViewMetadata.config, referenceType, propsToUse);
}

if (type === 'CheckboxGroup') {
const displayField = rawViewMetadata.config.displayField;
const primaryField = displayField?.startsWith('@P') ? displayField?.substring(3) : displayField;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ interface ListViewProps extends PConnProps {
compositeKeys?: any;
showDynamicFields?: boolean;
readonlyContextList?: any;
selectedValues?: any;
value: any;
viewName?: string;
showRecords?: boolean;
Expand Down Expand Up @@ -88,11 +89,14 @@ export default function ListView(props: ListViewProps) {
compositeKeys,
showDynamicFields,
viewName,
readonlyContextList: selectedValues,
readonlyContextList,
selectedValues: selectedValuesProp,
value,
displayAs,
localeReference
} = props;
// Use selectedValues prop (passed from SimpleTableSelect) with fallback to readonlyContextList
const selectedValues = selectedValuesProp ?? readonlyContextList;
let { showRecords } = props;
const ref = useRef({}).current;
const cosmosTableRef = useRef<any>(null);
Expand Down
Loading
Loading