Skip to content

Commit

Permalink
merge 1m-rework. addition: popup for blank selections on add rows
Browse files Browse the repository at this point in the history
  • Loading branch information
kennethbruskiewicz committed Dec 18, 2024
1 parent dcf0ed9 commit aedca7f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
28 changes: 19 additions & 9 deletions lib/DataHarmonizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -778,30 +778,40 @@ class DataHarmonizer {

// Validate and process the current selection
const is1mAndHasParent = (class_assignment) => {
console.log(this.context.currentSelection, this.context.oneToManyAppContext.appContext[class_assignment]);
const unique_keys = this.context.oneToManyAppContext.appContext[class_assignment].unique_keys;
const unique_keys =
this.context.oneToManyAppContext.appContext[class_assignment]
.unique_keys;
for (let key in unique_keys) {
if ('foreign_key' in unique_keys[key]) {
return unique_keys[key].foreign_key;
}
}
return false;
};
const classIsForeignKeyForClassAndCurrentSelection = (maybe_child_class, currentSelection) => {
const unique_keys = this.context.oneToManyAppContext.appContext[maybe_child_class].unique_keys;
return !isEmptyUnitVal(unique_keys[currentSelection.shared_key_name]) && maybe_child_class !== currentSelection.source;

}
const classIsForeignKeyForClassAndCurrentSelection = (
maybe_child_class,
currentSelection
) => {
const unique_keys =
this.context.oneToManyAppContext.appContext[maybe_child_class]
.unique_keys;
return (
!isEmptyUnitVal(unique_keys[currentSelection.shared_key_name]) &&
maybe_child_class !== currentSelection.source
);
};
// check if the DH refers to a parent class or class with no children.
// if it has a parent, ensure a foreign key is selected in some parent
// if it doesn't have a parent, use regular add rows implementation
if (is1mAndHasParent(this.class_assignment)) {
if (
!isEmptyUnitVal(this.context.currentSelection) &&
!isEmptyUnitVal(this.context.currentSelection.valueToMatch) &&
classIsForeignKeyForClassAndCurrentSelection(this.class_assignment, this.context.currentSelection)
classIsForeignKeyForClassAndCurrentSelection(
this.class_assignment,
this.context.currentSelection
)
) {

// Insert the new rows below the last existing row
this.hot.alter('insert_row_below', startRowIndex, numRows);
// Find the nearest index after the last non-empty row in the specified column
Expand Down
1 change: 0 additions & 1 deletion lib/Toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import pkg from '../package.json';

const VERSION = pkg.version;


class Toolbar {
constructor(root, context, options = {}) {
this.context = context;
Expand Down

0 comments on commit aedca7f

Please sign in to comment.