Skip to content

Commit f4041af

Browse files
prettier
1 parent 394fc82 commit f4041af

File tree

3 files changed

+49
-64
lines changed

3 files changed

+49
-64
lines changed

lib/DataHarmonizer.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ class DataHarmonizer {
627627
rowHeaders: true,
628628
copyPaste: true,
629629
contextMenu: ['remove_row', 'row_above', 'row_below'],
630-
outsideClickDeselects: false, // for maintaining selection between tabs
630+
outsideClickDeselects: false, // for maintaining selection between tabs
631631
manualColumnResize: true,
632632
//colWidths: [100], //Just fixes first column width
633633
minRows: 100,
@@ -784,7 +784,6 @@ class DataHarmonizer {
784784
}
785785
}.bind(self)
786786
);
787-
788787
}
789788

790789
addRowsToBottom(numRows) {

lib/Toolbar.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,6 @@ class Toolbar {
509509
schemaClass,
510510
})
511511
.then(async (context) => {
512-
513512
const languages = await context.getLocaleData(template_name);
514513
context.addTranslationResources(context.template, languages);
515514

@@ -525,7 +524,6 @@ class Toolbar {
525524
languages,
526525
columnCoordinates,
527526
}) => {
528-
529527
const languageSelect = $('#select-language-localization').empty();
530528
for (const { langcode, nativeName } of Object.values(languages)) {
531529
languageSelect.append(new Option(nativeName, langcode));
@@ -562,7 +560,7 @@ class Toolbar {
562560

563561
this.hideValidationResultButtons();
564562
};
565-
563+
566564
updateGUI({
567565
schema_name,
568566
template_name,
@@ -581,7 +579,6 @@ class Toolbar {
581579
this.setupSectionMenu(this.context.dhs[extraData.data]);
582580
this.setupFillModal(this.context.dhs[extraData.data]);
583581
});
584-
585582
}
586583

587584
setupSectionMenu(dh) {

web/index.js

+47-58
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,10 @@ class AppConfig {
6868
}
6969

7070
class AppContext {
71-
7271
schema_tree = {};
7372
dhs = {};
7473
current_data_harmonizer_name = null;
7574
template = null;
76-
7775

7876
constructor(appConfig) {
7977
this.appConfig = appConfig;
@@ -565,7 +563,6 @@ function findSlotNamesForClass(schema, class_name) {
565563
* @returns {Object|null} The schema tree object, or null if no "Container" classes are found.
566564
*/
567565
function buildSchemaTree(schema) {
568-
569566
function updateChildrenAndSharedKeys(data) {
570567
// Use a deep clone to avoid mutating the original object
571568
const result = JSON.parse(JSON.stringify(data));
@@ -635,13 +632,12 @@ function buildSchemaTree(schema) {
635632
});
636633
}, {}),
637634
};
635+
}
638636

639-
};
640-
641-
console.log('has Container')
637+
console.log('has Container');
642638

643639
const classes = Object.keys(schema.classes).filter(
644-
(el) => el !== 'dh_interface' && el !== 'Container'
640+
(el) => el !== 'dh_interface' && el !== 'Container'
645641
);
646642

647643
const tree_base = {
@@ -660,7 +656,7 @@ function buildSchemaTree(schema) {
660656
}, tree_base);
661657

662658
const schema_tree = updateChildrenAndSharedKeys(pre_schema_tree);
663-
console.log(schema_tree)
659+
console.log(schema_tree);
664660
return schema_tree;
665661
}
666662

@@ -693,7 +689,6 @@ function makeDataHarmonizersFromSchemaTree(
693689
schema_name,
694690
export_formats
695691
) {
696-
697692
function createDataHarmonizerContainer(dhId, isActive) {
698693
let dhSubroot = document.createElement('div');
699694
dhSubroot.id = dhId;
@@ -741,11 +736,10 @@ function makeDataHarmonizersFromSchemaTree(
741736
dhTab.addEventListener('click', () => {
742737
// set the current dataharmonizer tab in the context
743738
context.setCurrentDataHarmonizer(spec.name);
744-
739+
745740
$(document).trigger('dhCurrentChange', {
746-
data: spec.name
741+
data: spec.name,
747742
});
748-
749743
});
750744
dhTabNav.appendChild(dhTab); // Appending to the tab navigation
751745

@@ -900,16 +894,13 @@ function setupSharedColumn(data_harmonizer, shared_key_name, callback) {
900894
*/
901895
function makeSharedKeyHandler(data_harmonizer, schema_tree_node) {
902896
const makeUpdateHandler = (shared_key_spec) => {
903-
904897
const updateSchemaNodeChildrenCallback = (
905898
changes,
906899
source,
907900
old_value,
908901
new_value
909902
) => {
910-
911903
schema_tree_node.children.forEach((cls_key) => {
912-
913904
// lift this out to a more general function?
914905

915906
// transformation handler: what to do when a cell with a shared key is updated
@@ -928,12 +919,10 @@ function makeSharedKeyHandler(data_harmonizer, schema_tree_node) {
928919
// visitSchemaTree(schema_tree, () => transformMultivaluedColumn(data_harmonizers[cls_key], shared_key_name, changes, source, old_value, new_value), cls_key)
929920
// })
930921
// }, cls_key);
931-
932922
});
933923
};
934924

935925
return updateSchemaNodeChildrenCallback;
936-
937926
};
938927

939928
schema_tree_node.shared_keys.forEach((shared_key_spec) => {
@@ -980,80 +969,80 @@ function attachPropagationEventHandlersToDataHarmonizers(
980969
}
981970
});
982971

983-
984972
function stripDiv(html) {
985-
const div = document.createElement("div");
973+
const div = document.createElement('div');
986974
div.innerHTML = html;
987-
return (div.innerText);
975+
return div.innerText;
988976
}
989977

990-
Object.values(data_harmonizers).forEach(dh => {
991-
978+
Object.values(data_harmonizers).forEach((dh) => {
992979
dh.hot.addHook('afterSelection', (row, col) => {
993980
const valueToMatch = dh.hot.getDataAtCell(row, col);
994981

995982
// get value at cell
996983
// filter other data harmonizer at cell
997-
schema_tree[dh.class_assignment].children.forEach(child_name => {
998-
const shared_key_name = schema_tree[dh.class_assignment].shared_keys.filter(el => el.related_concept === child_name)[0].name;
984+
schema_tree[dh.class_assignment].children.forEach((child_name) => {
985+
const shared_key_name = schema_tree[
986+
dh.class_assignment
987+
].shared_keys.filter((el) => el.related_concept === child_name)[0].name;
999988
visitSchemaTree(
1000989
schema_tree,
1001990
(schema_tree_node) => {
1002-
1003991
const hot = data_harmonizers[schema_tree_node.name].hot;
1004992
const columnHeaders = hot.getColHeader();
1005993
const columnName = shared_key_name; // shared_key based on event selection ~ replace columnIndex with event data?
1006-
const columnIndex = columnHeaders.map(stripDiv).findIndex(header => header === columnName);
994+
const columnIndex = columnHeaders
995+
.map(stripDiv)
996+
.findIndex((header) => header === columnName);
1007997

1008998
if (columnIndex === -1) {
1009999
console.error('Column name not found');
10101000
return;
10111001
}
10121002
const plugin = hot.getPlugin('filters');
10131003
// Add a condition where the column value equals the specified value
1014-
plugin.clearConditions(columnIndex); // change valueToMatch per new selection in the column
1004+
plugin.clearConditions(columnIndex); // change valueToMatch per new selection in the column
10151005
plugin.addCondition(columnIndex, 'eq', [valueToMatch]);
10161006
plugin.filter();
1017-
10181007
},
1019-
child_name)
1020-
})
1008+
child_name
1009+
);
1010+
});
10211011
});
10221012

10231013
dh.hot.addHook('afterDeselect', () => {
1014+
// get value at cell
1015+
// filter other data harmonizer at cell
1016+
schema_tree[dh.class_assignment].children.forEach((child_name) => {
1017+
const shared_key_name = schema_tree[
1018+
dh.class_assignment
1019+
].shared_keys.filter((el) => el.related_concept === child_name)[0].name;
10241020

1025-
// get value at cell
1026-
// filter other data harmonizer at cell
1027-
schema_tree[dh.class_assignment].children.forEach(child_name => {
1028-
1029-
const shared_key_name = schema_tree[dh.class_assignment].shared_keys.filter(el => el.related_concept === child_name)[0].name;
1030-
1031-
visitSchemaTree(
1032-
schema_tree,
1033-
(schema_tree_node) => {
1034-
1035-
const hot = data_harmonizers[schema_tree_node.name].hot;
1036-
const columnHeaders = hot.getColHeader();
1037-
const columnName = shared_key_name; // shared_key based on event selection ~ replace columnIndex with event data?
1038-
const columnIndex = columnHeaders.map(stripDiv).findIndex(header => header === columnName);
1039-
1040-
if (columnIndex === -1) {
1041-
console.error('Column name not found');
1042-
return;
1043-
}
1044-
1045-
const plugin = hot.getPlugin('filters');
1046-
plugin.clearConditions(columnIndex);
1047-
plugin.filter();
1021+
visitSchemaTree(
1022+
schema_tree,
1023+
(schema_tree_node) => {
1024+
const hot = data_harmonizers[schema_tree_node.name].hot;
1025+
const columnHeaders = hot.getColHeader();
1026+
const columnName = shared_key_name; // shared_key based on event selection ~ replace columnIndex with event data?
1027+
const columnIndex = columnHeaders
1028+
.map(stripDiv)
1029+
.findIndex((header) => header === columnName);
10481030

1049-
},
1050-
child_name)
1031+
if (columnIndex === -1) {
1032+
console.error('Column name not found');
1033+
return;
1034+
}
10511035

1052-
})
1036+
const plugin = hot.getPlugin('filters');
1037+
plugin.clearConditions(columnIndex);
1038+
plugin.filter();
1039+
},
1040+
child_name
1041+
);
1042+
});
10531043
});
10541044
// TODO: preserve memory of selection between tabs! in DH? => using outsideClickDeselects: false, // for maintaining selection between tabs
1055-
1056-
})
1045+
});
10571046

10581047
return data_harmonizers;
10591048
}

0 commit comments

Comments
 (0)