Projet

Général

Profil

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

Frédéric Péters, 04 décembre 2019 11:06

Télécharger (2,85 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 | 10 ++++++++--
 2 files changed, 11 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
45 45
      $(this).parents('tr').removeClass('checked');
46 46
    }
47 47
  });
48
  if ($('#page-links .pages a').length < 2) {
49
    $('#info-all-rows').hide();
50
  }
48 51
  $('#listing input[type=checkbox]').on('change', function() {
49 52
    if ($(this).is(':checked')) {
50
      if ($(this).is('[value=_all]')) {
53
      if ($(this).is('#top-select')) {
51 54
        $(this).parents('table').find('tbody td.select input').prop('checked', true);
52 55
        $(this).parents('table').find('tbody tr').addClass('checked');
53 56
      } else {
54 57
        $(this).parents('tr').addClass('checked');
55 58
      }
56 59
    } else {
57
      if ($(this).is('[value=_all]')) {
60
      if ($(this).is('#top-select')) {
58 61
        $(this).parents('table').find('tbody td.select input').prop('checked', false);
59 62
        $(this).parents('table').find('tbody tr').removeClass('checked');
63
      } else if ($(this).is('[value=_all]')) {
64
        // do nothing particular when unchecking "all"
60 65
      } else {
61 66
        $(this).parents('tr').removeClass('checked');
62 67
        $('#listing input[type=checkbox][value=_all]').prop('checked', false);
68
        $('#listing input[type=checkbox]#top-select').prop('checked', false);
63 69
      }
64 70
    }
65 71
    if ($('#listing tbody input[type=checkbox]:checked').length == 0) {
66
-