Skip to content

Commit aedca7f

Browse files
merge 1m-rework. addition: popup for blank selections on add rows
1 parent dcf0ed9 commit aedca7f

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

lib/DataHarmonizer.js

+19-9
Original file line numberDiff line numberDiff line change
@@ -778,30 +778,40 @@ class DataHarmonizer {
778778

779779
// Validate and process the current selection
780780
const is1mAndHasParent = (class_assignment) => {
781-
console.log(this.context.currentSelection, this.context.oneToManyAppContext.appContext[class_assignment]);
782-
const unique_keys = this.context.oneToManyAppContext.appContext[class_assignment].unique_keys;
781+
const unique_keys =
782+
this.context.oneToManyAppContext.appContext[class_assignment]
783+
.unique_keys;
783784
for (let key in unique_keys) {
784785
if ('foreign_key' in unique_keys[key]) {
785786
return unique_keys[key].foreign_key;
786787
}
787788
}
788789
return false;
789790
};
790-
const classIsForeignKeyForClassAndCurrentSelection = (maybe_child_class, currentSelection) => {
791-
const unique_keys = this.context.oneToManyAppContext.appContext[maybe_child_class].unique_keys;
792-
return !isEmptyUnitVal(unique_keys[currentSelection.shared_key_name]) && maybe_child_class !== currentSelection.source;
793-
794-
}
791+
const classIsForeignKeyForClassAndCurrentSelection = (
792+
maybe_child_class,
793+
currentSelection
794+
) => {
795+
const unique_keys =
796+
this.context.oneToManyAppContext.appContext[maybe_child_class]
797+
.unique_keys;
798+
return (
799+
!isEmptyUnitVal(unique_keys[currentSelection.shared_key_name]) &&
800+
maybe_child_class !== currentSelection.source
801+
);
802+
};
795803
// check if the DH refers to a parent class or class with no children.
796804
// if it has a parent, ensure a foreign key is selected in some parent
797805
// if it doesn't have a parent, use regular add rows implementation
798806
if (is1mAndHasParent(this.class_assignment)) {
799807
if (
800808
!isEmptyUnitVal(this.context.currentSelection) &&
801809
!isEmptyUnitVal(this.context.currentSelection.valueToMatch) &&
802-
classIsForeignKeyForClassAndCurrentSelection(this.class_assignment, this.context.currentSelection)
810+
classIsForeignKeyForClassAndCurrentSelection(
811+
this.class_assignment,
812+
this.context.currentSelection
813+
)
803814
) {
804-
805815
// Insert the new rows below the last existing row
806816
this.hot.alter('insert_row_below', startRowIndex, numRows);
807817
// Find the nearest index after the last non-empty row in the specified column

lib/Toolbar.js

-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ import pkg from '../package.json';
3535

3636
const VERSION = pkg.version;
3737

38-
3938
class Toolbar {
4039
constructor(root, context, options = {}) {
4140
this.context = context;

0 commit comments

Comments
 (0)