106 lines
4.4 KiB
HTML
106 lines
4.4 KiB
HTML
|
{% extends "base.html" %}
|
||
|
|
||
|
<!-- {% block page_title %}.: New Routine :.{% endblock %} -->
|
||
|
<!-- {% block title %}Routine{% endblock %} -->
|
||
|
|
||
|
{% block content %}
|
||
|
<div class="row justify-content-center">
|
||
|
<div class="col-12 col-sm-12 col-md-8 col-lg-8 col-xl-6">
|
||
|
<div class="card">
|
||
|
<div class="card-header">
|
||
|
<h4 class="card-title">Compose Routine : {{ routine.longLabel }}</h4>
|
||
|
</div>
|
||
|
<div class="card-body">
|
||
|
<ol>
|
||
|
{% for link in skill_link_list %}
|
||
|
<li>
|
||
|
<div class="form-group row pb-0 mb-0">
|
||
|
<label class="col-1 col-sm-1 col-md-1 col-lg-1 col-xl-1 col-form-label text-right"> </label>
|
||
|
<div class="col-11 col-sm-11 col-md-11 col-lg-11 col-xl-11 pt-2 text-danger">
|
||
|
{{ link.skill.notation }}
|
||
|
</div>
|
||
|
</div>
|
||
|
</li>
|
||
|
{% endfor %}
|
||
|
<li>
|
||
|
<div class="form-group row">
|
||
|
<label class="col-1 col-sm-1 col-md-1 col-lg-1 col-xl-1 col-form-label text-right"> </label>
|
||
|
<div class="col-11 col-sm-11 col-md-11 col-lg-11 col-xl-11">
|
||
|
<input type="text" name="skill" placeholder="Skill" class="form-control" id="skill">
|
||
|
</div>
|
||
|
</div>
|
||
|
</li>
|
||
|
</ol>
|
||
|
</div>
|
||
|
<div class="card-footer pt-0">
|
||
|
<a href="{% url 'routine_details' routine.id %}">
|
||
|
<button type="submit" value="add" class="btn btn-icon btn-warning ">
|
||
|
<i class="tim-icons icon-double-left"></i>
|
||
|
</button>
|
||
|
</a>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
<script type="text/javascript" >
|
||
|
$(function(){
|
||
|
var number_of_skill = {{ number_of_skill }};
|
||
|
|
||
|
function insert_selected_skill(skill_label)
|
||
|
{
|
||
|
$('#minusButton').remove();
|
||
|
$('ol li:last-child').before('<li><div class="form-group row"><label class="col-1 col-sm-1 col-md-1 col-lg-1 col-xl-1 col-form-label text-right"> </label><div class="col-3 col-sm-3 col-md-3 col-lg-3 col-xl-3 pt-2">' + skill_label + '</div><div class="col-1 col-sm-1 col-md-1 col-lg-1 col-xl-1"><button type="button" class="btn btn-warning btn-sm" id="minusButton">-</button></div></div></li>');
|
||
|
$('#skill').val('');
|
||
|
}
|
||
|
|
||
|
$('body').on('click', '#minusButton', function(event){
|
||
|
// alert('Suppression du skill !');
|
||
|
$.ajax({
|
||
|
url: '/routine/' + {{ routine.id }} + '/order/' + number_of_skill + '/'
|
||
|
}).done(function() {
|
||
|
// alert('suppression du li');
|
||
|
$('ol li:last-child').prev().remove();
|
||
|
});
|
||
|
});
|
||
|
|
||
|
$('#skill').autocomplete({
|
||
|
source: function(request, response) {
|
||
|
$.ajax({
|
||
|
url: '/skill/lookup/?pattern=' + request.term,
|
||
|
dataType: "json",
|
||
|
success: function(data) {
|
||
|
if(data.length != 0) {
|
||
|
response($.map(data, function(item) {
|
||
|
return {
|
||
|
label: item.label,
|
||
|
value: item.label,
|
||
|
skillid: item.id,
|
||
|
notation: item.notation,
|
||
|
}
|
||
|
}))
|
||
|
} else {
|
||
|
response([{ label: 'No result found.', value: '' }]);
|
||
|
};
|
||
|
},
|
||
|
|
||
|
error: function (exception) {
|
||
|
console.log(exception);
|
||
|
}
|
||
|
});
|
||
|
},
|
||
|
minLength: 3,
|
||
|
select: function (event, ui) {
|
||
|
number_of_skill += 1;
|
||
|
$.ajax({
|
||
|
url: '/routine/' + {{ routine.id }} + '/add_skill/' + ui.item.skillid + '/order/' + number_of_skill + '/'
|
||
|
}).done(function() {
|
||
|
insert_selected_skill(ui.item.notation);
|
||
|
});
|
||
|
}
|
||
|
});
|
||
|
});
|
||
|
</script>
|
||
|
|
||
|
{% endblock %}
|