mirror of
				https://github.com/ae-utbm/sith.git
				synced 2025-11-04 11:03:04 +00:00 
			
		
		
		
	apply review comments
This commit is contained in:
		@@ -246,7 +246,11 @@ function select_item_builder(picture_getter) {
 | 
				
			|||||||
    const picture =
 | 
					    const picture =
 | 
				
			||||||
      typeof picture_getter === "function" ? picture_getter(item) : null;
 | 
					      typeof picture_getter === "function" ? picture_getter(item) : null;
 | 
				
			||||||
    const img_html = picture
 | 
					    const img_html = picture
 | 
				
			||||||
      ? `<img src="${picture_getter(item)}" alt="item.text"/>`
 | 
					      ? `<img 
 | 
				
			||||||
 | 
					          src="${picture_getter(item)}" 
 | 
				
			||||||
 | 
					          alt="${item.text}" 
 | 
				
			||||||
 | 
					          onerror="this.src = '/static/core/img/unknown.jpg'" 
 | 
				
			||||||
 | 
					        />`
 | 
				
			||||||
      : "";
 | 
					      : "";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return $(`<div class="select-item">
 | 
					    return $(`<div class="select-item">
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -11,7 +11,7 @@
 | 
				
			|||||||
      <link rel="stylesheet" href="{{ scss('core/markdown.scss') }}">
 | 
					      <link rel="stylesheet" href="{{ scss('core/markdown.scss') }}">
 | 
				
			||||||
      <link rel="stylesheet" href="{{ scss('core/header.scss') }}">
 | 
					      <link rel="stylesheet" href="{{ scss('core/header.scss') }}">
 | 
				
			||||||
      <link rel="stylesheet" href="{{ scss('core/navbar.scss') }}">
 | 
					      <link rel="stylesheet" href="{{ scss('core/navbar.scss') }}">
 | 
				
			||||||
      <link rel="stylesheet" href="{{ static('core/select2/select2.min.css') }}">
 | 
					      <link rel="stylesheet" href="{{ static('vendored/select2/select2.min.css') }}">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      {% block jquery_css %}
 | 
					      {% block jquery_css %}
 | 
				
			||||||
                {# Thile file is quite heavy (around 250kb), so declaring it in a block allows easy removal #}
 | 
					                {# Thile file is quite heavy (around 250kb), so declaring it in a block allows easy removal #}
 | 
				
			||||||
@@ -25,7 +25,7 @@
 | 
				
			|||||||
      <script src="{{ static('vendored/jquery/jquery-3.6.2.min.js') }}"></script>
 | 
					      <script src="{{ static('vendored/jquery/jquery-3.6.2.min.js') }}"></script>
 | 
				
			||||||
            <!-- Put here to always have acces to those functions on django widgets -->
 | 
					            <!-- Put here to always have acces to those functions on django widgets -->
 | 
				
			||||||
      <script src="{{ static('core/js/script.js') }}"></script>
 | 
					      <script src="{{ static('core/js/script.js') }}"></script>
 | 
				
			||||||
      <script defer src="{{ static('core/select2/select2.min.js') }}"></script>
 | 
					      <script defer src="{{ static('vendored/select2/select2.min.js') }}"></script>
 | 
				
			||||||
      <script defer src="{{ static('core/js/sith-select2.js') }}"></script>
 | 
					      <script defer src="{{ static('core/js/sith-select2.js') }}"></script>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,7 +4,6 @@
 | 
				
			|||||||
 * @property {UserProfile} user The identified user
 | 
					 * @property {UserProfile} user The identified user
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
document.addEventListener("alpine:init", () => {
 | 
					document.addEventListener("alpine:init", () => {
 | 
				
			||||||
  Alpine.data("picture_viewer", () => ({
 | 
					  Alpine.data("picture_viewer", () => ({
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@@ -79,7 +78,7 @@ document.addEventListener("alpine:init", () => {
 | 
				
			|||||||
      );
 | 
					      );
 | 
				
			||||||
      this.$watch("current_picture", () => this.update_picture());
 | 
					      this.$watch("current_picture", () => this.update_picture());
 | 
				
			||||||
      window.addEventListener("popstate", async (event) => {
 | 
					      window.addEventListener("popstate", async (event) => {
 | 
				
			||||||
        if (!event.state || event.state.sas_picture_id === undefined){
 | 
					        if (!event.state || event.state.sas_picture_id === undefined) {
 | 
				
			||||||
          return;
 | 
					          return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        this.pushstate = History.REPLACE;
 | 
					        this.pushstate = History.REPLACE;
 | 
				
			||||||
@@ -103,11 +102,11 @@ document.addEventListener("alpine:init", () => {
 | 
				
			|||||||
      this.loading = true;
 | 
					      this.loading = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      const update_args = [
 | 
					      const update_args = [
 | 
				
			||||||
        {sas_picture_id: this.current_picture.id},
 | 
					        { sas_picture_id: this.current_picture.id },
 | 
				
			||||||
        "",
 | 
					        "",
 | 
				
			||||||
        `/sas/picture/${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);
 | 
					        window.history.replaceState(...update_args);
 | 
				
			||||||
        this.pushstate = History.PUSH;
 | 
					        this.pushstate = History.PUSH;
 | 
				
			||||||
      } else {
 | 
					      } else {
 | 
				
			||||||
@@ -141,7 +140,7 @@ document.addEventListener("alpine:init", () => {
 | 
				
			|||||||
    },
 | 
					    },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    async delete_picture() {
 | 
					    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",
 | 
					        method: "DELETE",
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
      if (!res.ok) {
 | 
					      if (!res.ok) {
 | 
				
			||||||
@@ -5,7 +5,7 @@
 | 
				
			|||||||
{%- endblock -%}
 | 
					{%- endblock -%}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
{%- block additional_js -%}
 | 
					{%- block additional_js -%}
 | 
				
			||||||
  <script defer src="{{ static("sas/js/picture.js") }}"></script>
 | 
					  <script defer src="{{ static("sas/js/viewer.js") }}"></script>
 | 
				
			||||||
{%- endblock -%}
 | 
					{%- endblock -%}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
{% block title %}
 | 
					{% block title %}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user