hugo_themes_report/templates/js/buildSelectionMenu.js

117 lines
3.3 KiB
JavaScript
Raw Normal View History

2021-08-17 17:23:51 -07:00
function getMenuSortBy(sortBySelector) {
let sortByNumThemes = document.getElementById(
`${sortBySelector}SortByNumThemes`
2021-08-12 17:23:42 -07:00
);
2021-08-17 17:23:51 -07:00
if (sortByNumThemes === null) {
2021-08-14 17:42:01 -07:00
return "numThemes";
} else {
2021-08-17 17:23:51 -07:00
return sortByNumThemes.checked ? "numThemes" : "name";
2021-08-14 17:42:01 -07:00
}
}
2021-08-14 17:42:01 -07:00
function buildColumnSelectionHeadingRow(eParent, dState) {
let columnSelectionHeadingRow = document.createElement("div");
columnSelectionHeadingRow.id = "columnSelectionHeadingRow";
columnSelectionHeadingRow.style.maxWidth = "100%";
columnSelectionHeadingRow.style.display = dState.columnSelectionHeadingRow;
columnSelectionHeadingRow.style.alignItems = "center";
let columnSelectionHeading = document.createElement("h2");
columnSelectionHeading.innerHTML = "Select Columns";
columnSelectionHeadingRow.appendChild(columnSelectionHeading);
eParent.appendChild(columnSelectionHeadingRow);
2021-08-11 11:58:10 -07:00
}
2021-08-14 17:42:01 -07:00
function buildColumnSelectionDiv(selectedColumns, dState, eParent) {
buildColumnSelectionHeadingRow(eParent, dState);
2021-08-11 11:58:10 -07:00
2021-08-14 17:42:01 -07:00
let columnSelectionRow = document.createElement("div");
columnSelectionRow.id = "columnSelectionRow";
columnSelectionRow.style.display = dState.columnSelectionRow;
columnSelectionRow.style.flexWrap = "wrap";
columnSelectionRow.style.justifyContent = "space-around";
eParent.appendChild(columnSelectionRow);
2021-08-11 11:58:10 -07:00
2021-08-14 17:42:01 -07:00
tableColumns
.filter((x) => selectedColumns.includes(x.headingName))
2021-08-11 20:57:34 -07:00
.forEach((y) => {
2021-08-18 15:09:33 -07:00
// from buildSelectionInput.js
2021-08-14 17:42:01 -07:00
buildInput(y, true, columnSelectionRow);
2021-08-11 20:57:34 -07:00
});
2021-08-11 11:58:10 -07:00
2021-08-14 17:42:01 -07:00
tableColumns
.filter((x) => !selectedColumns.includes(x.headingName))
2021-08-11 20:57:34 -07:00
.forEach((y) => {
2021-08-18 15:09:33 -07:00
// from buildSelectionInput.js
2021-08-14 17:42:01 -07:00
buildInput(y, false, columnSelectionRow);
2021-08-11 20:57:34 -07:00
});
2021-08-11 11:58:10 -07:00
}
2021-08-14 17:42:01 -07:00
// called from buildPage.js
2021-08-11 20:57:34 -07:00
function buildSelectionMenu(
2021-08-17 17:23:51 -07:00
tagAndFeatureFilteredThemes,
2021-08-11 20:57:34 -07:00
sorted_themes,
2021-08-16 10:35:36 -07:00
sortBy,
2021-08-11 20:57:34 -07:00
selectedTags,
2021-08-14 07:21:26 -07:00
selectedFeatures,
2021-08-17 17:23:51 -07:00
selectedLicenses,
2021-08-14 17:42:01 -07:00
selectedColumns,
2021-08-18 15:09:33 -07:00
selectedMinVer,
2021-08-14 07:21:26 -07:00
dState
2021-08-11 20:57:34 -07:00
) {
2021-08-17 17:23:51 -07:00
let tagSortBy = getMenuSortBy("tag");
let featureSortBy = getMenuSortBy("feature");
let licenseSortBy = getMenuSortBy("license");
2021-08-14 17:42:01 -07:00
let selectionMenuDiv = document.getElementById("selection-menu");
2021-08-18 15:09:33 -07:00
// from getAvailableTagsAndFeaturesAndLicenses.js
let availableTags = getAvailableTags(sorted_themes, tagSortBy);
2021-08-18 15:09:33 -07:00
// from getAvailableTagsAndFeaturesAndLicenses.js
let availableFeatures = getAvailableFeatures(sorted_themes, featureSortBy);
2021-08-18 15:09:33 -07:00
// from getAvailableTagsAndFeaturesAndLicenses.js
2021-08-17 17:23:51 -07:00
let availableLicences = getAvailableLicenses(
tagAndFeatureFilteredThemes,
licenseSortBy
);
2021-08-14 17:42:01 -07:00
// from buildSortByDiv.js
2021-08-17 17:23:51 -07:00
buildSortByDiv(sortBy, dState.sortByRow);
buildColumnSelectionDiv(selectedColumns, dState, selectionMenuDiv);
2021-08-14 17:42:01 -07:00
2021-08-18 15:09:33 -07:00
buildMinVerSelectionDiv(selectedMinVer, dState, selectionMenuDiv);
2021-08-17 17:23:51 -07:00
// from buildSelectionDivs.js
buildSelectionDiv(
selectedLicenses,
availableLicences,
licenseSortBy,
dState.licenseSelectionRow,
dState.licenseSelectionHeadingRow,
selectionMenuDiv,
"license"
2021-08-14 17:42:01 -07:00
);
2021-08-17 17:23:51 -07:00
// from buildSelectionDivs.js
buildSelectionDiv(
selectedTags,
availableTags,
tagSortBy,
dState.tagSelectionRow,
dState.tagSelectionHeadingRow,
selectionMenuDiv,
"tag"
2021-08-14 17:42:01 -07:00
);
2021-08-17 17:23:51 -07:00
// from buildSelectionDivs.js
buildSelectionDiv(
selectedFeatures,
availableFeatures,
featureSortBy,
dState.featureSelectionRow,
dState.featureSelectionHeadingRow,
selectionMenuDiv,
"feature"
2021-08-14 07:21:26 -07:00
);
2021-08-11 11:58:10 -07:00
}