Ajoute timepicker partout. Utilise pour evaluation_edit. Fix #829

This commit is contained in:
Emmanuel Viennet 2024-01-16 12:36:20 +01:00
parent e3fc13f215
commit 7ce57d28cb
11 changed files with 49 additions and 75 deletions

View File

@ -584,20 +584,10 @@ def check_convert_evaluation_args(moduleimpl: "ModuleImpl", data: dict):
if date_debut and date_fin: if date_debut and date_fin:
duration = data["date_fin"] - data["date_debut"] duration = data["date_fin"] - data["date_debut"]
if duration.total_seconds() < 0 or duration > MAX_EVALUATION_DURATION: if duration.total_seconds() < 0 or duration > MAX_EVALUATION_DURATION:
raise ScoValueError("Heures de l'évaluation incohérentes !") raise ScoValueError(
# # --- heures "Heures de l'évaluation incohérentes !",
# heure_debut = data.get("heure_debut", None) dest_url="javascript:history.back();",
# if heure_debut and not isinstance(heure_debut, datetime.time): )
# if date_format == "dmy":
# data["heure_debut"] = heure_to_time(heure_debut)
# else: # ISO
# data["heure_debut"] = datetime.time.fromisoformat(heure_debut)
# heure_fin = data.get("heure_fin", None)
# if heure_fin and not isinstance(heure_fin, datetime.time):
# if date_format == "dmy":
# data["heure_fin"] = heure_to_time(heure_fin)
# else: # ISO
# data["heure_fin"] = datetime.time.fromisoformat(heure_fin)
def heure_to_time(heure: str) -> datetime.time: def heure_to_time(heure: str) -> datetime.time:

View File

@ -685,6 +685,11 @@ class TF(object):
'<input type="text" name="%s" size="10" value="%s" class="datepicker">' '<input type="text" name="%s" size="10" value="%s" class="datepicker">'
% (field, values[field]) % (field, values[field])
) )
elif input_type == "time": # JavaScript widget for date input
lem.append(
f"""<input type="text" name="{field}" maxlength="5" size="5" value="{
values[field]}" class="timepicker">"""
)
elif input_type == "text_suggest": elif input_type == "text_suggest":
lem.append( lem.append(
'<input type="text" name="%s" id="%s" size="%d" %s' '<input type="text" name="%s" id="%s" size="%d" %s'

View File

@ -189,7 +189,12 @@ def sco_header(
# jQuery UI # jQuery UI
# can modify loaded theme here # can modify loaded theme here
H.append( H.append(
f'<link type="text/css" rel="stylesheet" href="{scu.STATIC_DIR}/libjs/jquery-ui-1.10.4.custom/css/smoothness/jquery-ui-1.10.4.custom.min.css" />\n' f"""
<link type="text/css" rel="stylesheet"
href="{scu.STATIC_DIR}/libjs/jquery-ui-1.10.4.custom/css/smoothness/jquery-ui-1.10.4.custom.min.css" />
<link type="text/css" rel="stylesheet"
href="{scu.STATIC_DIR}/libjs/timepicker-1.3.5/jquery.timepicker.min.css" />
"""
) )
if init_google_maps: if init_google_maps:
# It may be necessary to add an API key: # It may be necessary to add an API key:
@ -219,19 +224,26 @@ def sco_header(
# jQuery # jQuery
H.append( H.append(
f"""<script src="{scu.STATIC_DIR}/jQuery/jquery.js"></script> f"""
<script src="{scu.STATIC_DIR}/libjs/jquery.field.min.js"></script>""" <script src="{scu.STATIC_DIR}/jQuery/jquery.js"></script>
<script src="{scu.STATIC_DIR}/libjs/jquery.field.min.js"></script>
"""
) )
# qTip # qTip
if init_qtip: if init_qtip:
H.append( H.append(
f"""<script src="{scu.STATIC_DIR}/libjs/qtip/jquery.qtip-3.0.3.min.js"></script> f"""<script src="{scu.STATIC_DIR}/libjs/qtip/jquery.qtip-3.0.3.min.js"></script>
<link type="text/css" rel="stylesheet" href="{scu.STATIC_DIR}/libjs/qtip/jquery.qtip-3.0.3.min.css" />""" <link type="text/css" rel="stylesheet"
href="{scu.STATIC_DIR}/libjs/qtip/jquery.qtip-3.0.3.min.css" />
"""
) )
H.append( H.append(
f"""<script src="{scu.STATIC_DIR}/libjs/jquery-ui-1.10.4.custom/js/jquery-ui-1.10.4.custom.min.js"></script> f"""<script
<script src="{scu.STATIC_DIR}/js/scodoc.js"></script>""" src="{scu.STATIC_DIR}/libjs/jquery-ui-1.10.4.custom/js/jquery-ui-1.10.4.custom.min.js"></script>
<script src="{scu.STATIC_DIR}/libjs/timepicker-1.3.5/jquery.timepicker.min.js"></script>
<script src="{scu.STATIC_DIR}/js/scodoc.js"></script>
"""
) )
if init_google_maps: if init_google_maps:
H.append( H.append(

View File

@ -178,9 +178,7 @@ def evaluation_create_form(
{ {
"title": "Heure de début", "title": "Heure de début",
"explanation": "heure du début de l'épreuve", "explanation": "heure du début de l'épreuve",
"input_type": "menu", "input_type": "time",
"allowed_values": heures,
"labels": heures,
}, },
), ),
( (
@ -188,9 +186,7 @@ def evaluation_create_form(
{ {
"title": "Heure de fin", "title": "Heure de fin",
"explanation": "heure de fin de l'épreuve", "explanation": "heure de fin de l'épreuve",
"input_type": "menu", "input_type": "time",
"allowed_values": heures,
"labels": heures,
}, },
), ),
] ]
@ -335,6 +331,7 @@ def evaluation_create_form(
+ "\n" + "\n"
+ tf[1] + tf[1]
+ render_template("scodoc/help/evaluations.j2", is_apc=is_apc) + render_template("scodoc/help/evaluations.j2", is_apc=is_apc)
+ render_template("sco_timepicker.j2")
+ html_sco_header.sco_footer() + html_sco_header.sco_footer()
) )
elif tf[0] == -1: elif tf[0] == -1:

View File

@ -167,6 +167,7 @@ def _ue_coefs_html(coefs_lst) -> str:
{'background-color: ' + ue.color + ';' if ue.color else ''} {'background-color: ' + ue.color + ';' if ue.color else ''}
"><div>{coef}</div>{ue.acronyme}</div>""" "><div>{coef}</div>{ue.acronyme}</div>"""
for ue, coef in coefs_lst for ue, coef in coefs_lst
if coef > 0
] ]
) )
+ "</div>" + "</div>"

View File

@ -6,7 +6,6 @@
{% block styles %} {% block styles %}
{{super()}} {{super()}}
<link rel="stylesheet" href="{{scu.STATIC_DIR}}/libjs/timepicker-1.3.5/jquery.timepicker.min.css"/>
<link rel="stylesheet" href="{{scu.STATIC_DIR}}/css/assiduites.css"> <link rel="stylesheet" href="{{scu.STATIC_DIR}}/css/assiduites.css">
{% endblock %} {% endblock %}
@ -114,19 +113,7 @@ div.submit > input {
{% block scripts %} {% block scripts %}
{{ super() }} {{ super() }}
<script src="{{scu.STATIC_DIR}}/libjs/timepicker-1.3.5/jquery.timepicker.min.js"></script>
<script src="{{scu.STATIC_DIR}}/js/assiduites.js"></script> <script src="{{scu.STATIC_DIR}}/js/assiduites.js"></script>
<script src="{{scu.STATIC_DIR}}/js/etud_info.js"></script> <script src="{{scu.STATIC_DIR}}/js/etud_info.js"></script>
<script> {% include "sco_timepicker.j2" %}
$('.timepicker').timepicker({
timeFormat: 'HH:mm',
interval: {{ scu.get_assiduites_time_config("assi_tick_time") }},
minTime: "{{ scu.get_assiduites_time_config("assi_morning_time") }}",
maxTime: "{{ scu.get_assiduites_time_config("assi_afternoon_time") }}",
startTime: "{{ scu.get_assiduites_time_config("assi_morning_time") }}",
dynamic: false,
dropdown: true,
scrollbar: false
});
</script>
{% endblock scripts %} {% endblock scripts %}

View File

@ -97,19 +97,8 @@
color: var(--color-error); color: var(--color-error);
} }
</style> </style>
{% include "sco_timepicker.j2" %}
<script> <script>
$('.timepicker').timepicker({
timeFormat: 'HH:mm',
interval: {{ scu.get_assiduites_time_config("assi_tick_time") }},
minTime: "{{ scu.get_assiduites_time_config("assi_morning_time") }}",
maxTime: "{{ scu.get_assiduites_time_config("assi_afternoon_time") }}",
defaultTime: 'now',
startTime: "{{ scu.get_assiduites_time_config("assi_morning_time") }}",
dynamic: false,
dropdown: true,
scrollbar: false
});
function validateFields() { function validateFields() {
const field = document.querySelector('.assi-form') const field = document.querySelector('.assi-form')
const { deb, fin } = getDates() const { deb, fin } = getDates()

View File

@ -5,7 +5,6 @@ Si justif, edit #}
{% block styles %} {% block styles %}
{{super()}} {{super()}}
<link rel="stylesheet" href="{{scu.STATIC_DIR}}/libjs/timepicker-1.3.5/jquery.timepicker.min.css"/>
<link rel="stylesheet" href="{{scu.STATIC_DIR}}/css/assiduites.css"> <link rel="stylesheet" href="{{scu.STATIC_DIR}}/css/assiduites.css">
{% endblock %} {% endblock %}
@ -126,21 +125,9 @@ div.submit > input {
{% block scripts %} {% block scripts %}
{{ super() }} {{ super() }}
<script src="{{scu.STATIC_DIR}}/libjs/timepicker-1.3.5/jquery.timepicker.min.js"></script>
<script src="{{scu.STATIC_DIR}}/js/assiduites.js"></script> <script src="{{scu.STATIC_DIR}}/js/assiduites.js"></script>
<script src="{{scu.STATIC_DIR}}/js/etud_info.js"></script> <script src="{{scu.STATIC_DIR}}/js/etud_info.js"></script>
<script> {% include "sco_timepicker.j2" %}
$('.timepicker').timepicker({
timeFormat: 'HH:mm',
interval: {{ scu.get_assiduites_time_config("assi_tick_time") }},
minTime: "{{ scu.get_assiduites_time_config("assi_morning_time") }}",
maxTime: "{{ scu.get_assiduites_time_config("assi_afternoon_time") }}",
startTime: "{{ scu.get_assiduites_time_config("assi_morning_time") }}",
dynamic: false,
dropdown: true,
scrollbar: false
});
</script>
<script> <script>
document.addEventListener("DOMContentLoaded", function() { document.addEventListener("DOMContentLoaded", function() {
// Suppression d'un fichier justificatif // Suppression d'un fichier justificatif

View File

@ -1,11 +1,6 @@
{% extends "sco_page.j2" %} {% extends "sco_page.j2" %}
{% import 'wtf.j2' as wtf %} {% import 'wtf.j2' as wtf %}
{% block styles %}
{{super()}}
<link rel="stylesheet" href="{{scu.STATIC_DIR}}/libjs/timepicker-1.3.5/jquery.timepicker.min.css"/>
{% endblock %}
{% block app_content %} {% block app_content %}
{% for err_msg in form.error_messages %} {% for err_msg in form.error_messages %}
<div class="wtf-error-messages"> <div class="wtf-error-messages">
@ -24,7 +19,3 @@
</form> </form>
{% endblock app_content %} {% endblock app_content %}
{% block scripts %}
{{ super() }}
<script src="{{scu.STATIC_DIR}}/libjs/timepicker-1.3.5/jquery.timepicker.min.js"></script>
{% endblock scripts %}

View File

@ -5,6 +5,8 @@
{{super()}} {{super()}}
<link type="text/css" rel="stylesheet" <link type="text/css" rel="stylesheet"
href="{{scu.STATIC_DIR}}/libjs/jquery-ui-1.10.4.custom/css/smoothness/jquery-ui-1.10.4.custom.min.css" /> href="{{scu.STATIC_DIR}}/libjs/jquery-ui-1.10.4.custom/css/smoothness/jquery-ui-1.10.4.custom.min.css" />
<link type="text/css" rel="stylesheet"
href="{{scu.STATIC_DIR}}/libjs/timepicker-1.3.5/jquery.timepicker.min.css" />
<link rel="stylesheet" href="{{scu.STATIC_DIR}}/css/scodoc.css"> <link rel="stylesheet" href="{{scu.STATIC_DIR}}/css/scodoc.css">
<link href="{{scu.STATIC_DIR}}/css/menu.css" rel="stylesheet" type="text/css" /> <link href="{{scu.STATIC_DIR}}/css/menu.css" rel="stylesheet" type="text/css" />
<link href="{{scu.STATIC_DIR}}/css/gt_table.css" rel="stylesheet" type="text/css" /> <link href="{{scu.STATIC_DIR}}/css/gt_table.css" rel="stylesheet" type="text/css" />
@ -45,6 +47,7 @@
<script src="{{scu.STATIC_DIR}}/jQuery/jquery-migrate-1.2.0.min.js"></script> <script src="{{scu.STATIC_DIR}}/jQuery/jquery-migrate-1.2.0.min.js"></script>
<script src="{{scu.STATIC_DIR}}/libjs/jquery.field.min.js"></script> <script src="{{scu.STATIC_DIR}}/libjs/jquery.field.min.js"></script>
<script src="{{scu.STATIC_DIR}}/libjs/jquery-ui-1.10.4.custom/js/jquery-ui-1.10.4.custom.min.js"></script> <script src="{{scu.STATIC_DIR}}/libjs/jquery-ui-1.10.4.custom/js/jquery-ui-1.10.4.custom.min.js"></script>
<script src="{{scu.STATIC_DIR}}/libjs/timepicker-1.3.5/jquery.timepicker.min.js"></script>
<script src="{{scu.STATIC_DIR}}/libjs/qtip/jquery.qtip-3.0.3.min.js"></script> <script src="{{scu.STATIC_DIR}}/libjs/qtip/jquery.qtip-3.0.3.min.js"></script>
<script src="{{scu.STATIC_DIR}}/js/scodoc.js"></script> <script src="{{scu.STATIC_DIR}}/js/scodoc.js"></script>

View File

@ -0,0 +1,12 @@
<script>
$('.timepicker').timepicker({
timeFormat: 'HH:mm',
interval: {{ scu.get_assiduites_time_config("assi_tick_time") }},
minTime: "{{ scu.get_assiduites_time_config("assi_morning_time") }}",
maxTime: "{{ scu.get_assiduites_time_config("assi_afternoon_time") }}",
startTime: "{{ scu.get_assiduites_time_config("assi_morning_time") }}",
dynamic: false,
dropdown: true,
scrollbar: false
});
</script>