Add clone option for schedules
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
<th>{% trans "Updated" %}</th>
|
||||
<th>{% trans "Status" %}</th>
|
||||
<th>{% trans "Report" %}</th>
|
||||
<th>{% trans "Actions" %}</th>
|
||||
</tr>
|
||||
{% for schedule in object_list %}
|
||||
<tr>
|
||||
@@ -23,6 +24,7 @@
|
||||
<td>{{ schedule.updated_at|date:"SHORT_DATETIME_FORMAT" }}</td>
|
||||
<td>{{ schedule.get_status_display }}</td>
|
||||
<td>None</td>
|
||||
<td><a href="{% url 'schedule:clone' schedule_id=schedule.id %}">Clone</a></td>
|
||||
</tr>
|
||||
{% empty %}
|
||||
<tr>
|
||||
|
@@ -2,8 +2,8 @@
|
||||
{% load i18n %}
|
||||
{% load static %}
|
||||
|
||||
{% block title %}{% trans "New schedule" %}{% endblock %}
|
||||
{% block pagetitle %}{% trans "New schedule" %}{% endblock %}
|
||||
{% block title %}{% if form.json.value %}{% trans "Clone schedule" %}{% else %}{% trans "New schedule" %}{% endif %}{% endblock %}
|
||||
{% block pagetitle %}{% if form.json.value %}{% trans "Clone schedule" %}{% else %}{% trans "New schedule" %}{% endif %}{% endblock %}
|
||||
{% block content %}
|
||||
<form method="POST" action="{% url 'schedule:new' %}" id="new_schedule_form">
|
||||
{% csrf_token %}
|
||||
@@ -464,7 +464,7 @@
|
||||
var clone = jQuery('div.poliekliniek_specialisatie:first').clone()
|
||||
clone.find('input').val('');
|
||||
clone.find('option:disabled').removeAttr('disabled');
|
||||
clone.find('small').show();
|
||||
clone.find('small.text-muted').show();
|
||||
clone.insertAfter('div.poliekliniek_specialisatie:last');
|
||||
updateSpecialisaties();
|
||||
loadRemoveSpecialisatie();
|
||||
@@ -476,6 +476,7 @@
|
||||
jQuery(this).parentsUntil('.poliekliniek_specialisatie').parent().remove();
|
||||
updateSpecialisaties();
|
||||
updateSpecialisatieValues();
|
||||
calculateBehandelingen();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -502,7 +503,7 @@
|
||||
});
|
||||
|
||||
jQuery('div.werktijden select').off('change').on('change',function(event){
|
||||
check_working_hours(this);
|
||||
check_working_hours(jQuery(this).parentsUntil('.werktijden').parent());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -536,11 +537,7 @@
|
||||
|
||||
clone.insertAfter('tr.behandeling:last');
|
||||
|
||||
jQuery('tr.behandeling input.behandeling_calc').off('change keyup').on('change keyup',function(){
|
||||
calculateBehandelingen();
|
||||
});
|
||||
|
||||
jQuery('tr.behandeling select').off('change').on('change',function(){
|
||||
jQuery('tr.behandeling :input').off('change keyup').on('change keyup',function(){
|
||||
calculateBehandelingen();
|
||||
});
|
||||
|
||||
@@ -554,6 +551,7 @@
|
||||
jQuery(this).parentsUntil('.behandeling').parent().remove();
|
||||
|
||||
updateBehandelingen();
|
||||
calculateBehandelingen();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -811,8 +809,11 @@
|
||||
}
|
||||
|
||||
function check_working_hours(html, showerror) {
|
||||
html = jQuery(html).parentsUntil('.werktijden').parent();
|
||||
html = jQuery(html[0]);
|
||||
if (Array.isArray(html)) {
|
||||
html = html[0];
|
||||
}
|
||||
|
||||
html = jQuery(html);
|
||||
|
||||
let day_start = html.find('select[name^="werkdag_start_afdeling_"]');
|
||||
let day_end = html.find('select[name^="werkdag_end_afdeling_"]');
|
||||
@@ -917,6 +918,35 @@
|
||||
}
|
||||
}
|
||||
|
||||
function load_clone_data() {
|
||||
if (jQuery('input#id_json').val() != '') {
|
||||
let form = jQuery('form#new_schedule_form');
|
||||
|
||||
let json_data = JSON.parse(form.find('input#id_json').val());
|
||||
|
||||
jQuery.each(json_data,function(key,value){
|
||||
let input = form.find(':input[name="' + key + '"]');
|
||||
|
||||
if (input.length == 0) {
|
||||
// check for second or more specilism or treatment
|
||||
if (key.indexOf('behandeling') >= 0) {
|
||||
addBehandeling();
|
||||
} else {
|
||||
addSpecialisatie();
|
||||
}
|
||||
|
||||
input = form.find(':input[name="' + key + '"]');
|
||||
}
|
||||
input.val(value);
|
||||
updateSpecialisatieValues();
|
||||
});
|
||||
|
||||
validate_working_hours();
|
||||
calculateBehandelingen();
|
||||
validate_behandeling_hours();
|
||||
}
|
||||
}
|
||||
|
||||
jQuery(function() {
|
||||
jQuery('a.add_specialisatie').on('click',function(event){
|
||||
event.preventDefault();
|
||||
@@ -939,7 +969,7 @@
|
||||
});
|
||||
|
||||
jQuery('div.werktijden select').off('change').on('change',function(event){
|
||||
check_working_hours(this);
|
||||
check_working_hours(jQuery(this).parentsUntil('.werktijden').parent());
|
||||
calculateBehandelingen();
|
||||
});
|
||||
|
||||
@@ -949,7 +979,7 @@
|
||||
});
|
||||
});
|
||||
|
||||
jQuery('input.behandeling_calc').off('change keyup').on('change keyup',function(event){
|
||||
jQuery('tr.behandeling :input').off('change keyup').on('change keyup',function(event){
|
||||
calculateBehandelingen();
|
||||
});
|
||||
|
||||
@@ -966,10 +996,11 @@
|
||||
return true;
|
||||
} else {
|
||||
alert('Er zijn wat problemen met het formulier. Controleer de invoer velden');
|
||||
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
load_clone_data();
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
Reference in New Issue
Block a user