Cleanup from code review

This commit is contained in:
2025-03-05 19:30:52 -06:00
parent 07cb6fd323
commit 8ec0ce5455
3 changed files with 6 additions and 25 deletions

View File

@ -111,7 +111,7 @@ function RecordGridWidget({widgetMetaData, data, addNewRecordCallback, disableRo
} }
const tableMetaData = data.childTableMetaData instanceof QTableMetaData ? data.childTableMetaData as QTableMetaData : new QTableMetaData(data.childTableMetaData); const tableMetaData = data.childTableMetaData instanceof QTableMetaData ? data.childTableMetaData as QTableMetaData : new QTableMetaData(data.childTableMetaData);
const rows = DataGridUtils.makeRows(records, tableMetaData); const rows = DataGridUtils.makeRows(records, tableMetaData, undefined, true);
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
// note - tablePath may be null, if the user doesn't have access to the table. // // note - tablePath may be null, if the user doesn't have access to the table. //
@ -255,14 +255,14 @@ function RecordGridWidget({widgetMetaData, data, addNewRecordCallback, disableRo
disabledFields = data.defaultValuesForNewChildRecords; disabledFields = data.defaultValuesForNewChildRecords;
} }
const defaultValuesForNewChildRecords = data.defaultValuesForNewChildRecords || {} const defaultValuesForNewChildRecords = data.defaultValuesForNewChildRecords || {};
/////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////
// copy values from specified fields in the parent record down into the child record // // copy values from specified fields in the parent record down into the child record //
/////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////
if(data.defaultValuesForNewChildRecordsFromParentFields) if (data.defaultValuesForNewChildRecordsFromParentFields)
{ {
for(let childField in data.defaultValuesForNewChildRecordsFromParentFields) for (let childField in data.defaultValuesForNewChildRecordsFromParentFields)
{ {
const parentField = data.defaultValuesForNewChildRecordsFromParentFields[childField]; const parentField = data.defaultValuesForNewChildRecordsFromParentFields[childField];
defaultValuesForNewChildRecords[childField] = parentRecord?.values?.get(parentField); defaultValuesForNewChildRecords[childField] = parentRecord?.values?.get(parentField);

View File

@ -71,7 +71,7 @@ export default class DataGridUtils
/******************************************************************************* /*******************************************************************************
** **
*******************************************************************************/ *******************************************************************************/
public static makeRows = (results: QRecord[], tableMetaData: QTableMetaData, tableVariant?: QTableVariant): GridRowsProp[] => public static makeRows = (results: QRecord[], tableMetaData: QTableMetaData, tableVariant?: QTableVariant, allowEmptyId = false): GridRowsProp[] =>
{ {
const fields = [...tableMetaData.fields.values()]; const fields = [...tableMetaData.fields.values()];
const rows = [] as any[]; const rows = [] as any[];
@ -112,7 +112,7 @@ export default class DataGridUtils
///////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////
// DataGrid gets very upset about a null or undefined here, so, try to make it happier // // DataGrid gets very upset about a null or undefined here, so, try to make it happier //
///////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////
if (!tableVariant) if (!allowEmptyId)
{ {
row["id"] = "--"; row["id"] = "--";
} }
@ -242,20 +242,6 @@ export default class DataGridUtils
cellValues.value ? <Link to={`${linkBase}${encodeURIComponent(cellValues.value)}`} onClick={(e) => e.stopPropagation()}>{cellValues.value}</Link> : "" cellValues.value ? <Link to={`${linkBase}${encodeURIComponent(cellValues.value)}`} onClick={(e) => e.stopPropagation()}>{cellValues.value}</Link> : ""
); );
} }
/* todo wip ... not sure if/how to get tooltipFieldName set in the row... */
/*
else if (field.hasAdornment(AdornmentType.TOOLTIP))
{
const tooltipAdornment = field.getAdornment(AdornmentType.TOOLTIP);
const tooltipFieldName: string = tooltipAdornment.getValue("tooltipFieldName");
if(tooltipFieldName)
{
column.renderCell = (cellValues: any) => (
cellValues.value ? <Tooltip title={cellValues.row[tooltipFieldName]}><span>{cellValues.value}</span></Tooltip> : ""
);
}
}
*/
}); });
} }

View File

@ -255,11 +255,6 @@ class ValueUtils
return (<BlobComponent field={field} url={url} filename={displayValue} usage={usage} />); return (<BlobComponent field={field} url={url} filename={displayValue} usage={usage} />);
} }
// todo if(field.hasAdornment(AdornmentType.CODE))
// todo {
// todo return <span style={{fontFamily: "monospace", fontSize: "12px", color: "#4f4f4f"}}>{ValueUtils.getUnadornedValueForDisplay(field, rawValue, displayValue)}</span>
// todo }
return (ValueUtils.getUnadornedValueForDisplay(field, rawValue, displayValue)); return (ValueUtils.getUnadornedValueForDisplay(field, rawValue, displayValue));
} }