Projet

Général

Profil

0001-backoffice-require-a-second-explicit-click-to-select.patch

Frédéric Péters, 29 novembre 2019 14:51

Télécharger (2,7 ko)

Voir les différences:

Subject: [PATCH] backoffice: require a second explicit click to select all
 items (#38057)

 wcs/forms/backoffice.py             | 6 +++---
 wcs/qommon/static/js/wcs.listing.js | 7 +++++--
 2 files changed, 8 insertions(+), 5 deletions(-)
wcs/forms/backoffice.py
91 91
        else:
92 92
            r += htmltext('<th></th>') # lock
93 93
        if include_checkboxes:
94
            r += htmltext('<th class="select"><input type="checkbox" name="select[]" value="_all"/>')
95
            r += htmltext(' <span id="info-all-rows">%s</span></th>') % _(
96
                    'Do note the selected action will run on all pages when this is checked.')
94
            r += htmltext('<th class="select"><input type="checkbox" id="top-select"/>')
95
            r += htmltext(' <span id="info-all-rows"><label><input type="checkbox" name="select[]" value="_all"/> %s</label></span></th>') % _(
96
                    'Run selected action on all pages')
97 97
        for f in fields:
98 98
            field_sort_key = None
99 99
            if getattr(f, 'fake', False):
wcs/qommon/static/js/wcs.listing.js
47 47
  });
48 48
  $('#listing input[type=checkbox]').on('change', function() {
49 49
    if ($(this).is(':checked')) {
50
      if ($(this).is('[value=_all]')) {
50
      if ($(this).is('#top-select')) {
51 51
        $(this).parents('table').find('tbody td.select input').prop('checked', true);
52 52
        $(this).parents('table').find('tbody tr').addClass('checked');
53 53
      } else {
54 54
        $(this).parents('tr').addClass('checked');
55 55
      }
56 56
    } else {
57
      if ($(this).is('[value=_all]')) {
57
      if ($(this).is('#top-select')) {
58 58
        $(this).parents('table').find('tbody td.select input').prop('checked', false);
59 59
        $(this).parents('table').find('tbody tr').removeClass('checked');
60
      } else if ($(this).is('[value=_all]')) {
61
        // do nothing particular when unchecking "all"
60 62
      } else {
61 63
        $(this).parents('tr').removeClass('checked');
62 64
        $('#listing input[type=checkbox][value=_all]').prop('checked', false);
65
        $('#listing input[type=checkbox]#top-select').prop('checked', false);
63 66
      }
64 67
    }
65 68
    if ($('#listing tbody input[type=checkbox]:checked').length == 0) {
66
-