Skip to content

Commit

Permalink
Fix 'vissible after start time' when creating series
Browse files Browse the repository at this point in the history
  • Loading branch information
jorg-vr committed Jun 12, 2024
1 parent aa4afa5 commit 4429524
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
33 changes: 20 additions & 13 deletions app/assets/javascripts/series.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,25 @@ const DRAG_AND_DROP_ARGS = {
},
};

function initSeriesForm(): void {
function init(): void {
initTimedVisibility();

Check warning on line 24 in app/assets/javascripts/series.ts

View check run for this annotation

Codecov / codecov/patch

app/assets/javascripts/series.ts#L22-L24

Added lines #L22 - L24 were not covered by tests
}

function initTimedVisibility(): void {
const timedVisibilityOption = document.getElementById("series_visibility_timed") as HTMLInputElement;
const timingOptions = document.getElementById("timing-options");
const visibilityOptions = document.querySelectorAll("[name=\"series[visibility]\"]");
visibilityOptions.forEach( option => {
option.addEventListener("change", () => {
timingOptions.classList.toggle("visually-hidden", !timedVisibilityOption.checked);

Check warning on line 33 in app/assets/javascripts/series.ts

View check run for this annotation

Codecov / codecov/patch

app/assets/javascripts/series.ts#L27-L33

Added lines #L27 - L33 were not covered by tests
});
});
}

init();

Check warning on line 38 in app/assets/javascripts/series.ts

View check run for this annotation

Codecov / codecov/patch

app/assets/javascripts/series.ts#L38

Added line #L38 was not covered by tests
}

function initSeriesEdit(): void {
function init(): void {
initAddButtons();
Expand All @@ -28,7 +47,6 @@ function initSeriesEdit(): void {
dodona.seriesEditActivitiesLoaded = () => {
initAddButtons();
};
initTimedVisibility();
}

function initAddButtons(): void {
Expand Down Expand Up @@ -151,17 +169,6 @@ function initSeriesEdit(): void {
document.getElementById("to-many-activities-info").classList.toggle("d-none", count <= 10);
}

function initTimedVisibility(): void {
const timedVisibilityOption = document.getElementById("series_visibility_timed") as HTMLInputElement;
const timingOptions = document.getElementById("timing-options");
const visibilityOptions = document.querySelectorAll("[name=\"series[visibility]\"]");
visibilityOptions.forEach( option => {
option.addEventListener("change", () => {
timingOptions.classList.toggle("visually-hidden", !timedVisibilityOption.checked);
});
});
}

init();
}

Expand Down Expand Up @@ -190,4 +197,4 @@ function initSeriesShow(id: string): void {
});
}

export { initSeriesEdit, initSeriesShow };
export { initSeriesEdit, initSeriesShow, initSeriesForm };

Check warning on line 200 in app/assets/javascripts/series.ts

View check run for this annotation

Codecov / codecov/patch

app/assets/javascripts/series.ts#L200

Added line #L200 was not covered by tests
3 changes: 2 additions & 1 deletion app/javascript/packs/series.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { initSeriesEdit, initSeriesShow } from "series.ts";
import { initSeriesEdit, initSeriesShow, initSeriesForm } from "series.ts";
import { initDatePicker } from "utilities.ts";

window.dodona.initDeadlinePicker = initDatePicker;
window.dodona.initSeriesEdit = initSeriesEdit;
window.dodona.initSeriesShow = initSeriesShow;
window.dodona.initSeriesForm = initSeriesForm;
1 change: 1 addition & 0 deletions app/views/series/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,6 @@
dodona.ready.then(function () {
dodona.initDeadlinePicker("#deadline-group");
dodona.initDeadlinePicker("#start-group");
dodona.initSeriesForm();
});
</script>

0 comments on commit 4429524

Please sign in to comment.