forked from ScoDoc/ScoDoc
Update opolka/ScoDoc from ScoDoc/ScoDoc #2
@ -642,6 +642,17 @@ class BasePreferences(object):
|
||||
"category": "assi",
|
||||
},
|
||||
),
|
||||
(
|
||||
"non_travail",
|
||||
{
|
||||
"initvalue": "sam, dim",
|
||||
"title": "Jours non travaillés",
|
||||
"size": 40,
|
||||
"category": "assi",
|
||||
"only_global": True,
|
||||
"explanation": "Liste des jours (lun,mar,mer,jeu,ven,sam,dim)",
|
||||
},
|
||||
),
|
||||
# portal
|
||||
(
|
||||
"portal_url",
|
||||
|
@ -28,6 +28,9 @@
|
||||
.infos {
|
||||
position: relative;
|
||||
width: fit-content;
|
||||
display: flex;
|
||||
justify-content: space-evenly;
|
||||
align-content: center;
|
||||
}
|
||||
|
||||
#datestr {
|
||||
@ -36,6 +39,9 @@
|
||||
border: 1px #444 solid;
|
||||
border-radius: 5px;
|
||||
padding: 5px;
|
||||
min-width: 100px;
|
||||
display: inline-block;
|
||||
min-height: 20px;
|
||||
}
|
||||
|
||||
#tl_slider {
|
||||
|
@ -467,7 +467,18 @@ function updateDate() {
|
||||
|
||||
const date = dateInput.valueAsDate;
|
||||
|
||||
$("#datestr").text(formatDate(date).capitalize());
|
||||
if (!verifyNonWorkDays(date.getDay(), nonWorkDays)) {
|
||||
$("#datestr").text(formatDate(date).capitalize());
|
||||
dateInput.setAttribute("value", date.toISOString().split("T")[0]);
|
||||
return true;
|
||||
} else {
|
||||
const att = document.createTextNode(
|
||||
"Le jour sélectionné n'est pas un jour travaillé."
|
||||
);
|
||||
openAlertModal("Erreur", att, "", "crimson");
|
||||
dateInput.value = dateInput.getAttribute("value");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function verifyDateInSemester() {
|
||||
@ -519,6 +530,39 @@ function formatDateModal(str, separator = "·") {
|
||||
return new moment.tz(str, TIMEZONE).format(`DD/MM/Y ${separator} HH:mm`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Vérifie si la date sélectionnée n'est pas un jour non travaillé
|
||||
* Renvoie Vrai si le jour est non travaillé
|
||||
*/
|
||||
function verifyNonWorkDays(day, nonWorkdays) {
|
||||
let d = "";
|
||||
switch (day) {
|
||||
case 0:
|
||||
d = "dim";
|
||||
break;
|
||||
case 1:
|
||||
d = "lun";
|
||||
break;
|
||||
case 2:
|
||||
d = "mar";
|
||||
break;
|
||||
case 3:
|
||||
d = "mer";
|
||||
break;
|
||||
case 4:
|
||||
d = "jeu";
|
||||
break;
|
||||
case 5:
|
||||
d = "ven";
|
||||
break;
|
||||
case 6:
|
||||
d = "sam";
|
||||
break;
|
||||
}
|
||||
|
||||
return nonWorkdays.indexOf(d) != -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fonction qui vérifie si une période est dans un interval
|
||||
* Objet période / interval
|
||||
@ -573,7 +617,9 @@ function isConflictSameAsTimeLine(conflict) {
|
||||
* @returns {Date} la date sélectionnée
|
||||
*/
|
||||
function getDate() {
|
||||
const date = document.querySelector("#tl_date").valueAsDate;
|
||||
const date = new Date(
|
||||
document.querySelector("#tl_date").getAttribute("value")
|
||||
);
|
||||
date.setHours(0, 0, 0, 0);
|
||||
return date;
|
||||
}
|
||||
|
@ -37,7 +37,7 @@
|
||||
|
||||
<div class="infos">
|
||||
Date: <span id="datestr"></span>
|
||||
<input type="date" name="tl_date" id="tl_date" value="{{ date }}" onchange="updateDate()">
|
||||
<input type="date" name="tl_date" id="tl_date" value="{{ date }}">
|
||||
</div>
|
||||
|
||||
{{timeline|safe}}
|
||||
@ -70,11 +70,16 @@
|
||||
|
||||
<script>
|
||||
const etudid = {{ sco.etud.id }};
|
||||
const nonWorkDays = [{{ nonworkdays| safe }}];
|
||||
|
||||
setupDate(() => {
|
||||
actualizeEtud(etudid);
|
||||
updateSelect()
|
||||
if (updateDate()) {
|
||||
actualizeEtud(etudid);
|
||||
updateSelect()
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
setupTimeLine(() => {
|
||||
updateJustifyBtn();
|
||||
});
|
||||
|
@ -70,6 +70,8 @@
|
||||
{% include "assiduites/prompt.j2" %}
|
||||
|
||||
<script>
|
||||
const nonWorkDays = [{{ nonworkdays| safe }}];
|
||||
|
||||
updateDate();
|
||||
setupDate();
|
||||
setupTimeLine();
|
||||
|
@ -207,6 +207,7 @@ def signal_assiduites_etud():
|
||||
lunch=lunch,
|
||||
timeline=_timeline(),
|
||||
afternoon=afternoon,
|
||||
nonworkdays=_non_work_days(),
|
||||
forcer_module=sco_preferences.get_preference(
|
||||
"forcer_module", dept_id=g.scodoc_dept_id
|
||||
),
|
||||
@ -214,6 +215,12 @@ def signal_assiduites_etud():
|
||||
).build()
|
||||
|
||||
|
||||
def _non_work_days():
|
||||
non_travail = sco_preferences.get_preference("non_travail", None)
|
||||
non_travail = non_travail.replace(" ", "").split(",")
|
||||
return ",".join([f"'{i.lower()}'" for i in non_travail])
|
||||
|
||||
|
||||
def _str_to_num(string: str):
|
||||
parts = [*map(float, string.split(":"))]
|
||||
hour = parts[0]
|
||||
@ -395,6 +402,7 @@ def signal_assiduites_group():
|
||||
grp=sco_groups_view.menu_groups_choice(groups_infos),
|
||||
moduleimpl_select=_module_selector(formsemestre, moduleimpl_id),
|
||||
timeline=_timeline(),
|
||||
nonworkdays=_non_work_days(),
|
||||
formsemestre_date_debut=str(formsemestre.date_debut),
|
||||
formsemestre_date_fin=str(formsemestre.date_fin),
|
||||
forcer_module=sco_preferences.get_preference(
|
||||
|
Loading…
Reference in New Issue
Block a user