diff --git a/packages/components/package-lock.json b/packages/components/package-lock.json index 09ac1a54fa..cb649bf0c5 100644 --- a/packages/components/package-lock.json +++ b/packages/components/package-lock.json @@ -1,12 +1,12 @@ { "name": "@labkey/components", - "version": "7.33.3", + "version": "7.33.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@labkey/components", - "version": "7.33.3", + "version": "7.33.4", "license": "SEE LICENSE IN LICENSE.txt", "dependencies": { "@hello-pangea/dnd": "18.0.1", diff --git a/packages/components/package.json b/packages/components/package.json index 7b5215e79c..1ac1b4f662 100644 --- a/packages/components/package.json +++ b/packages/components/package.json @@ -1,6 +1,6 @@ { "name": "@labkey/components", - "version": "7.33.3", + "version": "7.33.4", "description": "Components, models, actions, and utility functions for LabKey applications and pages", "sideEffects": false, "files": [ diff --git a/packages/components/releaseNotes/components.md b/packages/components/releaseNotes/components.md index 61f73f23c5..ad9d579ae9 100644 --- a/packages/components/releaseNotes/components.md +++ b/packages/components/releaseNotes/components.md @@ -1,6 +1,11 @@ # @labkey/components Components, models, actions, and utility functions for LabKey applications and pages +### version 7.33.4 +*Released*: 3 May 2026 +- Consolidate Dataclass data update methods - use DIB for update only + - Remove `altUpdateKeys` from `QueryInfo` + ### version 7.33.3 *Released*: 1 May 2026 - Accessibility improvements: add labels or aria-labels to input elements diff --git a/packages/components/src/internal/components/editable/actions.ts b/packages/components/src/internal/components/editable/actions.ts index 910046041c..16c8826ea7 100644 --- a/packages/components/src/internal/components/editable/actions.ts +++ b/packages/components/src/internal/components/editable/actions.ts @@ -123,7 +123,7 @@ export const initEditorModel = async ( } if (forUpdate) { - // If we're updating then we need to ensure that the pkCols and altUpdateKeys are in the columnMap + // If we're updating then we need to ensure that the pkCols are in the columnMap queryInfo.getPkCols().forEach(pkCol => { if (!columnMap[pkCol.fieldKey.toLowerCase()]) { columnMap[pkCol.fieldKey.toLowerCase()] = pkCol; @@ -131,14 +131,6 @@ export const initEditorModel = async ( } }); - queryInfo.altUpdateKeys?.forEach(fieldKey => { - const col = queryInfo.getColumn(fieldKey); - if (col && !columnMap[fieldKey.toLowerCase()]) { - columnMap[fieldKey.toLowerCase()] = col; - columns.push(col); - } - }); - const hasContainerCol = columns.filter(c => c.fieldKey.toLowerCase() === 'container' || c.fieldKey.toLowerCase() === 'folder') .length > 0; diff --git a/packages/components/src/internal/components/editable/models.test.ts b/packages/components/src/internal/components/editable/models.test.ts index 8b714e710f..71d523ead0 100644 --- a/packages/components/src/internal/components/editable/models.test.ts +++ b/packages/components/src/internal/components/editable/models.test.ts @@ -952,18 +952,6 @@ describe('EditorModel', () => { expect(updatedRows[0][expInputCol.fieldKey.toLowerCase()]).toBeUndefined(); }); }); - test('altUpdateKeys', () => { - const queryInfo = basicEditorModel.queryInfo.mutate({ altUpdateKeys: new Set([colTwoFk]) }); - const cellKey = genCellKey(colOneFk, 0); - const value = List([{ display: 'Changed', raw: 'changed' } as ValueDescriptor]); - const model = modifyEm({ - cellValues: basicEditorModel.cellValues.set(cellKey, value), - queryInfo, - }); - const updatedRows = model.getUpdatedData(); - // altUpdateKeys are always appended to row values even if not changed - expect(updatedRows[0]).toHaveProperty(colTwoFk); - }); test('field added', () => { const addedColumn = new QueryColumn({ name: 'added', @@ -1489,25 +1477,14 @@ describe('EditorModel', () => { }), }; const queryInfo = new QueryInfo(config); - const queryInfoWithAltKey = new QueryInfo({ - ...config, - altUpdateKeys: new Set(['lsid']), - }); const cellValues = fromJS({ [genCellKey('RowId', 0)]: List([{ raw: 1 } as ValueDescriptor]), - [genCellKey('lsid', 0)]: List([{ raw: 'abc' } as ValueDescriptor]), }); - let model = new EditorModel({ + const model = new EditorModel({ queryInfo, cellValues, }); expect(model.getPkValues(0)).toStrictEqual({ RowId: 1 }); - - model = new EditorModel({ - queryInfo: queryInfoWithAltKey, - cellValues, - }); - expect(model.getPkValues(0)).toStrictEqual({ RowId: 1, lsid: 'abc' }); }); }); }); diff --git a/packages/components/src/internal/components/editable/models.ts b/packages/components/src/internal/components/editable/models.ts index 970905a234..bbadbb797b 100644 --- a/packages/components/src/internal/components/editable/models.ts +++ b/packages/components/src/internal/components/editable/models.ts @@ -202,7 +202,6 @@ export class EditorModel const data = {}; const pkCols = new Set(); this.queryInfo.getPkCols().forEach(col => pkCols.add(col.fieldKey)); - this.queryInfo.altUpdateKeys?.forEach(key => pkCols.add(key)); pkCols.forEach(pkCol => { const pkVal = this.getValue(pkCol, rowIndex).get(0).raw; @@ -764,10 +763,6 @@ export class EditorModel const updatedRows: UpdatedRow[] = []; editorRows.forEach((editedRow, idx) => { const id = editedRow.get(pkFieldKey); - const altIds = {}; - queryInfo.altUpdateKeys?.forEach(altIdField => { - altIds[altIdField] = altIdField ? editedRow.get(altIdField) : undefined; - }); const originalRow = originalData.get(id.toString()); if (originalRow) { // Issue 52038: key here is almost always the column name (not the fieldKey) and should remain so since that is @@ -875,7 +870,6 @@ export class EditorModel // Always append folder if it's in the original data so cross folder updates work const folder = caseInsensitive(originalRow?.toJS(), FOLDER_COL)?.[0]?.value; if (folder !== undefined) row[FOLDER_COL] = folder; - Object.assign(row, altIds); updatedRows.push(row); } } else { diff --git a/packages/components/src/internal/components/forms/BulkUpdateForm.tsx b/packages/components/src/internal/components/forms/BulkUpdateForm.tsx index 9b63c052a6..7e93c82484 100644 --- a/packages/components/src/internal/components/forms/BulkUpdateForm.tsx +++ b/packages/components/src/internal/components/forms/BulkUpdateForm.tsx @@ -260,7 +260,7 @@ export class BulkUpdateForm extends PureComponent { } const rows = !Utils.isEmptyObj(data) - ? getUpdatedData(this.state.originalDataForSelection, data, queryInfo, queryInfo.altUpdateKeys) + ? getUpdatedData(this.state.originalDataForSelection, data, queryInfo) : []; return updateRows(queryInfo.schemaQuery, rows, comment); diff --git a/packages/components/src/internal/query/api.ts b/packages/components/src/internal/query/api.ts index bcbf6ec5f5..4502369577 100644 --- a/packages/components/src/internal/query/api.ts +++ b/packages/components/src/internal/query/api.ts @@ -245,7 +245,6 @@ export function applyQueryMetadata(rawQueryInfo: any, schemaName?: string, query const queryLabel = rawQueryInfo.title || _queryName; const disabledSystemFields = new Set(rawQueryInfo.disabledSystemFields ?? []); - const altUpdateKeys = new Set(rawQueryInfo.altUpdateKeys ?? []); const defaultQueryMeta = { queryLabel, plural: queryLabel, @@ -254,7 +253,6 @@ export function applyQueryMetadata(rawQueryInfo: any, schemaName?: string, query }; queryInfo = Object.assign({}, rawQueryInfo, schemaMeta, defaultQueryMeta, queryMeta, { - altUpdateKeys, disabledSystemFields, // derived fields columns, diff --git a/packages/components/src/internal/util/utils.test.ts b/packages/components/src/internal/util/utils.test.ts index de9f6cc77b..2aba53a654 100644 --- a/packages/components/src/internal/util/utils.test.ts +++ b/packages/components/src/internal/util/utils.test.ts @@ -934,37 +934,6 @@ describe('getUpdatedData', () => { }); }); - test('with additionalCols', () => { - const updatedData = getUpdatedData( - originalData, - { - Value: 'val', - And$C$D$SAgain: 'again', - Other: 'other3', - }, - queryInfo, - new Set(['Data']) - ); - expect(updatedData).toHaveLength(3); - expect(updatedData[0]).toStrictEqual({ - RowId: 445, - Other: 'other3', - Data: 'data1', - }); - expect(updatedData[1]).toStrictEqual({ - RowId: 447, - Value: 'val', - Other: 'other3', - Data: 'data1', - }); - expect(updatedData[2]).toStrictEqual({ - RowId: 448, - Value: 'val', - Other: 'other3', - Data: 'data1', - }); - }); - test('with folder', () => { const originalData_ = fromJS({ '448': { diff --git a/packages/components/src/internal/util/utils.ts b/packages/components/src/internal/util/utils.ts index 1571cb63a8..480ffd365e 100644 --- a/packages/components/src/internal/util/utils.ts +++ b/packages/components/src/internal/util/utils.ts @@ -346,19 +346,16 @@ export function isSameWithStringCompare(value1: any, value2: any): boolean { * @param originalData a map from an id field to a Map from fieldKeys to an object with a 'value' field * @param updatedValues an object mapping fieldKeys to values that are being updated * @param queryInfo the queryInfo to get column information from - * @param additionalCols additional array of fieldKeys to include */ export function getUpdatedData( originalData: Map, // the rows in the original data have column names as keys updatedValues: Record, // the keys here are column fieldKeys - queryInfo: QueryInfo, - additionalCols?: Set + queryInfo: QueryInfo ): any[] { const updateValuesMap = Map(updatedValues); const pkColsLc = new Set(); const pkColsInUse = new Set(); queryInfo.pkCols.forEach(key => pkColsLc.add(key.toLowerCase())); - additionalCols?.forEach(col => pkColsLc.add(col.toLowerCase())); // if the originalData has the container/folder values, keep those as well (i.e., treat it as a primary key) const folderKey = originalData diff --git a/packages/components/src/public/QueryInfo.ts b/packages/components/src/public/QueryInfo.ts index a0ec21b5ac..a5b1a769a8 100644 --- a/packages/components/src/public/QueryInfo.ts +++ b/packages/components/src/public/QueryInfo.ts @@ -18,7 +18,6 @@ export enum QueryInfoStatus { } const QUERY_INFO_DEFAULTS = { - altUpdateKeys: undefined, disabledSystemFields: undefined, // canEdit: false, // canEditSharedViews: false, @@ -73,7 +72,6 @@ export interface ImportTemplate { // Commented out attributes are not used in app, but are returned by the server export class QueryInfo { declare appEditableTable: boolean; // use isAppEditable() - declare altUpdateKeys: Set; declare disabledSystemFields: Set; // declare canEdit: boolean; // declare canEditSharedViews: boolean; @@ -153,7 +151,6 @@ export class QueryInfo { }); const disabledSystemFields = new Set(queryInfoJson.disabledSystemFields ?? []); - const altUpdateKeys = new Set(queryInfoJson.altUpdateKeys ?? []); const views = new ExtendedMap(); if (includeViews) { queryInfoJson.views.forEach(view => { @@ -164,7 +161,6 @@ export class QueryInfo { return new QueryInfo( Object.assign({}, queryInfoJson, { - altUpdateKeys, disabledSystemFields, columns, schemaQuery,