ScoDoc-PE/app/templates/pn/form_modules_ue_coefs.html

94 lines
3.3 KiB
HTML
Raw Normal View History

<!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>
2021-11-17 10:28:51 +01:00
<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>
2021-11-17 10:28:51 +01:00
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 () {
2021-11-17 10:28:51 +01:00
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";
}
2021-11-13 09:43:13 +01:00
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
2021-11-13 09:43:13 +01:00
// 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}}",
{
2021-11-13 09:43:13 +01:00
module_id: obj.dataset.module_id,
ue_id: obj.dataset.ue_id,
coef: value
},
function (result) {
obj.classList.remove("wait");
2021-11-13 09:43:13 +01:00
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
2021-11-13 09:43:13 +01:00
//setTimeout(() => {
// obj.classList.remove("modified");
//}, 1000);
}
);
2021-11-13 12:07:22 +01:00
return true;
}
</script>
</body>
</html>