@openg2p/registry-widgets 1.1.6-dev.5 → 1.1.6-dev.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -2857,14 +2857,10 @@ const buildSectionRecords = (widgets, sourceData, { sectionRegisterId, editActio
2857
2857
  : fullPath;
2858
2858
  cleanedSnapshot[fieldPath] = value;
2859
2859
  });
2860
- const sectionData = sectionRegisterId
2861
- ? sourceData[sectionRegisterId] ?? {}
2862
- : {};
2863
2860
  const includeEditAction = editAction === 'always' ||
2864
2861
  (editAction === 'when-register-id' && sectionRegisterId);
2865
2862
  return [
2866
2863
  {
2867
- ...sectionData,
2868
2864
  ...cleanedSnapshot,
2869
2865
  ...(includeEditAction ? { edit_action: 'UPDATE' } : {}),
2870
2866
  },
@@ -2994,32 +2990,38 @@ const diffTableRows = (baselineRecords, currentRecords) => {
2994
2990
  const baselineById = new Map();
2995
2991
  for (const row of baselineRows) {
2996
2992
  const id = getRowId(row);
2997
- if (id)
2993
+ if (id) {
2998
2994
  baselineById.set(id, row);
2995
+ }
2999
2996
  }
3000
2997
  const result = [];
3001
- currentRows.forEach((row, index) => {
2998
+ currentRows.forEach((row) => {
3002
2999
  const editAction = typeof row.edit_action === 'string' ? row.edit_action : undefined;
3003
3000
  const rowId = getRowId(row);
3001
+ // Deleted row
3004
3002
  if (editAction === 'DELETE') {
3005
3003
  if (!rowId)
3006
3004
  return;
3007
- result.push({ internal_record_id: rowId, edit_action: 'DELETE' });
3005
+ result.push({
3006
+ ...row,
3007
+ internal_record_id: rowId,
3008
+ edit_action: 'DELETE',
3009
+ });
3008
3010
  return;
3009
3011
  }
3010
- if (editAction === 'ADD') {
3011
- result.push({ ...row, edit_action: 'ADD' });
3012
+ // New row
3013
+ if (editAction === 'ADD' || !rowId) {
3014
+ result.push({
3015
+ ...row,
3016
+ edit_action: 'ADD',
3017
+ });
3012
3018
  return;
3013
3019
  }
3014
- const baseline = (rowId && baselineById.get(rowId)) || (!rowId ? baselineRows[index] : undefined);
3015
- if (!baseline)
3016
- return;
3017
- const changedFields = pickChangedFields(baseline, row);
3018
- if (Object.keys(changedFields).length === 0)
3019
- return;
3020
+ // Existing row:
3021
+ // Always include the complete row with UPDATE action,
3022
+ // whether it was actually modified or not.
3020
3023
  result.push({
3021
- ...changedFields,
3022
- ...(rowId ? { internal_record_id: rowId } : {}),
3024
+ ...row,
3023
3025
  edit_action: 'UPDATE',
3024
3026
  });
3025
3027
  });