fix family graph image exension

This commit is contained in:
thomas girod 2024-09-19 20:52:10 +02:00
parent 27443bcd21
commit d3cada4c95

View File

@ -77,11 +77,11 @@ function create_graph(container, data, active_user_id) {
fit: true, fit: true,
klay: { klay: {
addUnnecessaryBendpoints: true, addUnnecessaryBendpoints: true,
direction: 'DOWN', direction: "DOWN",
nodePlacement: 'INTERACTIVE', nodePlacement: "INTERACTIVE",
layoutHierarchy: true layoutHierarchy: true,
} },
} },
}); });
let active_user = cy let active_user = cy
.getElementById(active_user_id) .getElementById(active_user_id)
@ -178,7 +178,9 @@ document.addEventListener("alpine:init", () => {
typeof depth_min === "undefined" || typeof depth_min === "undefined" ||
typeof depth_max === "undefined" typeof depth_max === "undefined"
) { ) {
console.error("Some constants are not set before using the family_graph script, please look at the documentation"); console.error(
"Some constants are not set before using the family_graph script, please look at the documentation",
);
return; return;
} }
@ -194,7 +196,7 @@ document.addEventListener("alpine:init", () => {
loading: false, loading: false,
godfathers_depth: get_initial_depth("godfathers_depth"), godfathers_depth: get_initial_depth("godfathers_depth"),
godchildren_depth: get_initial_depth("godchildren_depth"), godchildren_depth: get_initial_depth("godchildren_depth"),
reverse: initialUrlParams.get("reverse")?.toLowerCase?.() === 'true', reverse: initialUrlParams.get("reverse")?.toLowerCase?.() === "true",
graph: undefined, graph: undefined,
graph_data: {}, graph_data: {},
@ -227,7 +229,11 @@ document.addEventListener("alpine:init", () => {
async screenshot() { async screenshot() {
const link = document.createElement("a"); const link = document.createElement("a");
link.href = this.graph.jpg(); link.href = this.graph.jpg();
link.download = gettext("family_tree.%(extension)s", "jpg"); link.download = interpolate(
gettext("family_tree.%(extension)s"),
{ extension: "jpg" },
true,
);
document.body.appendChild(link); document.body.appendChild(link);
link.click(); link.click();
document.body.removeChild(link); document.body.removeChild(link);