1
0
forked from ScoDoc/ScoDoc
ScoDoc/app/templates/pn/form_modules_ue_coefs.html
2021-11-17 10:28:51 +01:00

94 lines
3.3 KiB
HTML

<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="/ScoDoc/static/jQuery/jquery.js"></script>
<script src="/ScoDoc/static/js/table_editor.js"></script>
<link href="/ScoDoc/static/css/table_editor.css" rel="stylesheet" type="text/css" />
<title>Édition coef. formation</title>
</head>
<body>
<h2>Formation {{formation.titre}} ({{formation.acronyme}})
[version {{formation.version}}] code {{formation.code}}</h2>
<form onchange="change_semestre()">Semestre:
<select name="semestre_idx" id="semestre_idx" >
{% for i in semestre_ids %}
<option value="{{i}}" {%if semestre_idx == i%}selected{%endif%}>{{i}}</option>
{% endfor %}
</select>
</form>
<div class="tableau"></div>
<script>
function change_semestre() {
let semestre_idx = $("#semestre_idx")[0].value;
let url = window.location.href.replace( /\/[\-0-9]*$/, "/" + semestre_idx);
window.location.href = url;
};
$(function () {
let semestre_idx = $("#semestre_idx")[0].value;
if (semestre_idx > -10) {
let base_url = "{{data_source}}";
let data_url = base_url.replace( /\/[\-0-9]*$/, "/" + semestre_idx);
console.log("data_url=", data_url );
$.getJSON(data_url, function (data) {
console.log("build_table")
build_table(data);
});
}
});
function save(obj) {
var value = obj.innerText.trim();
if (value.length == 0) {
value = "0";
}
if (!/^[\d.,]+$/.test(value)) {
message("Il est attendu un nombre");
return false;
}
if (value == obj.dataset.data) {
return true; // Aucune modification, pas d'enregistrement mais on continue normalement
}
obj.dataset.data = value;
obj.classList.add("wait");
// XXX DEBUG
// console.log(`
// x : ${getComputedStyle(obj).getPropertyValue("--x")}
// y : ${getComputedStyle(obj).getPropertyValue("--y")}
// data : ${value}
// ue_id: ${obj.dataset.ue_id}
// module_id : ${obj.dataset.module_id}
// `);
$.post("{{data_save}}",
{
module_id: obj.dataset.module_id,
ue_id: obj.dataset.ue_id,
coef: value
},
function (result) {
obj.classList.remove("wait");
if (obj.dataset.orig != value)
obj.classList.add("modified");
else
obj.classList.remove("modified");
// Lorsque les données sont bien enregistrées, on enlève
// l'indication que c'est bon au bout d'un temps
//setTimeout(() => {
// obj.classList.remove("modified");
//}, 1000);
}
);
return true;
}
</script>
</body>
</html>