Skip to content

Commit

Permalink
Filtering with facets in new model
Browse files Browse the repository at this point in the history
  • Loading branch information
kennethbruskiewicz committed Oct 23, 2024
1 parent bc2ab00 commit 464ec41
Showing 1 changed file with 26 additions and 25 deletions.
51 changes: 26 additions & 25 deletions lib/utils/1m.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand All @@ -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);
Expand Down

0 comments on commit 464ec41

Please sign in to comment.