Skip to content

Commit

Permalink
Deploy preview for PR 76 🛫
Browse files Browse the repository at this point in the history
  • Loading branch information
brauliorivas committed Aug 13, 2024
1 parent 9856b7d commit 2e36fcf
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 9 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
18 changes: 11 additions & 7 deletions pr-preview/pr-76/js/filters/collections/mcparticle.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {
CheckboxComponent,
checkboxLogic,
bitfieldCheckboxLogic,
objectSatisfiesCheckbox,
} from "../components/checkbox.js";
Expand Down Expand Up @@ -46,14 +45,18 @@ function renderMCParticleFilters(viewObjects) {
simStatusContainer.appendChild(simStatusTitle);
const simStatusCheckboxesContainer = createCheckboxContainer();

Object.keys(SimStatusBitFieldDisplayValues).forEach((status) => {
const checkbox = new CheckboxComponent(
"simulatorStatus",
status,
SimStatusBitFieldDisplayValues[status]
);
Object.entries(SimStatusBitFieldDisplayValues).forEach(([status, value]) => {
const checkbox = new CheckboxComponent("simulatorStatus", status, value);
checkboxes.simStatus.push(checkbox);
simStatusCheckboxesContainer.appendChild(checkbox.render());

viewObjects.datatypes["edm4hep::MCParticle"].collection.forEach(
(mcparticle) => {
if (bitfieldCheckboxLogic(value, mcparticle, "simulatorStatus")) {
checkbox.checked(true);
}
}
);
});
simStatusContainer.appendChild(simStatusCheckboxesContainer);

Expand All @@ -76,6 +79,7 @@ function renderMCParticleFilters(viewObjects) {
);
checkboxes.generatorStatus.push(checkbox);
genStatusCheckboxesContainer.appendChild(checkbox.render());
checkbox.checked(true);
});
generatorStatusContainer.appendChild(genStatusCheckboxesContainer);

Expand Down
2 changes: 2 additions & 0 deletions pr-preview/pr-76/js/filters/components/checkbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ const createCheckbox = () => {
const checkbox = document.createElement("input");
checkbox.type = "checkbox";
checkbox.classList.add("filter-checkbox");
checkbox.classList.add("filter-input-checkbox");

return checkbox;
};

Expand Down
11 changes: 9 additions & 2 deletions pr-preview/pr-76/js/filters/components/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,22 @@ export function buildCollectionCheckboxes(collection) {
);
checkboxes.push(checkbox);
checkboxesContainer.appendChild(checkbox.render());
checkbox.checked(true);
});
container.appendChild(checkboxesContainer);

selectAll.addEventListener("click", () => {
checkboxes.forEach((checkbox) => checkbox.checked(true));
checkboxes.forEach((checkbox) => {
checkbox.checked(true);
checkbox.checkbox.dispatchEvent(new Event("change"));
});
});

clearAll.addEventListener("click", () => {
checkboxes.forEach((checkbox) => checkbox.checked(false));
checkboxes.forEach((checkbox) => {
checkbox.checked(false);
checkbox.checkbox.dispatchEvent(new Event("change"));
});
});

return [container, checkboxes];
Expand Down
1 change: 1 addition & 0 deletions pr-preview/pr-76/js/filters/components/range.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const createInput = (placeholder) => {
input.type = "number";
input.placeholder = placeholder;
input.classList.add("range-input");
input.classList.add("filter-input-range");

return input;
};
Expand Down
23 changes: 23 additions & 0 deletions pr-preview/pr-76/js/filters/filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ export function initFilters(
) {
const criteriaFunctions = {};

let someInputChanged = false;

const resetFiltersContent = () => {
const content = document.getElementById("filters-content");
content.replaceChildren();
Expand All @@ -69,11 +71,32 @@ export function initFilters(

const filterOutCheckbox = document.getElementById("invert-filter");
filterOutCheckbox.checked = false;

const allCheckboxes = document.getElementsByClassName(
"filter-input-checkbox"
);

for (const input of allCheckboxes) {
input.addEventListener("change", () => {
someInputChanged = true;
});
}

const allInputs = document.getElementsByClassName("filter-input-range");

for (const input of allInputs) {
input.addEventListener("input", () => {
someInputChanged = true;
});
}
};

resetFiltersContent();

filters.apply = async () => {
if (!someInputChanged) {
return;
}
const filterOutValue = document.getElementById("invert-filter").checked;
const ids = filterOut(
viewObjects,
Expand Down

0 comments on commit 2e36fcf

Please sign in to comment.