agenda: icon displayed or hidden on comment update

Closes #2509
This commit is contained in:
Serghei Mihai 2014-05-28 19:48:16 +02:00
parent ce8553a501
commit 7b8d8bd500
3 changed files with 13 additions and 7 deletions

View File

@ -3,7 +3,7 @@
<p><a href="{% url 'periodic-events-for-worker' service=service date=date worker_id=worker_agenda.worker.id %}">Rendez-vous périodiques</a></p>
<div {% if appointment.event_id %}data-event-id="{{ appointment.event_id }}"{% endif %}>
{% for appointment in worker_agenda.appointments %}
<h3 class="{{ appointment.type }} {% if appointment.act_absence %}act-absence{% endif %} appointment"
<h3 id="{{ appointment.event_id }}" class="{{ appointment.type }} {% if appointment.act_absence %}act-absence{% endif %} appointment"
{% if appointment.act_absence %}title="{{appointment.act_absence}}"{% endif %}>
<span class="hour">{{ appointment.begin_hour }}</span>
<span class="length">{% if appointment.length %}{% if appointment.length|str_length_lt:3 %}&nbsp;{% endif %}{{ appointment.length }} mn{% endif %}</span>
@ -33,9 +33,7 @@
{% for service_name in appointment.other_services_names %}
<span class="box {{ service_name }}" title="{{ service_name }}"></span>
{% endfor %}
{% if appointment.description %}
<span title="Un commentaire existe" class="icon-comment"></span>
{% endif %}
<span title="Un commentaire existe" class="icon-comment" {% if appointment.description %}style='display: inline'{% endif %}></span>
{% if appointment.event_id %}
{% if appointment.is_recurrent %} R {% endif %}
{% if appointment.patient.confidential %}

View File

@ -223,4 +223,8 @@ ul.addresses {
button.screen-only {
margin: 1em 0;
float: right;
}
h3 .icon-comment {
display: none;
}

View File

@ -80,15 +80,19 @@ function enable_events(base) {
}
else
{
var data = {description: textarea.val() };
var data = JSON.stringify(data);
var comment = {description: textarea.val()};
var data = JSON.stringify(comment);
$.ajax({
url: '/api/v1/event/' + $(this).data("event-id") + '/?format=json&date=' + $(this).data('date'),
type: 'PATCH',
contentType: 'application/json',
data: data,
success: function(data) {
success: function(response) {
btn.attr('disabled', 'disabled');
if (comment['description'])
$('h3#' + btn.data("event-id") + ' span.icon-comment').fadeIn();
else
$('h3#' + btn.data("event-id") + ' span.icon-comment').fadeOut();
span.html('Commentaire modifié avec succès');
}
});