From 464ec4138282bb6699b27ac5cc8a06069e08921b Mon Sep 17 00:00:00 2001 From: Kenneth Bruskiewicz Date: Tue, 22 Oct 2024 17:50:56 -0700 Subject: [PATCH] Filtering with facets in new model --- lib/utils/1m.js | 51 +++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/lib/utils/1m.js b/lib/utils/1m.js index f322408b..18d0908b 100644 --- a/lib/utils/1m.js +++ b/lib/utils/1m.js @@ -130,7 +130,7 @@ const findUniqueKeysForClass = (schema, cls_key) => { unique_key.description = slot?.description; unique_key.foreign_key = slot.name in foreignKeySlotsPerClassMap[cls_key]; if ('annotations' in slot && 'foreign_key' in slot.annotations) { - console.warn(cls_key + ' has foreign key annotations: ' + slot.annotations.foreign_key.value); + // console.warn(cls_key + ' has foreign key annotations: ' + slot.annotations.foreign_key.value); const [cls_name, slot_name] = slot.annotations.foreign_key.value.split('.'); unique_key.foreign_key_class = cls_name; unique_key.foreign_key_slot = slot_name; @@ -564,10 +564,10 @@ const bindChangeEmitter = (appContext, dh) => { // TODO: modal continuation interface const currentValue = row_changes[row].oldValues[column_index]; - console.warn('row_changes', row_changes, - 'column_index', column_index, - row_changes[row].oldValues, - row_changes[row].newValues); + // console.warn('row_changes', row_changes, + // 'column_index', column_index, + // row_changes[row].oldValues, + // row_changes[row].newValues); // propagate deletion when the deleted cell was unique of its kind // always propagate updates @@ -821,8 +821,6 @@ const makeCurrentSelection = (appContext, dh) => { const key_name = dh.hot.getSettings().columns[column].name; const maybeValueToMatch = dh.hot.getDataAtCell(row, column); - console.warn(unique_keys, key_name); - let currentSelectionObject = { source: dh.class_assignment, key_name, @@ -933,12 +931,6 @@ function parentBroadcastsCRUD(appContext, dhs) { return; // don't act on changes caused by loading data } if (changes) { - // changes.forEach(function([row, prop, oldValue, newValue]) { - // const event = new CustomEvent('handsontableUpdate', { - // detail: { row, prop, oldValue, newValue, sourceTable: foreign_key_class, shared_key: foreign_key_slot } - // }); - // document.dispatchEvent(event); - // }); const row_changes = changesToRows(changes); const column_index = dh.getColumnIndexByFieldName(foreign_key_slot); @@ -1037,21 +1029,31 @@ const routeAction2 = (appContext, dhs, action, event) => { makeCurrentSelection(appContext, activeDataHarmonizer); event.detail.target = event.detail.currentSelection.name; handleAction2(appContext, dhs, activeDataHarmonizer, action, event.detail); - // propagate filter actions to child tables if possible and allowed - // TODO - if (propagates) { - // warn about deletion if it's the final key - if (action === ACTION.SELECT) { - console.warn("PROPAGATION:", "Row collections with key will be filtered", event.detail); - } - // TODO: how to scope row changes - event.detail.row = null; - dispatchChildHooks2(unique_key, ACTION.FILTER, event.detail); + if ('child_classes' in unique_key) { + unique_key.child_classes.forEach(child_class => { + dispatchHandsontableUpdate2({ + ...event.detail, + action: ACTION.FILTER, + emitted_by, + key_name, + target: child_class, + }); + }); } + // // propagate filter actions to child tables if possible and allowed + // // TODO + // if (propagates) { + // // warn about deletion if it's the final key + // if (action === ACTION.SELECT) { + // console.warn("PROPAGATION:", "Row collections with key will be filtered", event.detail); + // } + // // TODO: how to scope row changes + // event.detail.row = null; + // dispatchChildHooks2(unique_key, ACTION.FILTER, event.detail); + // } } else if (action === ACTION.FILTER) { handleAction2(appContext, dhs, dhs[target], action, event.detail); } else if (action === ACTION.UPDATE || action === ACTION.DELETE) { - console.log(event, event.detail); handleAction2(appContext, dhs, dhs[target], action, event.detail); if (emitted_by === target) { // propagate update actions to child table if possible @@ -1072,7 +1074,6 @@ const routeAction2 = (appContext, dhs, action, event) => { event.detail.row = null; dispatchChildHooks2(unique_key, action, event.detail); } - } } else if (action === ACTION.VALIDATE) { handleAction2(appContext, dhs, dhs[emitted_by], action, event.detail);