Projet

Général

Profil

« Précédent | Suivant » 

Révision 4e7cbf81

Ajouté par Jérôme Schneider il y a environ 10 ans

dossiers: continue to re-enable js for patientrecord tabs

Refs #2357

Voir les différences:

calebasse/static/js/calebasse.dossiers.js
126 126
        generic_ajaxform_dialog('protection/' + $(this).data('id') + '/del', 'Supprimer une mesure de protection',
127 127
            '#ajax-dlg', '500px', 'Supprimer');
128 128
    });
129
    $('input#id_id-birthdate', this).datepicker({dateFormat: 'd/m/yy', showOn: 'button' });
129 130
}
130 131

  
131 132
function load_tab3_addresses(tab) {
133
    $('.policyholder-radio').click(function() {
134
        $("#policyholder-form").submit();
135
    });
136
    $('#new-contact-btn').click(function() {
137
        generic_ajaxform_dialog('contact/new', 'Ajouter un contact',
138
            '#ajax-dlg', '900px', 'Ajouter', null, nir_check);
139
    });
140
    $('.update-contact-btn').click(function() {
141
        generic_ajaxform_dialog('contact/' + $(this).data('id') + '/update', 'Modifier un contact',
142
            '#ajax-dlg', '800px', 'Modifier', null, nir_check);
143
    });
144
    $('.del-contact').click(function() {
145
        generic_ajaxform_dialog('contact/' + $(this).data('id') + '/del?address=' + $(this).data('address-id'),
146
                'Supprimer un contact', '#ajax-dlg', '500px', 'Supprimer');
147
    });
148
    $('#new-address-btn').click(function() {
149
        generic_ajaxform_dialog('address/new', 'Ajouter une adresse',
150
            '#ajax-dlg', '600px', 'Ajouter');
151
    });
152
    $('.update-address-btn').click(function() {
153
        generic_ajaxform_dialog('address/' + $(this).data('id') + '/update', 'Modifier une adresse',
154
            '#ajax-dlg', '600px', 'Modifier');
155
    });
156
    $('.del-address').click(function() {
157
        generic_ajaxform_dialog('address/' + $(this).data('id') + '/del', 'Supprimer une addresse',
158
            '#ajax-dlg', '500px', 'Supprimer');
159
    });
160

  
161

  
162
    function nir_check(that) {
163
      $(that).find('#social-security-id input').keyup(function() {
164
        if ($(this).val().length < 13) {
165
             $('p#nir-key span').removeAttr('id')
166
             $('p#nir-key span').text('-');
167
         } else {
168
             $('p#nir-key span').attr('id', 'highlight')
169
             var nir = $(this).val();
170
             var minus = 0;
171
             if (nir.charAt(6) == 'A'){
172
               nir = nir.replace('A', '0');
173
               minus = 1000000;
174
             }
175
             if (nir.charAt(6) == 'B'){
176
               nir = nir.replace('B', '0');
177
               minus = 2000000;
178
             }
179
             nir = parseInt(nir, 10);
180
             nir = nir - minus;
181
             var key = 97 - (nir % 97);
182
             if (isNaN(key)) {
183
                 $('p#nir-key span').text('NIR invalide');
184
             } else {
185
                 $('p#nir-key span').text(key);
186
             }
187
         }
188
      });
189
    }
190
      $('.place_of_life').click(function() {
191
          if ((this.checked) == true) {
192
              var value = "true";
193
          } else {
194
              var value = "false";
195
          }
196
          var prev = $(this).prev();
197
          $.ajax({
198
              url: '/api/v1/patientaddress/' + $(this).data("id") + '/?format=json',
199
              type: 'PATCH',
200
              contentType: 'application/json',
201
              data: '{"place_of_life": ' + value + '}',
202
              success: function(data) {
203
                (prev).show();
204
                (prev).html('<li>Modification appliquée avec succés</li>');
205
                $('.ajax_messages').delay(1500).fadeOut('slow');
206
                location.reload();
207
              }
208
          });
209
      });
210
    $('.social-security-label').click(function() {
211
      var label = $(this).html();
212
      var data = $(this).next();
213
      if (($(data).is(':hidden'))) {
214
        $(this).html(label.replace('+', '-'));
215
        $(this).css("font-weight", "bold");
216
      } else {
217
        $(this).html(label.replace('-', '+'));
218
        $(this).css("font-weight", "");
219
      }
220
      $(data).toggle();
221
    });
132 222
}
223

  
133 224
function load_tab4_notifs(tab) {
134 225
}
135 226
function load_tab5_last_acts(tab) {
......
183 274
        $("#search").click();
184 275
    });
185 276

  
186
    $('.policyholder-radio').click(function() {
187
        $("#policyholder-form").submit();
188
    });
189 277
    $('.pr-line').click(function() {
190 278
        window.open($(this).data('link'), $(this).data('link'));
191 279
    });
......
223 311
            '#ajax-dlg', '500px', 'Oui', '..');
224 312
    });
225 313

  
226
    $('#new-address-btn').click(function() {
227
        generic_ajaxform_dialog('address/new', 'Ajouter une adresse',
228
            '#ajax-dlg', '600px', 'Ajouter');
229
    });
230
    $('.update-address-btn').click(function() {
231
        generic_ajaxform_dialog('address/' + $(this).data('id') + '/update', 'Modifier une adresse',
232
            '#ajax-dlg', '600px', 'Modifier');
233
    });
234
    $('.del-address').click(function() {
235
        generic_ajaxform_dialog('address/' + $(this).data('id') + '/del', 'Supprimer une addresse',
236
            '#ajax-dlg', '500px', 'Supprimer');
237
    });
238

  
239

  
240
    function nir_check(that) {
241
      $(that).find('#social-security-id input').keyup(function() {
242
        if ($(this).val().length < 13) {
243
             $('p#nir-key span').removeAttr('id')
244
             $('p#nir-key span').text('-');
245
         } else {
246
             $('p#nir-key span').attr('id', 'highlight')
247
             var nir = $(this).val();
248
             var minus = 0;
249
             if (nir.charAt(6) == 'A'){
250
               nir = nir.replace('A', '0');
251
               minus = 1000000;
252
             }
253
             if (nir.charAt(6) == 'B'){
254
               nir = nir.replace('B', '0');
255
               minus = 2000000;
256
             }
257
             nir = parseInt(nir, 10);
258
             nir = nir - minus;
259
             var key = 97 - (nir % 97);
260
             if (isNaN(key)) {
261
                 $('p#nir-key span').text('NIR invalide');
262
             } else {
263
                 $('p#nir-key span').text(key);
264
             }
265
         }
266
      });
267
    }
268 314

  
269
    $('#new-contact-btn').click(function() {
270
        generic_ajaxform_dialog('contact/new', 'Ajouter un contact',
271
            '#ajax-dlg', '900px', 'Ajouter', null, nir_check);
272
    });
273
    $('.update-contact-btn').click(function() {
274
        generic_ajaxform_dialog('contact/' + $(this).data('id') + '/update', 'Modifier un contact',
275
            '#ajax-dlg', '800px', 'Modifier', null, nir_check);
276
    });
277
    $('.del-contact').click(function() {
278
        generic_ajaxform_dialog('contact/' + $(this).data('id') + '/del?address=' + $(this).data('address-id'),
279
                'Supprimer un contact', '#ajax-dlg', '500px', 'Supprimer');
280
    });
281 315
    $('#new-socialisation-duration-btn').click(function() {
282 316
        generic_ajaxform_dialog('socialisation/new', 'Ajouter une période de socialisation',
283 317
            '#ajax-dlg', '800px', 'Ajouter', null, add_datepickers);
......
361 395
    });
362 396

  
363 397

  
364
      $('.place_of_life').click(function() {
365
          if ((this.checked) == true) {
366
              var value = "true";
367
          } else {
368
              var value = "false";
369
          }
370
          var prev = $(this).prev();
371
          $.ajax({
372
              url: '/api/v1/patientaddress/' + $(this).data("id") + '/?format=json',
373
              type: 'PATCH',
374
              contentType: 'application/json',
375
              data: '{"place_of_life": ' + value + '}',
376
              success: function(data) {
377
                (prev).show();
378
                (prev).html('<li>Modification appliquée avec succés</li>');
379
                $('.ajax_messages').delay(1500).fadeOut('slow');
380
                location.reload();
381
              }
382
          });
383
      });
384 398

  
385
    $('input#id_id-birthdate', this).datepicker({dateFormat: 'd/m/yy', showOn: 'button' });
386 399

  
387 400
    $('button.blind').next().hide();
388 401
    $('button.blind').click(function() {
389 402
      $(this).next().toggle('blind');
390 403
    });
391
    $('.social-security-label').click(function() {
392
      var label = $(this).html();
393
      var data = $(this).next();
394
      if (($(data).is(':hidden'))) {
395
        $(this).html(label.replace('+', '-'));
396
        $(this).css("font-weight", "bold");
397
      } else {
398
        $(this).html(label.replace('-', '+'));
399
        $(this).css("font-weight", "");
400
      }
401
      $(data).toggle();
402
    });
403 404
    var tabid = $.url($(location).attr('href')).fparam('tab');
404 405
      if (tabid) {
405 406
        $tabs.tabs('select',  parseInt(tabid));

Formats disponibles : Unified diff