Projet

Général

Profil

« Précédent | Suivant » 

Révision 3e4631f4

Ajouté par Mikaël Ates il y a presque 10 ans

agenda: comment update in ajax, we update comment on event and not on act

Voir les différences:

calebasse/agenda/templates/agenda/ajax-worker-tab.html
136 136
            <span></span>
137 137
            {% if service in appointment.services_names or not appointment.services_names %}
138 138
            <textarea>{{ appointment.description }}</textarea>
139
            <button disabled="disabled" data-event-id="{{ appointment.event_id }}" data-date="{{ date|date:"Y-m-d" }}" {% if appointment.act_id %}data-act-id="{{ appointment.act_id }}{% endif %}">✔</button>
139
            <button disabled="disabled" data-event-id="{{ appointment.event_id }}" data-date="{{ date|date:"Y-m-d" }}">✔</button>
140 140
            {% else %}
141 141
            <p>{{ appointment.description }}</p>
142 142
            {% endif %}
calebasse/static/js/calebasse.agenda.js
65 65
          var btn = $(this);
66 66
          var comment = {description: textarea.val()};
67 67
          var data = JSON.stringify(comment);
68
          if ($(this).data('act-id'))
69
          {
70

  
71
            $.ajax({
72
              url: '/api/v1/act/' + $(this).data("act-id") + '/?format=json&date=' + $(this).data('date'),
73
              type: 'PATCH',
74
              contentType: 'application/json',
75
              data: data,
76
              success: function(data) {
77
                btn.attr('disabled', 'disabled');
78
                if (comment['description']) {
79
                    $('h3#' + btn.data("event-id") + ' span.icon-comment').fadeIn();
80
                }
81
                else {
82
                    $('h3#' + btn.data("event-id") + ' span.icon-comment').fadeOut();
83
                }
84
                span.html('Commentaire modifié avec succès');
85
              }
86
            });
87
          }
88
          else
89
          {
90 68
            $.ajax({
91 69
              url: '/api/v1/event/' + $(this).data("event-id") + '/?format=json&date=' + $(this).data('date'),
92 70
              type: 'PATCH',
......
101 79
                span.html('Commentaire modifié avec succès');
102 80
              }
103 81
            });
104
          }
105 82
      });
106 83
      /* TODO: put this in a generic function */
107 84
      $('.input_is_billable').click(function() {

Formats disponibles : Unified diff