Project

General

Profile

« Previous | Next » 

Revision cf65455c

Added by Jérôme Schneider over 11 years ago

agenda: fix update periodic events and appoinments

View differences:

calebasse/static/js/calebasse.agenda.js
195 195
          });
196 196
        return false;
197 197
      });
198
      $(base).on('click', '.update-periodic-event', function () {
199
        $('.ui-icon-closethick').click();
200
        // remove the form from previous hidden layer in order to prevent two
201
        // elements with 'id_date' id on the page
202
        $(this).parent().remove();
203

  
204
        var id = $(this).data('id');
205
        var delete_url = $(this).data('delete-url');
206
        generic_ajaxform_dialog('/' + service + '/' + app_name + '/' + current_date + '/update-periodic-event/' + id,
207
          'Modifier un évènement périodique', '#ajax-dlg', '900px', 'Modifier', null,
208
          function (dialog) {
209
            $('#ajax-dlg .datepicker-date').datepicker({dateFormat: 'd/m/yy', showOn: 'button'});
210
            var buttons = $(dialog).dialog('option', 'buttons');
211
            buttons.push({
212
              text: "Supprimer",
213
              id: "delete-btn",
214
              click: function () {
215
                var r = delete_prompt("Etes-vous sûr de vouloir supprimer cet évènement récurrent ?");
216
                if (r == true)
217
                {
218
                  $.ajax({
219
                    url: delete_url,
220
                    type: 'DELETE',
221
                    success: function(data) {
222
                        window.location.reload(true);
223
                        return false;
224
                    }
225
                  });
226
                }
227
              }
228
            });
229
            $(dialog).dialog('option', 'buttons', buttons);
230
          }
231
        );
232
      });
233
      $(base).on('click', '.update-periodic-rdv', function () {
234
        $('.ui-icon-closethick').click();
235
        var id = $(this).data('id');
236
        var delete_url = $(this).data('delete-url');
237
        generic_ajaxform_dialog('/' + service + '/' + app_name + '/' + current_date + '/update-periodic-rdv/' + id,
238
          'Modifier un rendez-vous périodique', '#ajax-dlg', '900px', 'Modifier', null,
239
          function (dialog) {
240
            $('#ajax-dlg .datepicker-date').datepicker({dateFormat: 'd/m/yy', showOn: 'button'});
241
            var buttons = $(dialog).dialog('option', 'buttons');
242
            buttons.push({
243
              text: "Supprimer",
244
             id: "delete-btn",
245
              click: function () {
246
                var r = delete_prompt("Etes-vous sûr de vouloir supprimer ce rendez-vous récurrent ?");
247
                if (r == true)
248
                {
249
                  $.ajax({
250
                    url: delete_url,
251
                    type: 'DELETE',
252
                    success: function(data) {
253
                        window.location.reload(true);
254
                        return false;
255
                    }
256
                  });
257
                }
258
              }
259
            });
260
            $(dialog).dialog('option', 'buttons', buttons);
261
          }
262
        );
263
      });
264 198
}
265 199

  
266 200
function toggle_ressource(ressource) {
......
331 265
}
332 266

  
333 267
function event_dialog(url, title, width, btn_text) {
334
    add_dialog('#ajax-dlg', url, title, width, btn_text);
268
    
269
    function add_periodic_events(base) {
270
      $(base).on('click', '.update-periodic-event', function () {
271
        $('.ui-icon-closethick').click();
272
        // remove the form from previous hidden layer in order to prevent two
273
        // elements with 'id_date' id on the page
274
        $(this).parent().remove();
275

  
276
        var id = $(this).data('id');
277
        var delete_url = $(this).data('delete-url');
278
        generic_ajaxform_dialog('/' + service + '/' + app_name + '/' + current_date + '/update-periodic-event/' + id,
279
          'Modifier un évènement périodique', '#ajax-dlg', '900px', 'Modifier', null,
280
          function (dialog) {
281
            $('#ajax-dlg .datepicker-date').datepicker({dateFormat: 'd/m/yy', showOn: 'button'});
282
            var buttons = $(dialog).dialog('option', 'buttons');
283
            buttons.push({
284
              text: "Supprimer",
285
              id: "delete-btn",
286
              click: function () {
287
                var r = delete_prompt("Etes-vous sûr de vouloir supprimer cet évènement récurrent ?");
288
                if (r == true)
289
                {
290
                  $.ajax({
291
                    url: delete_url,
292
                    type: 'DELETE',
293
                    success: function(data) {
294
                        window.location.reload(true);
295
                        return false;
296
                    }
297
                  });
298
                }
299
              }
300
            });
301
            $(dialog).dialog('option', 'buttons', buttons);
302
          }
303
        );
304
      });
305
      $(base).on('click', '.update-periodic-rdv', function () {
306
        $('.ui-icon-closethick').click();
307
        var id = $(this).data('id');
308
        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 () {
318
                var r = delete_prompt("Etes-vous sûr de vouloir supprimer ce rendez-vous récurrent ?");
319
                if (r == true)
320
                {
321
                  $.ajax({
322
                    url: delete_url,
323
                    type: 'DELETE',
324
                    success: function(data) {
325
                        window.location.reload(true);
326
                        return false;
327
                    }
328
                  });
329
                }
330
              }
331
            });
332
            $(dialog).dialog('option', 'buttons', buttons);
333
          }
334
        );
335
      });
336
    }
337

  
338
    generic_ajaxform_dialog(url, title, '#ajax-dlg', width, btn_text, null,
339
          add_periodic_events);
340

  
335 341
}
336 342

  
337 343
(function($) {

Also available in: Unified diff