From a2a858262af4cdefc5279cacdd9abd96111f82d1 Mon Sep 17 00:00:00 2001 From: thomas girod Date: Tue, 10 Sep 2024 22:55:39 +0200 Subject: [PATCH] apply review comments --- core/static/core/js/sith-select2.js | 6 +++++- core/static/{core => vendored}/select2/select2.min.css | 0 core/static/{core => vendored}/select2/select2.min.js | 0 core/templates/core/base.jinja | 4 ++-- sas/static/sas/js/{picture.js => viewer.js} | 9 ++++----- sas/templates/sas/picture.jinja | 2 +- 6 files changed, 12 insertions(+), 9 deletions(-) rename core/static/{core => vendored}/select2/select2.min.css (100%) rename core/static/{core => vendored}/select2/select2.min.js (100%) rename sas/static/sas/js/{picture.js => viewer.js} (98%) diff --git a/core/static/core/js/sith-select2.js b/core/static/core/js/sith-select2.js index 1af9b111..58d801b0 100644 --- a/core/static/core/js/sith-select2.js +++ b/core/static/core/js/sith-select2.js @@ -246,7 +246,11 @@ function select_item_builder(picture_getter) { const picture = typeof picture_getter === "function" ? picture_getter(item) : null; const img_html = picture - ? `item.text` + ? `${item.text}` : ""; return $(`
diff --git a/core/static/core/select2/select2.min.css b/core/static/vendored/select2/select2.min.css similarity index 100% rename from core/static/core/select2/select2.min.css rename to core/static/vendored/select2/select2.min.css diff --git a/core/static/core/select2/select2.min.js b/core/static/vendored/select2/select2.min.js similarity index 100% rename from core/static/core/select2/select2.min.js rename to core/static/vendored/select2/select2.min.js diff --git a/core/templates/core/base.jinja b/core/templates/core/base.jinja index 20f7c644..f49aa302 100644 --- a/core/templates/core/base.jinja +++ b/core/templates/core/base.jinja @@ -11,7 +11,7 @@ - + {% block jquery_css %} {# Thile file is quite heavy (around 250kb), so declaring it in a block allows easy removal #} @@ -25,7 +25,7 @@ - + diff --git a/sas/static/sas/js/picture.js b/sas/static/sas/js/viewer.js similarity index 98% rename from sas/static/sas/js/picture.js rename to sas/static/sas/js/viewer.js index 0b1f714c..017aee1a 100644 --- a/sas/static/sas/js/picture.js +++ b/sas/static/sas/js/viewer.js @@ -4,7 +4,6 @@ * @property {UserProfile} user The identified user */ - document.addEventListener("alpine:init", () => { Alpine.data("picture_viewer", () => ({ /** @@ -79,7 +78,7 @@ document.addEventListener("alpine:init", () => { ); this.$watch("current_picture", () => this.update_picture()); window.addEventListener("popstate", async (event) => { - if (!event.state || event.state.sas_picture_id === undefined){ + if (!event.state || event.state.sas_picture_id === undefined) { return; } this.pushstate = History.REPLACE; @@ -103,11 +102,11 @@ document.addEventListener("alpine:init", () => { this.loading = true; const update_args = [ - {sas_picture_id: this.current_picture.id}, + { sas_picture_id: this.current_picture.id }, "", `/sas/picture/${this.current_picture.id}/`, ]; - if (this.pushstate === History.REPLACE){ + if (this.pushstate === History.REPLACE) { window.history.replaceState(...update_args); this.pushstate = History.PUSH; } else { @@ -141,7 +140,7 @@ document.addEventListener("alpine:init", () => { }, async delete_picture() { - const res = await fetch(`/api/sas/picture/${this.current_picture}/`, { + const res = await fetch(`/api/sas/picture/${this.current_picture.id}/`, { method: "DELETE", }); if (!res.ok) { diff --git a/sas/templates/sas/picture.jinja b/sas/templates/sas/picture.jinja index 7d1538bc..62d069d8 100644 --- a/sas/templates/sas/picture.jinja +++ b/sas/templates/sas/picture.jinja @@ -5,7 +5,7 @@ {%- endblock -%} {%- block additional_js -%} - + {%- endblock -%} {% block title %}