Jarvis/jarvis/objective/templates/passes/create.html

110 lines
5.0 KiB
HTML
Raw Normal View History

2024-02-25 20:02:20 +01:00
{% extends "base.html" %}
{% block content %}
<div class="row justify-content-center">
<div class="col-12 col-sm-12 col-md-8 col-lg-7 col-xl-6">
<div class="card">
<div class="card-header">
<h4 class="">{% if passe_id %}Edit{% else %}Add{% endif %} Passe</h4>
</div>
<div class="card-body">
<form action="{% if passe_id %}{% url 'passe_update' passe_id %}{% else %}{% url 'passe_create' %}{% endif %}" method="post" class="form-horizontal" id="formulaire" name="formulaire">
{% csrf_token %}
{% for hidden in form.hidden_fields %}
{{ hidden }}
{% endfor %}
<div class="form-group row {% if form.long_label.errors %}has-error has-feedback{% endif %}">
<label for="id_label" class="col-4 col-sm-2 col-md-2 col-lg-2 col-xl-2 col-form-label">Label</label>
<div class="col-8 col-sm-10 col-md-10 col-lg-10 col-xl-10">
{{ form.label }}
{% if form.label.errors %}&nbsp;<span class="btn btn-sm btn-danger-outline">{% for error in form.label.errors %}{{ error }}{% endfor %}</span>{% endif %}
</div>
</div>
<div class="form-group row {% if form.regexp.errors %}has-error has-feedback{% endif %}">
<label for="id_regexp" class="col-4 col-sm-2 col-md-2 col-lg-2 col-xl-2 col-form-label">{{ form.regexp.label }}<span class="text-danger"><b>*</b></span></label>
<div class="col-4 col-sm-4 col-md-4 col-lg-4 col-xl-3">
{{ form.regexp }}
{% if form.regexp.errors %}&nbsp;<span class="btn btn-sm btn-danger-outline">{% for error in form.regexp.errors %}{{ error }}{% endfor %}</span>{% endif %}
</div>
</div>
2024-03-13 11:15:19 +01:00
<div class="form-group row ">
<label for="id_educative" class="col-4 col-sm-2 col-md-2 col-lg-2 col-xl-2 col-form-label">{{ form.educatives.label }} <span class="text-danger"><b>*</b></span></label>
<div class="col-8 col-sm-8 col-md-6 col-lg-6 col-xl-6 {% if form.educatives.errors %}has-danger{% endif %}">
{{ form.media }}
{{ form.educatives }}
</div>
</div>
2024-02-25 20:02:20 +01:00
<div class="form-group row ">
<label for="id_informations" class="col-4 col-sm-2 col-md-2 col-lg-2 col-xl-2 col-form-label">Informations</label>
<div class="col-8 col-sm-9 col-md-9 col-lg-9 col-xl-9 {% if form.id_information.errors %}has-danger{% endif %}">
{{ form.informations }}
</div>
</div>
<div class="form-group text-center">
<input type="submit" value="Save" class="btn btn-warning" />
</div>
</form>
</div>
</div>
</div>
</div>
{% endblock %}
{% block footerscript %}
<script type="text/javascript" >
$(function(){
const csrf_token = "{{ csrf_token|escapejs }}";
const educative_lookup = "{% url 'educative_lookup' %}";
$('#id_educative_related').autocomplete({
source: function(request, response) {
$.ajax({
url: educative_lookup,
method: "POST",
data: {
pattern: $('#id_educative_related').val(),
csrfmiddlewaretoken: csrf_token
},
dataType: "json",
success: function(data) {
if(data.length != 0) {
response($.map(data, function(item) {
return {
label: item.long_label,
value: item.short_label,
educativeid: item.ID
}
}))
} else {
response([{ label: 'No result found.', value: '' }]);
};
},
error: function (exception) {
console.log(exception);
}
});
},
minLength: 3,
select: function (event, ui) {
$($(this).data('ref')).val(ui.item.educativeid);
},
{% if request.session.template == 0 %}
classes: {
"ui-widget-content": "custom_autocomplete_ul",
"ui-autocomplete": "custom_autocomplete_ul",
"ui-menu-item-wrapper": "custom_autocomplete_li",
"ui-menu-item": "custom_autocomplete_li",
},
{% endif %}
});
});
</script>
{% endblock %}