2023-11-14 20:09:43 +00:00
|
|
|
import {
|
|
|
|
syncSelectInputUntilChanged,
|
|
|
|
getEl,
|
|
|
|
disableElementsWhenTrue,
|
|
|
|
disableElementsWhenFalse,
|
|
|
|
} from "./utils.js";
|
2023-11-09 13:49:00 +00:00
|
|
|
|
|
|
|
let syncData = [
|
|
|
|
{
|
2023-11-14 18:27:00 +00:00
|
|
|
source: "#id_edition",
|
|
|
|
source_value: "dataset.platform",
|
|
|
|
target: "#id_platform",
|
|
|
|
target_value: "value",
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
syncSelectInputUntilChanged(syncData, "form");
|
|
|
|
|
2023-11-14 20:09:43 +00:00
|
|
|
function setupElementHandlers() {
|
|
|
|
disableElementsWhenTrue("#id_type", "game", [
|
|
|
|
"#id_name",
|
|
|
|
"#id_related_purchase",
|
|
|
|
]);
|
|
|
|
disableElementsWhenFalse("#id_type", "game", ["#id_date_finished"]);
|
|
|
|
}
|
2023-11-14 18:27:00 +00:00
|
|
|
|
2023-11-14 20:09:43 +00:00
|
|
|
document.addEventListener("DOMContentLoaded", setupElementHandlers);
|
2023-11-16 18:03:16 +00:00
|
|
|
document.addEventListener("htmx:afterSwap", setupElementHandlers);
|
2023-11-14 18:27:00 +00:00
|
|
|
getEl("#id_type").onchange = () => {
|
2023-11-14 20:09:43 +00:00
|
|
|
setupElementHandlers();
|
|
|
|
};
|