1
0
forked from ScoDoc/ScoDoc
ScoDoc/app/static/js/edit_ue.js

64 lines
1.8 KiB
JavaScript
Raw Normal View History

2020-09-26 16:19:37 +02:00
// Affiche et met a jour la liste des UE partageant le meme code
2021-06-21 18:46:35 +02:00
$().ready(function () {
if (document.querySelector("#tf_ue_id")) {
/* fonctions spécifiques pour edition UE */
update_ue_list();
$("#tf_ue_code").bind("keyup", update_ue_list);
2022-01-27 18:12:40 +01:00
$("select#tf_type").change(function () {
update_bonus_description();
});
2022-01-27 18:12:40 +01:00
update_bonus_description();
}
2020-09-26 16:19:37 +02:00
});
2022-01-27 18:12:40 +01:00
function update_bonus_description() {
var ue_type = $("#tf_type")[0].value;
if (ue_type == "1") { /* UE SPORT */
$("#bonus_description").show();
var query = "/ScoDoc/get_bonus_description/default";
$.get(query, '', function (data) {
$("#bonus_description").html(data);
});
} else {
$("#bonus_description").html("");
$("#bonus_description").hide();
}
}
2020-09-26 16:19:37 +02:00
function update_ue_list() {
let ue_id = $("#tf_ue_id")[0].value;
let ue_code = $("#tf_ue_code")[0].value;
let query = SCO_URL + "/Notes/ue_sharing_code?ue_code=" + ue_code + "&hide_ue_id=" + ue_id + "&ue_id=" + ue_id;
2021-06-21 18:46:35 +02:00
$.get(query, '', function (data) {
$("#ue_list_code").html(data);
2020-09-26 16:19:37 +02:00
});
2021-06-21 18:46:35 +02:00
}
2023-04-11 23:56:50 +02:00
function set_ue_parcour(checkbox) {
let url = checkbox.dataset.setter;
const checkboxes = document.querySelectorAll('#choix_parcours input[type="checkbox"]:checked');
const parcours_ids = [];
checkboxes.forEach(function (checkbox) {
parcours_ids.push(checkbox.value);
});
2023-04-11 23:56:50 +02:00
fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
2023-04-11 23:56:50 +02:00
body: JSON.stringify(parcours_ids)
})
.then(response => response.json())
2023-04-11 23:56:50 +02:00
.then(data => {
2023-05-13 18:35:10 +02:00
if (data.status == 404) {
sco_error_message(data.message);
} else {
2023-04-11 23:56:50 +02:00
sco_message(data.message);
}
});
}