Project

General

Profile

« Previous | Next » 

Revision 31541882

Added by Serghei Mihai about 10 years ago

ajaxfom dialog function updated

View differences:

calebasse/actes/templates/actes/act_listing.html
11 11
            if ($(this).data('isbilled') == "False")
12 12
            {
13 13
                var id = $(this).data('id');
14
                generic_ajaxform_dialog($(this).data('id') + '/update', "Modifier l'acte",
15
                '#acte-dlg', '700px', 'Modifier', '.',
16
                function (dialog) {
17
                    var buttons = $(dialog).dialog('option', 'buttons');
18
                    buttons.push({
19
                        text: "Supprimer",
20
                        id: "delete-btn",
21
                        click: function () {
22
                            $(dialog).dialog('close');
23
                            generic_ajaxform_dialog(id + '/delete', "Supprimer l'acte",
24
                            '#acte-dlg', '500px', 'Oui', window.location.href);
14
                var delete_button = {
15
                    text: "Supprimer",
16
                    id: "delete-btn",
17
                    click: function () {
18
                        $(dialog).dialog('close');
19
                        generic_ajaxform_dialog(id + '/delete', "Supprimer l'acte",
20
                                                '#acte-dlg', '500px', 'Oui', window.location.href);
25 21

  
26
                        }
27
                    });
28
                    $(dialog).dialog('option', 'buttons', buttons);
29
                }
30
                );
22
                    }
23
                };
24
                generic_ajaxform_dialog($(this).data('id') + '/update', "Modifier l'acte",
25
                '#acte-dlg', '700px', 'Modifier', '.', function (dialog) {});
31 26
                } else if ($(this).data('oldbilled') == "True") {
32 27
                generic_ajaxform_dialog($(this).data('id') + '/rebill', "Refacturer cet acte de l'ancienne facturation) ?",
33 28
                '#acte-dlg', '700px', 'Refacturer', '.');
calebasse/static/js/calebasse.agenda.js
274 274

  
275 275
        var id = $(this).data('id');
276 276
        var delete_url = $(this).data('delete-url');
277
        generic_ajaxform_dialog('/' + service + '/' + app_name + '/' + current_date + '/update-periodic-event/' + id,
278
          'Modifier un évènement périodique', '#ajax-dlg', '900px', 'Modifier', null,
279
          function (dialog) {
280
            $('#ajax-dlg .datepicker-date').datepicker({dateFormat: 'd/m/yy', showOn: 'button'});
281
            var buttons = $(dialog).dialog('option', 'buttons');
282
            var delete_button = {
283
              text: "Supprimer",
284
              id: "delete-btn",
285
              click: function () {
277
        var delete_button = {
278
            text: "Supprimer",
279
            id: "delete-btn",
280
            click: function () {
286 281
                var r = delete_prompt("Etes-vous sûr de vouloir supprimer cet évènement récurrent ?");
287 282
                if (r == true)
288 283
                {
......
297 292
                }
298 293
              }
299 294
            };
300
            buttons.push(delete_button);
301
            $(dialog).dialog('option', 'buttons', buttons);
302
          }
295
        generic_ajaxform_dialog('/' + service + '/' + app_name + '/' + current_date + '/update-periodic-event/' + id,
296
          'Modifier un évènement périodique', '#ajax-dlg', '900px', 'Modifier', null,
297
          function (dialog) {
298
            $('#ajax-dlg .datepicker-date').datepicker({dateFormat: 'd/m/yy', showOn: 'button'});
299
          }, null, delete_button
303 300
        );
304 301
      });
305 302
      $(base).on('click', '.update-periodic-rdv', function () {
306 303
        $('.ui-icon-closethick').click();
307 304
        var id = $(this).data('id');
308 305
        var delete_url = $(this).data('delete-url');
309
        generic_ajaxform_dialog('/' + service + '/' + app_name + '/' + current_date + '/update-periodic-rdv/' + id,
310
          'Modifier un rendez-vous périodique', '#ajax-dlg', '900px', 'Modifier', null,
311
          function (dialog) {
312
            $('#ajax-dlg .datepicker-date').datepicker({dateFormat: 'd/m/yy', showOn: 'button'});
313
            var buttons = $(dialog).dialog('option', 'buttons');
314
            buttons.push({
315
              text: "Supprimer",
316
             id: "delete-btn",
317
              click: function () {
306
        var delete_button = {
307
            text: "Supprimer",
308
            id: "delete-btn",
309
            click: function () {
318 310
                var r = delete_prompt("Etes-vous sûr de vouloir supprimer ce rendez-vous récurrent ?");
319 311
                if (r == true)
320 312
                {
......
327 319
                    }
328 320
                  });
329 321
                }
330
              }
331
            });
332
            $(dialog).dialog('option', 'buttons', buttons);
333
          }
322
            }
323
        };
324
        generic_ajaxform_dialog('/' + service + '/' + app_name + '/' + current_date + '/update-periodic-rdv/' + id,
325
          'Modifier un rendez-vous périodique', '#ajax-dlg', '900px', 'Modifier', null,
326
          function (dialog) {
327
            $('#ajax-dlg .datepicker-date').datepicker({dateFormat: 'd/m/yy', showOn: 'button'});
328
          }, null, delete_button
334 329
        );
335 330
      });
336 331
    }
calebasse/static/js/calebasse.dialog.js
17 17
  $button.removeAttr('disabled');
18 18
}
19 19

  
20
function generic_ajaxform_dialog(url, title, id, width, btn_submit_name, redirectToUrl, on_load_callback, height) {
20
function generic_ajaxform_dialog(url, title, id, width, btn_submit_name, redirectToUrl, on_load_callback, height, extra_button) {
21 21
  if (! height)
22 22
    height = 'auto';
23 23
  $(id).load(url,
......
53 53
        $('form', this).ajaxForm({
54 54
          success: onsuccess,
55 55
        });
56
        var buttons = [{text: "Annuler",
57
                        id: "close-btn",
58
                        click: function() { $(this).dialog("close"); } },
59
                       {text:btn_submit_name,
60
                        id: "submit-btn",
61
                        click: function() {
62
                            disable_button($('#submit-btn'));
63
                            $(id + " form").submit();
64
                        }}];
65

  
66
        if (extra_button)
67
            buttons.push(extra_button);
56 68
        $(this).dialog({title: title,
57 69
          modal: true,
58 70
          width: width,
59 71
          height: height,
60
          buttons: [ { text: "Annuler",
61
            id: "close-btn",
62
          click: function() { $(this).dialog("close"); } },
63
          { text: btn_submit_name,
64
            id: "submit-btn",
65
          click: function() {
66
            disable_button($('#submit-btn'));
67
            $(id + " form").submit(); 
68
          } }]});
72
          buttons: buttons});
69 73
        if (on_load_callback) {
70 74
          on_load_callback($(this));
71 75
        }

Also available in: Unified diff