Project

General

Profile

« Previous | Next » 

Revision 5a8330bb

Added by Serghei Mihai over 9 years ago

agenda: appointment and event editing dialog fix while adding groups

Closes #5635

View differences:

calebasse/static/js/calebasse.dialog.js
17 17
  $button.removeAttr('disabled');
18 18
}
19 19

  
20
function init_dialog(id) {
21
    init_datepickers(id);
22
    $('#id_description', id).attr('rows', '3');
23
    $('#id_description', id).attr('cols', '30');
24
    var deck = $('#id_participants_on_deck', id);
25
    $(deck).bind('added', function() {
26
      var added = $(deck).find('div:last');
27
      var t = added.attr('id').indexOf('_group:');
28
      if ( t == -1) return;
29

  
30
      /* remove group element and fake id */
31
      added.remove();
32
      var val = $('#id_participants').val();
33
      $('#id_participants').val(val.substr(0, val.substr(0, val.length-1).lastIndexOf('|')+1));
34

  
35
      /* add all workers */
36
      var query = added.attr('id').substr(t+1);
37
      var receive_result = $('#id_participants_text', id).autocomplete('option', 'select');
38
      $.getJSON($('#id_participants_text', id).autocomplete('option', 'source') + '?term=' + query,
39
        function(data) {
40
          $.each(data, function(key, val) {
41
            if (key==0) return; /* ignore first element as it's the group itself */
42
            var ui = Object();
43
            ui.item = val;
44
            receive_result(null, ui);
45
          });
46
        });
47
    });
48
}
49

  
20 50
function generic_ajaxform_dialog(url, title, id, width, btn_submit_name, redirectToUrl, on_load_callback, height, extra_button, replace_content) {
21 51
  if (! height)
22 52
    height = 'auto';
23 53
  $(id).load(url,
24 54
      function () {
25
        init_datepickers(id);
55
        init_dialog(id);
26 56
        function onsuccess(response, status, xhr, form) {
27 57
          enable_button($('#submit-btn'));
28 58
          var parse = $(response);
......
104 134
function add_dialog(on, url, title, width, btn_text) {
105 135
  // function used to add patient schedules, events and acts
106 136

  
107
  function init_dialog() {
108
    $('.datepicker-date').datepicker({dateFormat: 'd/m/yy', showOn: 'button'});
109
    $('.datepicker input').datepicker({dateFormat: 'd/m/yy', showOn: 'button'});
110
    $('#id_description').attr('rows', '3');
111
    $('#id_description').attr('cols', '30');
112
    var deck = $('#id_participants_on_deck');
113
    $(deck).bind('added', function() {
114
      var added = $(deck).find('div:last');
115
      var t = added.attr('id').indexOf('_group:');
116
      if ( t == -1) return;
117

  
118
      /* remove group element and fake id */
119
      added.remove();
120
      var val = $('#id_participants').val();
121
      $('#id_participants').val(val.substr(0, val.substr(0, val.length-1).lastIndexOf('|')+1));
122

  
123
      /* add all workers */
124
      var query = added.attr('id').substr(t+1);
125
      var receive_result = $('#id_participants_text').autocomplete('option', 'select');
126
      $.getJSON($('#id_participants_text').autocomplete('option', 'source') + '?term=' + query,
127
        function(data) {
128
          $.each(data, function(key, val) {
129
            if (key==0) return; /* ignore first element as it's the group itself */
130
            var ui = Object();
131
            ui.item = val;
132
            receive_result(null, ui);
133
          });
134
        });
135

  
136
    });
137
  }
138

  
139 137
  $(on).load(url,
140 138
      function () {
141
        init_dialog();
139
        init_dialog(on);
142 140
        var old_background_image, old_background_repeat, $button;
143 141
        var in_submit = false;
144 142
        $(on).unbind('submit');
......
155 153
              $button.removeAttr('disabled');
156 154
              if ($('.errorlist', parse).length != 0) {
157 155
                $(on).html(data);
158
                init_dialog();
156
                init_dialog(on);
159 157
              } else {
160 158
                $('body').html(data);
161 159
              }

Also available in: Unified diff