Projet

Général

Profil

« Précédent | Suivant » 

Révision bbf89bd4

Ajouté par Jérôme Schneider il y a plus de 9 ans

dossiers: show an alert when closing without saving

Closes #2740

Voir les différences:

calebasse/dossiers/templates/dossiers/patientrecord_tab1_general.html
89 89
      <button type="button" id="patientrecord-history">Historique</button>
90 90
      <hr/>
91 91
      <p id="confidential-msg" style="display: none; font-size: 10px;">Confidentialité mise à jour</p>
92
      {{ form.confidential.label_tag }} : {{ form.confidential }}
92
      {{ form.confidential.label_tag }} : <span class="autosubmit">{{ form.confidential }}</span>
93 93
      <p id="pause-msg" style="display: none; font-size: 10px;">Pause facturation mise à jour</p>
94 94
      {{ form.pause.label_tag }} : {{ form.pause }}
95 95
      <br/><label>Commentaire de la pause facturation</label> <button class="save enable-on-change btn-maj">✔</button><br/>
calebasse/static/js/calebasse.dossiers.js
43 43
      '#address-dlg', '600px', 'Ajouter');
44 44
}
45 45

  
46
function warning_on_unsave_change() {
47
    var form_changed = false;
48
    $(window).on("beforeunload", function() {
49
        if (form_changed) {
50
            return "Vous n'avez pas enregistré vos changements.";
51
        }
52
    });
53
    $("#tabs").on("tabsbeforeactivate", function(event, ui) {
54
        if (form_changed) {
55
            var answer = confirm('Vous avez des changements non sauvegardés. Voulez vous vraiment continuer ?');
56
            if (! answer) {
57
                event.preventDefault();
58
            }
59
            else {
60
                form_changed = false;
61
            }
62
        }
63
    });
64
    $('.autosubmit').on("click", function() {
65
        form_changed = false;
66
    });
67
    $('form').on("change", function() {
68
        form_changed = true;
69
    });
70
    $('button').on("click", function() {
71
        form_changed = false;
72
    });
73
}
74

  
46 75
function state_dialog(url, state_title, state_type) {
47 76
    $('#change-record').load(url,
48 77
            function () {
......
80 109
}
81 110

  
82 111
function load_tab1_general() {
112
    warning_on_unsave_change();
83 113
    $('#update-paper-id-btn').click(function() {
84 114
        generic_ajaxform_dialog('update/paper_id', 'Modifier le numéro du dossier papier',
85 115
            '#ajax-dlg', '500px', 'Modifier');
......
122 152
      $('#patientrecord-history').click();
123 153
      location.hash = '';
124 154
    }
125
    $('#id_pause').click(function() {
126
        $('#general-form').submit();
127
    });
128
    $('#id_confidential').click(function() {
155
    $('.autosubmit').click(function() {
129 156
        $('#general-form').submit();
130 157
    });
131 158
}
132 159

  
133 160
function load_tab2_adm() {
161
    warning_on_unsave_change();
134 162
    init_magic_dialog();
135 163
    $('#prescription-transport-btn').click(function() {
136 164
        $('#ajax-dlg').load('prescription-transport',
......
351 379

  
352 380
function load_tab8_medical() {
353 381
  calebasse_ajax_form('#tabs-8');
354
  SelectFilter.init("id_mises_1", "Catégorie", 0, "/static/admin/");
355
  SelectFilter.init("id_mises_2", "Catégorie", 0, "/static/admin/");
356
  SelectFilter.init("id_mises_3", "Catégorie", 0, "/static/admin/");
382
  warning_on_unsave_change();
357 383
}
358 384

  
359 385

  
......
380 406
    });
381 407

  
382 408

  
383
    $('.atabs').click(function() {
384
        location.hash = 'tab=' + $(this).data('id');
409
    $('#tabs').on("tabsload", function(event, ui) {
410
        location.hash = 'tab=' + $(ui.tab).data('id');
385 411
    });
386 412

  
387 413
    $('#btn_all_state').click(function() {

Formats disponibles : Unified diff