Project

General

Profile

« Previous | Next » 

Revision edda5421

Added by Serghei Mihai over 10 years ago

agenda; rooms availability bar added.

Closes #3690

View differences:

calebasse/agenda/templates/agenda/index.html
34 34
     <dd><ul>
35 35
       {% for worker in workers_type.workers %}
36 36
       {% if worker|is_worker_in_service:service_name and worker|is_intervenant %}
37
       <li id="selector-worker-{{worker.id}}" class="person-item in_service intervenant" data-worker-id="{{worker.id}}" data-target=".worker-{{worker.id}}.agenda">{{ worker.first_name }} <span class="lastname">{{ worker.last_name }}</span>{% if not worker.services.all %} (Ext){% endif %} <span class="toggle" title="cliquer pour déselectionner">(-)</span></li>
37
       <li id="selector-worker-{{worker.id}}" class="worker-item in_service intervenant" data-worker-id="{{worker.id}}" data-target=".worker-{{worker.id}}.agenda">{{ worker.first_name }} <span class="lastname">{{ worker.last_name }}</span>{% if not worker.services.all %} (Ext){% endif %} <span class="toggle" title="cliquer pour déselectionner">(-)</span></li>
38 38
       {% elif worker|is_worker_in_service:service_name %}
39
       <li id="selector-worker-{{worker.id}}" class="person-item in_service" data-worker-id="{{worker.id}}" data-target=".worker-{{worker.id}}.agenda">{{ worker.first_name }} <span class="lastname">{{ worker.last_name }}</span>{% if not worker.services.all %} (Ext){% endif %} <span class="toggle" title="cliquer pour déselectionner">(-)</span></li>
39
       <li id="selector-worker-{{worker.id}}" class="worker-item in_service" data-worker-id="{{worker.id}}" data-target=".worker-{{worker.id}}.agenda">{{ worker.first_name }} <span class="lastname">{{ worker.last_name }}</span>{% if not worker.services.all %} (Ext){% endif %} <span class="toggle" title="cliquer pour déselectionner">(-)</span></li>
40 40
       {% elif worker|is_intervenant %}
41
       <li id="selector-worker-{{worker.id}}" class="person-item intervenant" data-worker-id="{{worker.id}}" data-target=".worker-{{worker.id}}.agenda">{{ worker.first_name }} <span class="lastname">{{ worker.last_name }}</span>{% if not worker.services.all %} (Ext){% endif %} <span class="toggle" title="cliquer pour déselectionner">(-)</span></li>
41
       <li id="selector-worker-{{worker.id}}" class="worker-item intervenant" data-worker-id="{{worker.id}}" data-target=".worker-{{worker.id}}.agenda">{{ worker.first_name }} <span class="lastname">{{ worker.last_name }}</span>{% if not worker.services.all %} (Ext){% endif %} <span class="toggle" title="cliquer pour déselectionner">(-)</span></li>
42 42
       {% else %}
43
       <li id="selector-worker-{{worker.id}}" class="person-item" data-worker-id="{{worker.id}}" data-target=".worker-{{worker.id}}.agenda">{{ worker.first_name }} <span class="lastname">{{ worker.last_name }}</span>{% if not worker.services.all %} (Ext){% endif %} <span class="toggle" title="cliquer pour déselectionner">(-)</span></li>
43
       <li id="selector-worker-{{worker.id}}" class="worker-item" data-worker-id="{{worker.id}}" data-target=".worker-{{worker.id}}.agenda">{{ worker.first_name }} <span class="lastname">{{ worker.last_name }}</span>{% if not worker.services.all %} (Ext){% endif %} <span class="toggle" title="cliquer pour déselectionner">(-)</span></li>
44 44
       {% endif %}
45 45
       {% endfor %}
46 46
     </ul></dd>
......
63 63
    <tbody>
64 64
    <tr>
65 65
     <td id="dispos">
66
       <button id="close-all-agendas" style="display: none">Fermer tous les agendas</button>
66
       <button id="close-all-worker-agendas" style="display: none">Fermer tous les agendas</button>
67 67
      Disponibilités
68 68
      <table>
69 69
        <tr class="initials"><td></td></tr>
calebasse/agenda/templates/agenda/ressources.html
32 32
    <tbody>
33 33
    <tr>
34 34
     <td id="dispos">
35
       <button id="close-all-ressource-agendas" style="display: none">Fermer tous les agendas</button>
36
       Disponibilités
37
       <table>
38
         <tr class="initials"><td></td></tr>
39
         {% for start_time in disponibility_start_times %}
40
         <tr class="hour-mark">
41
           <td rowspan="4">{{ start_time }}:00</td>
42
         </tr>
43
         <tr></tr>
44
         <tr></tr>
45
         <tr></tr>
46
         {% endfor %}
47
       </table>
35 48
     </td>
36 49

  
37 50
     <td id="agendas">
calebasse/static/js/calebasse.agenda.js
86 86
        return false;
87 87
      });
88 88
      $(base).find('.newrdv').click(function() {
89
          var participants = $('.person-item.active').map(function (i, v) { return $(v).data('worker-id'); });
89
          var participants = $('.worker-item.active').map(function (i, v) { return $(v).data('worker-id'); });
90 90
          var qs = $.param({participants: $.makeArray(participants),
91 91
                            room: $.cookie('active-ressource-agenda'),
92 92
                            time: $(this).data('hour') }, true);
......
98 98
          return false;
99 99
      });
100 100
      $(base).find('.newevent').click(function() {
101
          var participants = $('.person-item.active').map(function (i, v) { return $(v).data('worker-id'); });
101
          var participants = $('.worker-item.active').map(function (i, v) { return $(v).data('worker-id'); });
102 102
          var qs = $.param({participants: $.makeArray(participants),
103 103
                            room: $.cookie('active-ressource-agenda'),
104 104
                            time: $(this).data('hour') }, true);
......
221 221
    };
222 222
}
223 223

  
224
function toggle_worker(worker_selector) {
225
    var worker_id = $(worker_selector).data('worker-id');
226
    if (!worker_id) {
227
        return;
228
    }
229

  
230
    $(worker_selector).toggleClass('active');
231
    if (!($.cookie('agenda-worker-tabs'))) {
232
        $.cookie('agenda-worker-tabs', new Array(), {path: COOKIE_PATH});
233
    }
234
    if ($(worker_selector).hasClass('active')) {
235
        var tabs = $.cookie('agenda-worker-tabs');
236
        if ($.inArray($(worker_selector).attr('id'), tabs) == -1)
237
        {
238
            tabs.push($(worker_selector).attr('id'));
239
            $.cookie('agenda-worker-tabs', tabs, { path: COOKIE_PATH });
240
        }
241
    }
242
    else {
243
        var agendatabs = $.cookie('agenda-worker-tabs');
244
        var ok = false;
245
        $.each(agendatabs, function (i, value) {
246
            if (value == $(worker_selector).attr('id')) {
247
                agendatabs.splice(i, 1);
248
                ok = true;
249
            }
250
        });
251
        $.cookie('agenda-worker-tabs', agendatabs, {path: COOKIE_PATH});
252
    }
253
    var target = $($(worker_selector).data('target'));
254
    target.toggle();
255
    /* Show the close all button */
256
    $('#close-all-agendas').toggle($('li.agenda:visible').length != 0);
224
function toggle_ressource(ressource_selector, ressource) {
257 225

  
258
    var tab = $('#link-tab-worker-' + worker_id).parent().get(0);
259
    var tab_list = $(tab).parent().get(0);
260
    $(tab).detach().appendTo(tab_list);
261

  
262
    if ($('#tabs-worker-' + worker_id + ' .worker-tab-content-placeholder').length) {
263
        /* load worker appointments tab */
264
        $('#tabs-worker-' + worker_id).load('ajax-worker-tab/' + worker_id,
265
            function () {
266
               $(this).children('div').accordion({active: false, autoHeight: false, collapsible: true});
267
               enable_events(this);
268
            }
269
        );
270
        /* load worker disponibility column */
271
        $.get('ajax-worker-disponibility-column/' + worker_id,
272
            function(data) {
273
                var dispo_table_rows = $('td#dispos table tr');
274
                all_td = $(data).find('td');
275
                for (var i=0; i<all_td.length; i++) {
276
                    $(dispo_table_rows[i]).append(all_td[i]);
277
                }
278
            }
279
        );
280
    }
281
    return target.find('a.tab');
282
}
283

  
284
function toggle_ressource(ressource_selector) {
285
    var ressource_id = $(ressource_selector).data('ressource-id');
226
   var ressource_id = $(ressource_selector).data(ressource + '-id');
286 227
    if (!ressource_id) {
287 228
        return;
288 229
    }
289 230

  
290 231
    $(ressource_selector).toggleClass('active');
291
    if (!($.cookie('agenda-ressource-tabs'))) {
292
        $.cookie('agenda-ressource-tabs', new Array(), { path: COOKIE_PATH });
232
    if (!($.cookie('agenda-' + ressource + '-tabs'))) {
233
        $.cookie('agenda-' + ressource + '-tabs', new Array(), { path: COOKIE_PATH });
293 234
    }
294 235
    if ($(ressource_selector).hasClass('active')) {
295
        var tabs = $.cookie('agenda-ressource-tabs');
236
        var tabs = $.cookie('agenda-' + ressource + '-tabs');
296 237
        if ($.inArray($(ressource_selector).attr('id'), tabs) == -1)
297 238
        {
298 239
            tabs.push($(ressource_selector).attr('id'));
299
            $.cookie('agenda-ressource-tabs', tabs, { path: COOKIE_PATH });
240
            $.cookie('agenda-' + ressource + '-tabs', tabs, { path: COOKIE_PATH });
300 241
        }
301 242
    }
302 243
    else {
303
        var agendatabs = $.cookie('agenda-ressource-tabs');
244
        var agendatabs = $.cookie('agenda-' + ressource + '-tabs');
304 245
        $.each(agendatabs, function (i, value) {
305 246
            if (value == $(ressource_selector).attr('id')) {
306 247
                agendatabs.splice(i, 1);
307 248
            }
308 249
        });
309
        $.cookie('agenda-ressource-tabs', agendatabs, { path: COOKIE_PATH });
250
        $.cookie('agenda-' + ressource + '-tabs', agendatabs, { path: COOKIE_PATH });
310 251
    }
311 252
    var target = $($(ressource_selector).data('target'));
312 253
    target.toggle();
254
    $('#close-all-' + ressource + '-agendas').toggle($('li.agenda:visible').length != 0);
313 255

  
314
    var tab = $('#link-tab-ressource-' + ressource_id).parent().get(0);
256
    var tab = $('#link-tab-' + ressource + '-' + ressource_id).parent().get(0);
315 257
    var tab_list = $(tab).parent().get(0);
316 258
    $(tab).detach().appendTo(tab_list);
317 259

  
318
    if ($('#tabs-ressource-' + ressource_id + ' .ressource-tab-content-placeholder').length) {
260
    if ($('#tabs-' + ressource + '-' + ressource_id + ' .' + ressource + '-tab-content-placeholder').length) {
319 261
        /* load ressource appointments tab */
320
        $('#tabs-ressource-' + ressource_id).load('ajax-ressource-tab/' + ressource_id,
262
        $('#tabs-' + ressource + '-' + ressource_id).load('ajax-' + ressource + '-tab/' + ressource_id,
321 263
            function () {
322 264
               $(this).children('div').accordion({active: false, autoHeight: false});
323 265
               enable_events(this);
324 266
            }
325 267
        );
326 268
        /* load ressource disponibility column */
327
        $.get('ajax-ressource-disponibility-column/' + ressource_id,
269
        $.get('ajax-' + ressource + '-disponibility-column/' + ressource_id,
328 270
            function(data) {
329 271
                var dispo_table_rows = $('td#dispos table tr');
330 272
                $(data).find('td').each(function(a, b) {
......
340 282
    return target.find('a.tab');
341 283
}
342 284

  
343

  
344 285
function event_dialog(url, title, width, btn_text) {
345 286
    add_dialog('#rdv', url, title, width, btn_text);
346 287
}
......
351 292

  
352 293
      $('#tabs').ajaxStop(function() { reorder_disponibility_columns(); });
353 294

  
354
      if ($('.person-item').length) {
355
          $('.person-item').on('click', function() {
356
              var target = toggle_worker(this);
295
      if ($('.worker-item').length) {
296
          $('.worker-item').on('click', function() {
297
              var target = toggle_ressource(this, 'worker');
357 298
              if ($(target).is(':visible')) {
358 299
                  $(target).click();
359 300
              }
......
373 314

  
374 315
          if ($.cookie('agenda-worker-tabs')) {
375 316
              $.each($.cookie('agenda-worker-tabs'), function (i, worker_selector) {
376
                  toggle_worker('#' + worker_selector);
317
                  toggle_ressource('#' + worker_selector, 'worker');
377 318
              });
378 319
              if ($.cookie('active-worker-agenda'))
379 320
              {
......
387 328

  
388 329
      if ($('.ressource-item').length) {
389 330
          $('.ressource-item').on('click', function() {
390
              var target = toggle_ressource(this);
331
              var target = toggle_ressource(this, 'ressource');
391 332
              if ($(target).is(':visible')) {
392 333
                  $(target).click();
393 334
              }
......
406 347

  
407 348
          if ($.cookie('agenda-ressource-tabs')) {
408 349
              $.each($.cookie('agenda-ressource-tabs'), function (i, ressource_selector) {
409
                  toggle_ressource('#' + ressource_selector);
350
                  toggle_ressource('#' + ressource_selector, 'ressource');
410 351
              });
411 352
              if ($.cookie('active-ressource-agenda'))
412 353
              {
......
449 390
          } else {
450 391
              $('#users li').show();
451 392
              if (! everybody) {
452
                  $('.person-item:not(.in_service)').hide();
453
                  $('.person-item:not(.intervenant)').hide();
393
                  $('.worker-item:not(.in_service)').hide();
394
                  $('.worker-item:not(.intervenant)').hide();
454 395
              }
455 396
          }
456 397
          /* hide worker type titles that do not have a single visible person */
......
478 419
      ($(this).data('previous') == $(this).val()));
479 420
    })
480 421
    $('#filtre input').keyup();
481
    $('#close-all-agendas').click(function () {
482
      $('.person-item.active').each(function (i, v) {
483
        toggle_worker(v);
484
      });
485
    });
422

  
423
    $.each({'persons': {'button': 'worker', 'element': 'worker'},
424
            'rooms': {'button': 'ressource', 'element': 'ressource'}
425
           },
426
         function(key, value) {
427
             $('#close-all-' + value.button + '-agendas').click(function() {
428
                 $('.' + value.element + '-item.active').each(function (i, v) {
429
                     toggle_ressource(v, value.element);
430
                 });
431
             });
432
         });
486 433
  });
487 434
})(window.jQuery)

Also available in: Unified diff