mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-10 03:49:24 +00:00
introduce djhtml as jinja+scss formater
This commit is contained in:
committed by
Bartuccio Antoine
parent
13d0d2a300
commit
b25805e0a1
@ -2,139 +2,139 @@
|
||||
{% extends "core/base.jinja" %}
|
||||
|
||||
{% block title %}
|
||||
{% trans %}UV Guide{% endtrans %}
|
||||
{% trans %}UV Guide{% endtrans %}
|
||||
{% endblock %}
|
||||
|
||||
{% block additional_js %}
|
||||
<script src="{{ static('core/js/alpinejs.min.js') }}" defer></script>
|
||||
<script src="{{ static('core/js/alpinejs.min.js') }}" defer></script>
|
||||
{% endblock %}
|
||||
|
||||
{% block head %}
|
||||
{{ super() }}
|
||||
<meta name="viewport" content="width=device-width, initial-scale=0.6, maximum-scale=2">
|
||||
{{ super() }}
|
||||
<meta name="viewport" content="width=device-width, initial-scale=0.6, maximum-scale=2">
|
||||
{% endblock head %}
|
||||
|
||||
{% block content %}
|
||||
{% if can_create_uv %}
|
||||
<div class="action-bar">
|
||||
<p>
|
||||
{% if can_create_uv %}
|
||||
<div class="action-bar">
|
||||
<p>
|
||||
<a href="{{ url('pedagogy:uv_create') }}">{% trans %}Create UV{% endtrans %}</a>
|
||||
</p>
|
||||
<p>
|
||||
</p>
|
||||
<p>
|
||||
<a href="{{ url('pedagogy:moderation') }}">{% trans %}Moderate comments{% endtrans %}</a>
|
||||
</p>
|
||||
</p>
|
||||
</div>
|
||||
<br/>
|
||||
{% endif %}
|
||||
<div class="pedagogy" x-data="uv_search" x-cloak>
|
||||
<form id="search_form">
|
||||
<div class="search-form-container">
|
||||
<div class="search-bar">
|
||||
<input
|
||||
id="search_input"
|
||||
class="search-bar-input"
|
||||
type="text"
|
||||
name="search"
|
||||
x-model.debounce.500ms="search"
|
||||
/>
|
||||
</div>
|
||||
<div class="radio-department">
|
||||
<div class="radio-guide">
|
||||
{% for (display_name, real_name) in [
|
||||
("EDIM", "EDIM"), ("ENERGIE", "EE"), ("IMSI", "IMSI"),
|
||||
("INFO", "GI"), ("GMC", "MC"), ("HUMA", "HUMA"), ("TC", "TC")
|
||||
] %}
|
||||
<input
|
||||
type="checkbox"
|
||||
name="department"
|
||||
id="radio{{ real_name }}"
|
||||
value="{{ real_name }}"
|
||||
x-model="department"
|
||||
/>
|
||||
<label for="radio{{ real_name }}">{% trans %}{{ display_name }}{% endtrans %}</label>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="radio-credit-type">
|
||||
<div class="radio-guide">
|
||||
{% for credit_type in ["CS", "TM", "EC", "QC", "OM"] %}
|
||||
<input
|
||||
type="checkbox"
|
||||
name="credit_type"
|
||||
id="radio{{ credit_type }}"
|
||||
value="{{ credit_type }}"
|
||||
x-model="credit_type"
|
||||
/>
|
||||
<label for="radio{{ credit_type }}">{% trans %}{{ credit_type }}{% endtrans %}</label>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
<br/>
|
||||
{% endif %}
|
||||
<div class="pedagogy" x-data="uv_search" x-cloak>
|
||||
<form id="search_form">
|
||||
<div class="search-form-container">
|
||||
<div class="search-bar">
|
||||
<input
|
||||
id="search_input"
|
||||
class="search-bar-input"
|
||||
type="text"
|
||||
name="search"
|
||||
x-model.debounce.500ms="search"
|
||||
/>
|
||||
</div>
|
||||
<div class="radio-department">
|
||||
<div class="radio-guide">
|
||||
{% for (display_name, real_name) in [
|
||||
("EDIM", "EDIM"), ("ENERGIE", "EE"), ("IMSI", "IMSI"),
|
||||
("INFO", "GI"), ("GMC", "MC"), ("HUMA", "HUMA"), ("TC", "TC")
|
||||
] %}
|
||||
<input
|
||||
type="checkbox"
|
||||
name="department"
|
||||
id="radio{{ real_name }}"
|
||||
value="{{ real_name }}"
|
||||
x-model="department"
|
||||
/>
|
||||
<label for="radio{{ real_name }}">{% trans %}{{ display_name }}{% endtrans %}</label>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="radio-credit-type">
|
||||
<div class="radio-guide">
|
||||
{% for credit_type in ["CS", "TM", "EC", "QC", "OM"] %}
|
||||
<input
|
||||
type="checkbox"
|
||||
name="credit_type"
|
||||
id="radio{{ credit_type }}"
|
||||
value="{{ credit_type }}"
|
||||
x-model="credit_type"
|
||||
/>
|
||||
<label for="radio{{ credit_type }}">{% trans %}{{ credit_type }}{% endtrans %}</label>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="radio-semester">
|
||||
<div class="radio-guide">
|
||||
<input type="checkbox" name="semester" id="radioAUTUMN" value="AUTUMN" x-model="semester"/>
|
||||
<label for="radioAUTUMN"><i class="fa fa-leaf"></i></label>
|
||||
<input type="checkbox" name="semester" id="radioSPRING" value="SPRING" x-model="semester"/>
|
||||
<label for="radioSPRING"><i class="fa fa-sun-o"></i></label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<table id="dynamic_view">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>{% trans %}UV{% endtrans %}</td>
|
||||
<td>{% trans %}Title{% endtrans %}</td>
|
||||
<td>{% trans %}Department{% endtrans %}</td>
|
||||
<td>{% trans %}Credit type{% endtrans %}</td>
|
||||
<td><i class="fa fa-leaf"></i></td>
|
||||
<td><i class="fa fa-sun-o"></i></td>
|
||||
{% if can_create_uv %}
|
||||
<td>{% trans %}Edit{% endtrans %}</td>
|
||||
<td>{% trans %}Delete{% endtrans %}</td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="dynamic_view_content">
|
||||
<template x-for="uv in uvs.results" :key="uv.id">
|
||||
<tr @click="window.location.href = `/pedagogy/uv/${uv.id}`">
|
||||
<td><a :href="`/pedagogy/uv/${uv.id}`" x-text="uv.code"></a></td>
|
||||
<td x-text="uv.title"></td>
|
||||
<td x-text="uv.department"></td>
|
||||
<td x-text="uv.credit_type"></td>
|
||||
<td><i :class="uv.semester.includes('AUTUMN') && 'fa fa-leaf'"></i></td>
|
||||
<td><i :class="uv.semester.includes('SPRING') && 'fa fa-sun-o'"></i></td>
|
||||
{% if can_create_uv -%}
|
||||
<td><a :href="`/pedagogy/uv/${uv.id}/edit`">{% trans %}Edit{% endtrans %}</a></td>
|
||||
<td><a :href="`/pedagogy/uv/${uv.id}/delete`">{% trans %}Delete{% endtrans %}</a></td>
|
||||
{%- endif -%}
|
||||
</tr>
|
||||
</template>
|
||||
</tbody>
|
||||
</table>
|
||||
<nav id="pagination" class="hidden" :style="max_page() == 0 && 'display: none;'">
|
||||
<button @click="page--" :disabled="page == 1">{% trans %}Previous{% endtrans %}</button>
|
||||
<template x-for="i in max_page()">
|
||||
<button x-text="i" @click="page = i" :class="i == page && 'active'"></button>
|
||||
</template>
|
||||
<button @click="page++" :disabled="page == max_page()">{% trans %}Next{% endtrans %}</button>
|
||||
</nav>
|
||||
<div class="radio-semester">
|
||||
<div class="radio-guide">
|
||||
<input type="checkbox" name="semester" id="radioAUTUMN" value="AUTUMN" x-model="semester"/>
|
||||
<label for="radioAUTUMN"><i class="fa fa-leaf"></i></label>
|
||||
<input type="checkbox" name="semester" id="radioSPRING" value="SPRING" x-model="semester"/>
|
||||
<label for="radioSPRING"><i class="fa fa-sun-o"></i></label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<table id="dynamic_view">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>{% trans %}UV{% endtrans %}</td>
|
||||
<td>{% trans %}Title{% endtrans %}</td>
|
||||
<td>{% trans %}Department{% endtrans %}</td>
|
||||
<td>{% trans %}Credit type{% endtrans %}</td>
|
||||
<td><i class="fa fa-leaf"></i></td>
|
||||
<td><i class="fa fa-sun-o"></i></td>
|
||||
{% if can_create_uv %}
|
||||
<td>{% trans %}Edit{% endtrans %}</td>
|
||||
<td>{% trans %}Delete{% endtrans %}</td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="dynamic_view_content">
|
||||
<template x-for="uv in uvs.results" :key="uv.id">
|
||||
<tr @click="window.location.href = `/pedagogy/uv/${uv.id}`">
|
||||
<td><a :href="`/pedagogy/uv/${uv.id}`" x-text="uv.code"></a></td>
|
||||
<td x-text="uv.title"></td>
|
||||
<td x-text="uv.department"></td>
|
||||
<td x-text="uv.credit_type"></td>
|
||||
<td><i :class="uv.semester.includes('AUTUMN') && 'fa fa-leaf'"></i></td>
|
||||
<td><i :class="uv.semester.includes('SPRING') && 'fa fa-sun-o'"></i></td>
|
||||
{% if can_create_uv -%}
|
||||
<td><a :href="`/pedagogy/uv/${uv.id}/edit`">{% trans %}Edit{% endtrans %}</a></td>
|
||||
<td><a :href="`/pedagogy/uv/${uv.id}/delete`">{% trans %}Delete{% endtrans %}</a></td>
|
||||
{%- endif -%}
|
||||
</tr>
|
||||
</template>
|
||||
</tbody>
|
||||
</table>
|
||||
<nav id="pagination" class="hidden" :style="max_page() == 0 && 'display: none;'">
|
||||
<button @click="page--" :disabled="page == 1">{% trans %}Previous{% endtrans %}</button>
|
||||
<template x-for="i in max_page()">
|
||||
<button x-text="i" @click="page = i" :class="i == page && 'active'"></button>
|
||||
</template>
|
||||
<button @click="page++" :disabled="page == max_page()">{% trans %}Next{% endtrans %}</button>
|
||||
</nav>
|
||||
</div>
|
||||
<script>
|
||||
const initialUrlParams = new URLSearchParams(window.location.search);
|
||||
const initialUrlParams = new URLSearchParams(window.location.search);
|
||||
|
||||
function update_query_string(key, value) {
|
||||
const url = new URL(window.location.href);
|
||||
if (!value) {
|
||||
url.searchParams.delete(key)
|
||||
} else if (Array.isArray(value)) {
|
||||
url.searchParams.delete(key)
|
||||
value.forEach((v) => url.searchParams.append(key, v))
|
||||
} else {
|
||||
url.searchParams.set(key, value);
|
||||
}
|
||||
history.pushState(null, document.title, url.toString());
|
||||
function update_query_string(key, value) {
|
||||
const url = new URL(window.location.href);
|
||||
if (!value) {
|
||||
url.searchParams.delete(key)
|
||||
} else if (Array.isArray(value)) {
|
||||
url.searchParams.delete(key)
|
||||
value.forEach((v) => url.searchParams.append(key, v))
|
||||
} else {
|
||||
url.searchParams.set(key, value);
|
||||
}
|
||||
history.pushState(null, document.title, url.toString());
|
||||
}
|
||||
|
||||
{#
|
||||
How does this work :
|
||||
@ -145,50 +145,50 @@
|
||||
then fetch the corresponding data from the API.
|
||||
This data will then be displayed on the result part of the page.
|
||||
#}
|
||||
const page_default = 1;
|
||||
const page_size_default = 100;
|
||||
document.addEventListener("alpine:init", () => {
|
||||
Alpine.data("uv_search", () => ({
|
||||
uvs: [],
|
||||
page: initialUrlParams.get("page") || page_default,
|
||||
page_size: initialUrlParams.get("page_size") || page_size_default,
|
||||
search: initialUrlParams.get("search") || "",
|
||||
department: initialUrlParams.getAll("department"),
|
||||
credit_type: initialUrlParams.getAll("credit_type"),
|
||||
const page_default = 1;
|
||||
const page_size_default = 100;
|
||||
document.addEventListener("alpine:init", () => {
|
||||
Alpine.data("uv_search", () => ({
|
||||
uvs: [],
|
||||
page: initialUrlParams.get("page") || page_default,
|
||||
page_size: initialUrlParams.get("page_size") || page_size_default,
|
||||
search: initialUrlParams.get("search") || "",
|
||||
department: initialUrlParams.getAll("department"),
|
||||
credit_type: initialUrlParams.getAll("credit_type"),
|
||||
{# The semester is easier to use on the backend as an enum (spring/autumn/both/none)
|
||||
and easier to use on the frontend as an array ([spring, autumn]).
|
||||
Thus there is some conversion involved when both communicate together #}
|
||||
semester: initialUrlParams.has("semester") ?
|
||||
initialUrlParams.get("semester").split("_AND_") : [],
|
||||
semester: initialUrlParams.has("semester") ?
|
||||
initialUrlParams.get("semester").split("_AND_") : [],
|
||||
|
||||
async init() {
|
||||
let search_params = ["search", "department", "credit_type", "semester"];
|
||||
let pagination_params = ["semester", "page"];
|
||||
search_params.forEach((param) => {
|
||||
this.$watch(param, async () => {
|
||||
async init() {
|
||||
let search_params = ["search", "department", "credit_type", "semester"];
|
||||
let pagination_params = ["semester", "page"];
|
||||
search_params.forEach((param) => {
|
||||
this.$watch(param, async () => {
|
||||
{# Reset pagination on search #}
|
||||
this.page = page_default;
|
||||
this.page_size = page_size_default;
|
||||
});
|
||||
});
|
||||
search_params.concat(pagination_params).forEach((param) => {
|
||||
this.$watch(param, async (value) => {
|
||||
update_query_string(param, value);
|
||||
await this.fetch_data(); {# reload data on form change #}
|
||||
});
|
||||
});
|
||||
await this.fetch_data(); {# load initial data #}
|
||||
},
|
||||
this.page = page_default;
|
||||
this.page_size = page_size_default;
|
||||
});
|
||||
});
|
||||
search_params.concat(pagination_params).forEach((param) => {
|
||||
this.$watch(param, async (value) => {
|
||||
update_query_string(param, value);
|
||||
await this.fetch_data(); {# reload data on form change #}
|
||||
});
|
||||
});
|
||||
await this.fetch_data(); {# load initial data #}
|
||||
},
|
||||
|
||||
async fetch_data() {
|
||||
const url = "{{ url("api:fetch_uvs") }}" + window.location.search;
|
||||
this.uvs = await (await fetch(url)).json();
|
||||
},
|
||||
async fetch_data() {
|
||||
const url = "{{ url("api:fetch_uvs") }}" + window.location.search;
|
||||
this.uvs = await (await fetch(url)).json();
|
||||
},
|
||||
|
||||
max_page() {
|
||||
return Math.round(this.uvs.count / this.page_size);
|
||||
}
|
||||
}))
|
||||
})
|
||||
max_page() {
|
||||
return Math.round(this.uvs.count / this.page_size);
|
||||
}
|
||||
}))
|
||||
})
|
||||
</script>
|
||||
{% endblock content %}
|
@ -1,16 +1,16 @@
|
||||
{% macro display_star(grade) -%}
|
||||
|
||||
{% if grade >= 0 %}
|
||||
{% for i in range(5) %}
|
||||
{% if i <= grade %}
|
||||
<span class="fa fa-star pedagogy star-checked grade-with-star"></span>
|
||||
{% else %}
|
||||
<span class="fa fa-star pedagogy star-not-checked grade-with-star"></span>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
<span class="pedagogy grade-without-star">{{ grade }}/5</span>
|
||||
{% else %}
|
||||
<span class="grade-text"> {% trans %} not rated {% endtrans %} </span>
|
||||
{% endif %}
|
||||
{% if grade >= 0 %}
|
||||
{% for i in range(5) %}
|
||||
{% if i <= grade %}
|
||||
<span class="fa fa-star pedagogy star-checked grade-with-star"></span>
|
||||
{% else %}
|
||||
<span class="fa fa-star pedagogy star-not-checked grade-with-star"></span>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
<span class="pedagogy grade-without-star">{{ grade }}/5</span>
|
||||
{% else %}
|
||||
<span class="grade-text"> {% trans %} not rated {% endtrans %} </span>
|
||||
{% endif %}
|
||||
|
||||
{%- endmacro %}
|
@ -1,37 +1,37 @@
|
||||
{% extends "core/base.jinja" %}
|
||||
|
||||
{% block title %}
|
||||
{% trans %}UV comment moderation{% endtrans %}
|
||||
{% trans %}UV comment moderation{% endtrans %}
|
||||
{% endblock title %}
|
||||
|
||||
{% block content %}
|
||||
{{ form.errors }}
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<td>{% trans %}UV{% endtrans %}</td>
|
||||
<td>{% trans %}Comment{% endtrans %}</td>
|
||||
<td>{% trans %}Reason{% endtrans %}</td>
|
||||
<td>{% trans %}Action{% endtrans %}</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% set queryset = form.accepted_reports.field.queryset %}
|
||||
{% for widget in form.accepted_reports.subwidgets %}
|
||||
{% set report = queryset.get(id=widget.data.value.value) %}
|
||||
<form action="{{ url('pedagogy:moderation') }}" method="post" enctype="multipart/form-data">
|
||||
{% csrf_token %}
|
||||
<tr>
|
||||
<td><a href="{{ url('pedagogy:uv_detail', uv_id=report.comment.uv.id) }}#{{ report.comment.uv.id }}">{{ report.comment.uv }}</a></td>
|
||||
<td>{{ report.comment.comment|markdown }}</td>
|
||||
<td>{{ report.reason|markdown }}</td>
|
||||
<td>
|
||||
<button name="accepted_reports" type="submit" value="{{ report.id }}">{% trans %}Delete comment{% endtrans %}</button>
|
||||
<button name="denied_reports" type="submit" value="{{ report.id }}">{% trans %}Delete report{% endtrans %}</button>
|
||||
</td>
|
||||
</tr>
|
||||
</form>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{{ form.errors }}
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<td>{% trans %}UV{% endtrans %}</td>
|
||||
<td>{% trans %}Comment{% endtrans %}</td>
|
||||
<td>{% trans %}Reason{% endtrans %}</td>
|
||||
<td>{% trans %}Action{% endtrans %}</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% set queryset = form.accepted_reports.field.queryset %}
|
||||
{% for widget in form.accepted_reports.subwidgets %}
|
||||
{% set report = queryset.get(id=widget.data.value.value) %}
|
||||
<form action="{{ url('pedagogy:moderation') }}" method="post" enctype="multipart/form-data">
|
||||
{% csrf_token %}
|
||||
<tr>
|
||||
<td><a href="{{ url('pedagogy:uv_detail', uv_id=report.comment.uv.id) }}#{{ report.comment.uv.id }}">{{ report.comment.uv }}</a></td>
|
||||
<td>{{ report.comment.comment|markdown }}</td>
|
||||
<td>{{ report.reason|markdown }}</td>
|
||||
<td>
|
||||
<button name="accepted_reports" type="submit" value="{{ report.id }}">{% trans %}Delete comment{% endtrans %}</button>
|
||||
<button name="denied_reports" type="submit" value="{{ report.id }}">{% trans %}Delete report{% endtrans %}</button>
|
||||
</td>
|
||||
</tr>
|
||||
</form>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% endblock content %}
|
||||
|
@ -1,58 +1,58 @@
|
||||
<div>
|
||||
<style>
|
||||
.checked {
|
||||
color : orange;
|
||||
}
|
||||
.unchecked {
|
||||
color : gray;
|
||||
}
|
||||
.star input[type="radio"] {
|
||||
display : none;
|
||||
}
|
||||
.star {
|
||||
display: inline;
|
||||
}
|
||||
<style>
|
||||
.checked {
|
||||
color : orange;
|
||||
}
|
||||
.unchecked {
|
||||
color : gray;
|
||||
}
|
||||
.star input[type="radio"] {
|
||||
display : none;
|
||||
}
|
||||
.star {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
</style>
|
||||
</style>
|
||||
|
||||
{# Do not vote button #}
|
||||
<label class="star">
|
||||
<input type="radio" name="{{ widget.name }}" value="-1" onclick='
|
||||
var stars = document.getElementsByClassName("{{ widget.name }}");
|
||||
for (var i = 0; i < stars.length; i++){
|
||||
var attrs = stars[i].getAttribute("class");
|
||||
attrs = attrs.replace("unchecked", "");
|
||||
attrs = attrs.replace("checked", "");
|
||||
stars[i].setAttribute("class", attrs + " unchecked");
|
||||
}
|
||||
' checked>
|
||||
<span class="fa fa-times-circle"> {{ translations.do_not_vote }}</span>
|
||||
</label>
|
||||
<label class="star">
|
||||
<input type="radio" name="{{ widget.name }}" value="-1" onclick='
|
||||
var stars = document.getElementsByClassName("{{ widget.name }}");
|
||||
for (var i = 0; i < stars.length; i++){
|
||||
var attrs = stars[i].getAttribute("class");
|
||||
attrs = attrs.replace("unchecked", "");
|
||||
attrs = attrs.replace("checked", "");
|
||||
stars[i].setAttribute("class", attrs + " unchecked");
|
||||
}
|
||||
' checked>
|
||||
<span class="fa fa-times-circle"> {{ translations.do_not_vote }}</span>
|
||||
</label>
|
||||
|
||||
{# Star widget #}
|
||||
{% for i in number_of_stars %}
|
||||
{% for i in number_of_stars %}
|
||||
<label class="star">
|
||||
<input type="radio" name="{{ widget.name }}" value="{{ forloop.counter0 }}" onclick='
|
||||
var stars = document.getElementsByClassName("{{ widget.name }}");
|
||||
<input type="radio" name="{{ widget.name }}" value="{{ forloop.counter0 }}" onclick='
|
||||
var stars = document.getElementsByClassName("{{ widget.name }}");
|
||||
|
||||
for (var i = 0; i < stars.length; i++){
|
||||
var attrs = stars[i].getAttribute("class");
|
||||
attrs = attrs.replace("unchecked", "");
|
||||
attrs = attrs.replace("checked", "");
|
||||
if (i > {{ forloop.counter0 }}){
|
||||
stars[i].setAttribute("class", attrs + " unchecked");
|
||||
} else {
|
||||
stars[i].setAttribute("class", attrs + " checked");
|
||||
}
|
||||
}
|
||||
'>
|
||||
<i class="{{ widget.name }} fa fa-star unchecked"></i>
|
||||
for (var i = 0; i < stars.length; i++){
|
||||
var attrs = stars[i].getAttribute("class");
|
||||
attrs = attrs.replace("unchecked", "");
|
||||
attrs = attrs.replace("checked", "");
|
||||
if (i > {{ forloop.counter0 }}){
|
||||
stars[i].setAttribute("class", attrs + " unchecked");
|
||||
} else {
|
||||
stars[i].setAttribute("class", attrs + " checked");
|
||||
}
|
||||
}
|
||||
'>
|
||||
<i class="{{ widget.name }} fa fa-star unchecked"></i>
|
||||
</label>
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
|
||||
{# Restaure previous (-1 is default) #}
|
||||
<script type="text/javascript">
|
||||
document.querySelector("input[name='{{ widget.name }}'][value='{{ widget.value }}']").click()
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
document.querySelector("input[name='{{ widget.name }}'][value='{{ widget.value }}']").click()
|
||||
</script>
|
||||
|
||||
</div>
|
@ -3,223 +3,223 @@
|
||||
{% from "pedagogy/macros.jinja" import display_star %}
|
||||
|
||||
{% block title %}
|
||||
{% trans %}UV Details{% endtrans %}
|
||||
{% trans %}UV Details{% endtrans %}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="pedagogy">
|
||||
<div id="uv_detail">
|
||||
<p id="return_noscript"><a href="{{ url('pedagogy:guide') }}">{% trans %}Back{% endtrans %}</a></p>
|
||||
<button id="return_js" onclick='(function(){
|
||||
// If comes from the guide page, go back with history
|
||||
if (document.referrer.replace(/\?(.+)/gm,"").endsWith(`{{ url("pedagogy:guide") }}`)){
|
||||
window.history.back();
|
||||
return;
|
||||
}
|
||||
// Simply goes to the guide page
|
||||
window.location.href = `{{ url("pedagogy:guide") }}`;
|
||||
})()' hidden>{% trans %}Back{% endtrans %}</button>
|
||||
<div class="pedagogy">
|
||||
<div id="uv_detail">
|
||||
<p id="return_noscript"><a href="{{ url('pedagogy:guide') }}">{% trans %}Back{% endtrans %}</a></p>
|
||||
<button id="return_js" onclick='(function(){
|
||||
// If comes from the guide page, go back with history
|
||||
if (document.referrer.replace(/\?(.+)/gm,"").endsWith(`{{ url("pedagogy:guide") }}`)){
|
||||
window.history.back();
|
||||
return;
|
||||
}
|
||||
// Simply goes to the guide page
|
||||
window.location.href = `{{ url("pedagogy:guide") }}`;
|
||||
})()' hidden>{% trans %}Back{% endtrans %}</button>
|
||||
|
||||
<h1>{{ object.code }} - {{ object.title }}</h1>
|
||||
<br>
|
||||
<div class="uv-quick-info-container">
|
||||
<div class="hours-cm">
|
||||
<b>{% trans %}CM: {% endtrans %}</b>{{ object.hours_CM }}
|
||||
</div>
|
||||
<div class="hours-td">
|
||||
<b>{% trans %}TD: {% endtrans %}</b>{{ object.hours_TD }}
|
||||
</div>
|
||||
<div class="hours-tp">
|
||||
<b>{% trans %}TP: {% endtrans %}</b>{{ object.hours_TP }}
|
||||
</div>
|
||||
<div class="hours-te">
|
||||
<b>{% trans %}TE: {% endtrans %}</b>{{ object.hours_TE }}
|
||||
</div>
|
||||
<div class="hours-the">
|
||||
<b>{% trans %}THE: {% endtrans %}</b>{{ object.hours_THE }}
|
||||
</div>
|
||||
<h1>{{ object.code }} - {{ object.title }}</h1>
|
||||
<br>
|
||||
<div class="uv-quick-info-container">
|
||||
<div class="hours-cm">
|
||||
<b>{% trans %}CM: {% endtrans %}</b>{{ object.hours_CM }}
|
||||
</div>
|
||||
<div class="hours-td">
|
||||
<b>{% trans %}TD: {% endtrans %}</b>{{ object.hours_TD }}
|
||||
</div>
|
||||
<div class="hours-tp">
|
||||
<b>{% trans %}TP: {% endtrans %}</b>{{ object.hours_TP }}
|
||||
</div>
|
||||
<div class="hours-te">
|
||||
<b>{% trans %}TE: {% endtrans %}</b>{{ object.hours_TE }}
|
||||
</div>
|
||||
<div class="hours-the">
|
||||
<b>{% trans %}THE: {% endtrans %}</b>{{ object.hours_THE }}
|
||||
</div>
|
||||
|
||||
<div class="department">
|
||||
{{ object.department }}
|
||||
</div>
|
||||
<div class="credit-type">
|
||||
{{ object.credit_type }}
|
||||
</div>
|
||||
<div class="semester">
|
||||
{{ object.get_semester_display() }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="department">
|
||||
{{ object.department }}
|
||||
</div>
|
||||
<div class="credit-type">
|
||||
{{ object.credit_type }}
|
||||
</div>
|
||||
<div class="semester">
|
||||
{{ object.get_semester_display() }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
<br>
|
||||
|
||||
<div class="uv-details-container">
|
||||
<div class="grade">
|
||||
<p>{% trans %}Global grade{% endtrans %}</p>
|
||||
<p>{% trans %}Utility{% endtrans %}</p>
|
||||
<p>{% trans %}Interest{% endtrans %}</p>
|
||||
<p>{% trans %}Teaching{% endtrans %}</p>
|
||||
<p>{% trans %}Work load{% endtrans %}</p>
|
||||
</div>
|
||||
<div class="grade-stars">
|
||||
<p>{{ display_star(object.grade_global_average) }}</p>
|
||||
<p>{{ display_star(object.grade_utility_average) }}</p>
|
||||
<p>{{ display_star(object.grade_interest_average) }}</p>
|
||||
<p>{{ display_star(object.grade_teaching_average) }}</p>
|
||||
<p>{{ display_star(object.grade_work_load_average) }}</p>
|
||||
</div>
|
||||
<div class="uv-infos">
|
||||
<p><b>{% trans %}Objectives{% endtrans %}</b></p>
|
||||
<p>{{ object.objectives|markdown }}</p>
|
||||
<p><b>{% trans %}Program{% endtrans %}</b></p>
|
||||
<p>{{ object.program|markdown }}</p>
|
||||
<p><b>{% trans %}Earned skills{% endtrans %}</b></p>
|
||||
<p>{{ object.skills|markdown }}</p>
|
||||
<p><b>{% trans %}Key concepts{% endtrans %}</b></p>
|
||||
<p>{{ object.key_concepts|markdown }}</p>
|
||||
<p><b>{% trans %}UE manager: {% endtrans %}</b>{{ object.manager }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="uv-details-container">
|
||||
<div class="grade">
|
||||
<p>{% trans %}Global grade{% endtrans %}</p>
|
||||
<p>{% trans %}Utility{% endtrans %}</p>
|
||||
<p>{% trans %}Interest{% endtrans %}</p>
|
||||
<p>{% trans %}Teaching{% endtrans %}</p>
|
||||
<p>{% trans %}Work load{% endtrans %}</p>
|
||||
</div>
|
||||
<div class="grade-stars">
|
||||
<p>{{ display_star(object.grade_global_average) }}</p>
|
||||
<p>{{ display_star(object.grade_utility_average) }}</p>
|
||||
<p>{{ display_star(object.grade_interest_average) }}</p>
|
||||
<p>{{ display_star(object.grade_teaching_average) }}</p>
|
||||
<p>{{ display_star(object.grade_work_load_average) }}</p>
|
||||
</div>
|
||||
<div class="uv-infos">
|
||||
<p><b>{% trans %}Objectives{% endtrans %}</b></p>
|
||||
<p>{{ object.objectives|markdown }}</p>
|
||||
<p><b>{% trans %}Program{% endtrans %}</b></p>
|
||||
<p>{{ object.program|markdown }}</p>
|
||||
<p><b>{% trans %}Earned skills{% endtrans %}</b></p>
|
||||
<p>{{ object.skills|markdown }}</p>
|
||||
<p><b>{% trans %}Key concepts{% endtrans %}</b></p>
|
||||
<p>{{ object.key_concepts|markdown }}</p>
|
||||
<p><b>{% trans %}UE manager: {% endtrans %}</b>{{ object.manager }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
{% if object.has_user_already_commented(user) %}
|
||||
<div id="leave_comment_not_allowed">
|
||||
<p>{% trans %}You already posted a comment on this UV. If you want to comment again, please modify or delete your previous comment.{% endtrans %}</p>
|
||||
</div>
|
||||
{% else %}
|
||||
<div id="leave_comment">
|
||||
<h2>{% trans %}Leave comment{% endtrans %}</h2>
|
||||
<div>
|
||||
<form action="{{ url('pedagogy:uv_detail', uv_id=object.id) }}" method="post" enctype="multipart/form-data">
|
||||
{% csrf_token %}
|
||||
<div class="leave-comment-grid-container">
|
||||
<div class="form-stars">
|
||||
{{ form.author.errors }}
|
||||
{{ form.uv.errors }}
|
||||
<br>
|
||||
{% if object.has_user_already_commented(user) %}
|
||||
<div id="leave_comment_not_allowed">
|
||||
<p>{% trans %}You already posted a comment on this UV. If you want to comment again, please modify or delete your previous comment.{% endtrans %}</p>
|
||||
</div>
|
||||
{% else %}
|
||||
<div id="leave_comment">
|
||||
<h2>{% trans %}Leave comment{% endtrans %}</h2>
|
||||
<div>
|
||||
<form action="{{ url('pedagogy:uv_detail', uv_id=object.id) }}" method="post" enctype="multipart/form-data">
|
||||
{% csrf_token %}
|
||||
<div class="leave-comment-grid-container">
|
||||
<div class="form-stars">
|
||||
{{ form.author.errors }}
|
||||
{{ form.uv.errors }}
|
||||
|
||||
{{ form.author }}
|
||||
{{ form.uv }}
|
||||
{{ form.author }}
|
||||
{{ form.uv }}
|
||||
|
||||
<div class="input-stars">
|
||||
<label for="{{ form.grade_global.id_for_label }}">{{ form.grade_global.label }} :</label>
|
||||
{{ form.grade_global.errors }}
|
||||
{{ form.grade_global }}
|
||||
</div>
|
||||
<div class="input-stars">
|
||||
<label for="{{ form.grade_global.id_for_label }}">{{ form.grade_global.label }} :</label>
|
||||
{{ form.grade_global.errors }}
|
||||
{{ form.grade_global }}
|
||||
</div>
|
||||
|
||||
<div class="input-stars">
|
||||
<label for="{{ form.grade_utility.id_for_label }}">{{ form.grade_utility.label }} :</label>
|
||||
{{ form.grade_utility.errors }}
|
||||
{{ form.grade_utility }}
|
||||
</div>
|
||||
<div class="input-stars">
|
||||
<label for="{{ form.grade_utility.id_for_label }}">{{ form.grade_utility.label }} :</label>
|
||||
{{ form.grade_utility.errors }}
|
||||
{{ form.grade_utility }}
|
||||
</div>
|
||||
|
||||
<div class="input-stars">
|
||||
<label for="{{ form.grade_interest.id_for_label }}">{{ form.grade_interest.label }} :</label>
|
||||
{{ form.grade_interest.errors }}
|
||||
{{ form.grade_interest }}
|
||||
</div>
|
||||
<div class="input-stars">
|
||||
<label for="{{ form.grade_interest.id_for_label }}">{{ form.grade_interest.label }} :</label>
|
||||
{{ form.grade_interest.errors }}
|
||||
{{ form.grade_interest }}
|
||||
</div>
|
||||
|
||||
<div class="input-stars">
|
||||
<label for="{{ form.grade_teaching.id_for_label }}">{{ form.grade_teaching.label }} :</label>
|
||||
{{ form.grade_teaching.errors }}
|
||||
{{ form.grade_teaching }}
|
||||
</div>
|
||||
<div class="input-stars">
|
||||
<label for="{{ form.grade_teaching.id_for_label }}">{{ form.grade_teaching.label }} :</label>
|
||||
{{ form.grade_teaching.errors }}
|
||||
{{ form.grade_teaching }}
|
||||
</div>
|
||||
|
||||
<div class="input-stars">
|
||||
<label for="{{ form.grade_work_load.id_for_label }}">{{ form.grade_work_load.label }} :</label>
|
||||
{{ form.grade_work_load.errors }}
|
||||
{{ form.grade_work_load }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-comment">
|
||||
<label for="{{ form.comment.id_for_label }}">{{ form.comment.label }} :</label>
|
||||
{{ form.comment.errors }}
|
||||
{{ form.comment }}
|
||||
</div>
|
||||
</div>
|
||||
<p><input type="submit" value="{% trans %}Comment{% endtrans %}" /></p>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
<br>
|
||||
<div class="input-stars">
|
||||
<label for="{{ form.grade_work_load.id_for_label }}">{{ form.grade_work_load.label }} :</label>
|
||||
{{ form.grade_work_load.errors }}
|
||||
{{ form.grade_work_load }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-comment">
|
||||
<label for="{{ form.comment.id_for_label }}">{{ form.comment.label }} :</label>
|
||||
{{ form.comment.errors }}
|
||||
{{ form.comment }}
|
||||
</div>
|
||||
</div>
|
||||
<p><input type="submit" value="{% trans %}Comment{% endtrans %}" /></p>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
<br>
|
||||
|
||||
{% if object.comments.exists() %}
|
||||
<h2>{% trans %}Comments{% endtrans %}</h2>
|
||||
{% for comment in object.comments.order_by("-publish_date").all() %}
|
||||
<div id="{{ comment.id }}" class="comment-container">
|
||||
{% if object.comments.exists() %}
|
||||
<h2>{% trans %}Comments{% endtrans %}</h2>
|
||||
{% for comment in object.comments.order_by("-publish_date").all() %}
|
||||
<div id="{{ comment.id }}" class="comment-container">
|
||||
|
||||
<div class="grade-block">
|
||||
<div class="grade-type">
|
||||
<p>{% trans %}Global grade{% endtrans %}</p>
|
||||
<p>{% trans %}Utility{% endtrans %}</p>
|
||||
<p>{% trans %}Interest{% endtrans %}</p>
|
||||
<p>{% trans %}Teaching{% endtrans %}</p>
|
||||
<p>{% trans %}Work load{% endtrans %}</p>
|
||||
</div>
|
||||
<div class="grade-stars">
|
||||
<p>{{ display_star(comment.grade_global) }}</p>
|
||||
<p>{{ display_star(comment.grade_utility) }}</p>
|
||||
<p>{{ display_star(comment.grade_interest) }}</p>
|
||||
<p>{{ display_star(comment.grade_teaching) }}</p>
|
||||
<p>{{ display_star(comment.grade_work_load) }}</p>
|
||||
</div>
|
||||
<div class="grade-extension"></div>
|
||||
</div>
|
||||
<div class="grade-block">
|
||||
<div class="grade-type">
|
||||
<p>{% trans %}Global grade{% endtrans %}</p>
|
||||
<p>{% trans %}Utility{% endtrans %}</p>
|
||||
<p>{% trans %}Interest{% endtrans %}</p>
|
||||
<p>{% trans %}Teaching{% endtrans %}</p>
|
||||
<p>{% trans %}Work load{% endtrans %}</p>
|
||||
</div>
|
||||
<div class="grade-stars">
|
||||
<p>{{ display_star(comment.grade_global) }}</p>
|
||||
<p>{{ display_star(comment.grade_utility) }}</p>
|
||||
<p>{{ display_star(comment.grade_interest) }}</p>
|
||||
<p>{{ display_star(comment.grade_teaching) }}</p>
|
||||
<p>{{ display_star(comment.grade_work_load) }}</p>
|
||||
</div>
|
||||
<div class="grade-extension"></div>
|
||||
</div>
|
||||
|
||||
<div class="comment">
|
||||
<div class="anchor">
|
||||
<a href="{{ url('pedagogy:uv_detail', uv_id=uv.id) }}#{{ comment.id }}"><i class="fa fa-paragraph"></i></a>
|
||||
</div>
|
||||
{{ comment.comment|markdown }}
|
||||
</div>
|
||||
<div class="comment">
|
||||
<div class="anchor">
|
||||
<a href="{{ url('pedagogy:uv_detail', uv_id=uv.id) }}#{{ comment.id }}"><i class="fa fa-paragraph"></i></a>
|
||||
</div>
|
||||
{{ comment.comment|markdown }}
|
||||
</div>
|
||||
|
||||
<div class="info">
|
||||
{% if comment.is_reported %}
|
||||
<p class="status-reported">
|
||||
{% trans %}This comment has been reported{% endtrans %}
|
||||
</p>
|
||||
{% endif %}
|
||||
<div class="info">
|
||||
{% if comment.is_reported %}
|
||||
<p class="status-reported">
|
||||
{% trans %}This comment has been reported{% endtrans %}
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
{% if user.is_owner(comment) %}
|
||||
<p class="actions">
|
||||
<a href="{{ url('pedagogy:comment_update', comment_id=comment.id) }}">{% trans %}Edit{% endtrans %}</a>
|
||||
<a href="{{ url('pedagogy:comment_delete', comment_id=comment.id) }}">{% trans %}Delete{% endtrans %}</a>
|
||||
</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if user.is_owner(comment) %}
|
||||
<p class="actions">
|
||||
<a href="{{ url('pedagogy:comment_update', comment_id=comment.id) }}">{% trans %}Edit{% endtrans %}</a>
|
||||
<a href="{{ url('pedagogy:comment_delete', comment_id=comment.id) }}">{% trans %}Delete{% endtrans %}</a>
|
||||
</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="comment-end-bar">
|
||||
<div class="report"><p><a href="{{ url('pedagogy:comment_report', comment_id=comment.id) }}">{% trans %}Report this comment{% endtrans %}</a></p></div>
|
||||
<div class="comment-end-bar">
|
||||
<div class="report"><p><a href="{{ url('pedagogy:comment_report', comment_id=comment.id) }}">{% trans %}Report this comment{% endtrans %}</a></p></div>
|
||||
|
||||
<div class="date"><p>{{ comment.publish_date.strftime('%d/%m/%Y') }}</p></div>
|
||||
<div class="date"><p>{{ comment.publish_date.strftime('%d/%m/%Y') }}</p></div>
|
||||
|
||||
<div class="author"><p>{{ user_profile_link(comment.author) }}</p></div>
|
||||
</div>
|
||||
<div class="author"><p>{{ user_profile_link(comment.author) }}</p></div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
$("#return_noscript").hide();
|
||||
$("#return_js").show();
|
||||
var icons = {
|
||||
header: "fa fa-toggle-right",
|
||||
activeHeader: "fa fa-toggle-down"
|
||||
};
|
||||
$(function(){
|
||||
$("#leave_comment").accordion({
|
||||
icons: icons,
|
||||
heightStyle: "content",
|
||||
active: false,
|
||||
collapsible: true
|
||||
});
|
||||
});
|
||||
<script type="text/javascript">
|
||||
$("#return_noscript").hide();
|
||||
$("#return_js").show();
|
||||
var icons = {
|
||||
header: "fa fa-toggle-right",
|
||||
activeHeader: "fa fa-toggle-down"
|
||||
};
|
||||
$(function(){
|
||||
$("#leave_comment").accordion({
|
||||
icons: icons,
|
||||
heightStyle: "content",
|
||||
active: false,
|
||||
collapsible: true
|
||||
});
|
||||
});
|
||||
// Remove jquery-ui icons to make fontawesome work
|
||||
$(document).ready(function(){
|
||||
$(".ui-accordion-header-icon").first().removeClass("ui-icon");
|
||||
});
|
||||
</script>
|
||||
$(document).ready(function(){
|
||||
$(".ui-accordion-header-icon").first().removeClass("ui-icon");
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
@ -1,88 +1,88 @@
|
||||
{% extends "core/base.jinja" %}
|
||||
|
||||
{% block title %}
|
||||
{% trans %}Edit UE{% endtrans %}
|
||||
{% trans %}Edit UE{% endtrans %}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h2>{% trans %}Edit UE{% endtrans %}</h2>
|
||||
<form action="" method="post" enctype="multipart/form-data" id="uv_edit">
|
||||
<h2>{% trans %}Edit UE{% endtrans %}</h2>
|
||||
<form action="" method="post" enctype="multipart/form-data" id="uv_edit">
|
||||
{% csrf_token %}
|
||||
{{ form.non_field_errors() }}
|
||||
|
||||
{% for field in form %}
|
||||
|
||||
{% if field.is_hidden %}
|
||||
{% if field.is_hidden %}
|
||||
|
||||
{{ field }}
|
||||
|
||||
{% else %}
|
||||
<p>
|
||||
{{ field.errors }}
|
||||
<label for="{{ field.name }}">{{ field.label }}</label>
|
||||
{{ field }}
|
||||
{% else %}
|
||||
<p>
|
||||
{{ field.errors }}
|
||||
<label for="{{ field.name }}">{{ field.label }}</label>
|
||||
{{ field }}
|
||||
|
||||
|
||||
{% if field.name == 'code' %}
|
||||
<button type="button" id="autofill">{% trans %}Import from UTBM{% endtrans %}</button>
|
||||
{% endif %}
|
||||
</p>
|
||||
{% endif %}
|
||||
{% if field.name == 'code' %}
|
||||
<button type="button" id="autofill">{% trans %}Import from UTBM{% endtrans %}</button>
|
||||
{% endif %}
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
|
||||
{% endfor %}
|
||||
|
||||
|
||||
<p><input type="submit" value="{% trans %}Update{% endtrans %}" /></p>
|
||||
</form>
|
||||
</form>
|
||||
{% endblock %}
|
||||
|
||||
{% block script %}
|
||||
{{ super() }}
|
||||
{{ super() }}
|
||||
|
||||
<script type="text/javascript">
|
||||
<script type="text/javascript">
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const autofillBtn = document.getElementById('autofill')
|
||||
const codeInput = document.querySelector('input[name="code"]')
|
||||
const autofillBtn = document.getElementById('autofill')
|
||||
const codeInput = document.querySelector('input[name="code"]')
|
||||
|
||||
autofillBtn.addEventListener('click', () => {
|
||||
const today = new Date()
|
||||
let year = today.getFullYear()
|
||||
if (today.getMonth() < 7) { // student year starts in september
|
||||
year--
|
||||
autofillBtn.addEventListener('click', () => {
|
||||
const today = new Date()
|
||||
let year = today.getFullYear()
|
||||
if (today.getMonth() < 7) { // student year starts in september
|
||||
year--
|
||||
}
|
||||
const url = `/api/uv/${year}/${codeInput.value}`;
|
||||
deleteQuickNotifs()
|
||||
|
||||
$.ajax({
|
||||
dataType: "json",
|
||||
url: url,
|
||||
success: function(data, _, xhr) {
|
||||
if (xhr.status !== 200) {
|
||||
createQuickNotif("{% trans %}Unknown UE code{% endtrans %}")
|
||||
return
|
||||
}
|
||||
const url = `/api/uv/${year}/${codeInput.value}`;
|
||||
deleteQuickNotifs()
|
||||
|
||||
$.ajax({
|
||||
dataType: "json",
|
||||
url: url,
|
||||
success: function(data, _, xhr) {
|
||||
if (xhr.status !== 200) {
|
||||
createQuickNotif("{% trans %}Unknown UE code{% endtrans %}")
|
||||
return
|
||||
}
|
||||
Object.entries(data)
|
||||
.filter(([_, val]) => !!val) // skip entries with null or undefined value
|
||||
.map(([key, val]) => { // convert keys to DOM elements
|
||||
return [document.querySelector('[name="' + key + '"]'), val];
|
||||
})
|
||||
.filter(([elem, _]) => !!elem) // skip non-existing DOM elements
|
||||
.forEach(([elem, val]) => { // write the value in the form field
|
||||
if (elem.tagName === 'TEXTAREA') {
|
||||
Object.entries(data)
|
||||
.filter(([_, val]) => !!val) // skip entries with null or undefined value
|
||||
.map(([key, val]) => { // convert keys to DOM elements
|
||||
return [document.querySelector('[name="' + key + '"]'), val];
|
||||
})
|
||||
.filter(([elem, _]) => !!elem) // skip non-existing DOM elements
|
||||
.forEach(([elem, val]) => { // write the value in the form field
|
||||
if (elem.tagName === 'TEXTAREA') {
|
||||
// MD editor text input
|
||||
elem.parentNode.querySelector('.CodeMirror').CodeMirror.setValue(val);
|
||||
} else {
|
||||
elem.value = val;
|
||||
}
|
||||
});
|
||||
createQuickNotif('{% trans %}Successful autocomplete{% endtrans %}')
|
||||
},
|
||||
error: function(_, _, statusMessage) {
|
||||
createQuickNotif('{% trans %}An error occurred: {% endtrans %}' + statusMessage)
|
||||
},
|
||||
})
|
||||
elem.parentNode.querySelector('.CodeMirror').CodeMirror.setValue(val);
|
||||
} else {
|
||||
elem.value = val;
|
||||
}
|
||||
});
|
||||
createQuickNotif('{% trans %}Successful autocomplete{% endtrans %}')
|
||||
},
|
||||
error: function(_, _, statusMessage) {
|
||||
createQuickNotif('{% trans %}An error occurred: {% endtrans %}' + statusMessage)
|
||||
},
|
||||
})
|
||||
})
|
||||
})
|
||||
</script>
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
Reference in New Issue
Block a user