summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2020-01-02 11:16:32 +0100
committerYorhel <git@yorhel.nl>2020-01-02 11:17:18 +0100
commit5f7672ff8c5823f256b09846e30a0632fd7cb19a (patch)
tree0ace9da023ec2286b404197b549819d107702177
parentab6eb079e3f66218a6089bed584944911ae85f94 (diff)
ulist: Make label filter single-selection by default
To optimize for the common use case. The "Select all" option is now a "Multi-select" toggle.
-rw-r--r--elm/UList/labelfilters.js12
-rw-r--r--lib/VNWeb/User/Lists.pm13
2 files changed, 19 insertions, 6 deletions
diff --git a/elm/UList/labelfilters.js b/elm/UList/labelfilters.js
new file mode 100644
index 00000000..6a91a82d
--- /dev/null
+++ b/elm/UList/labelfilters.js
@@ -0,0 +1,12 @@
+var p = document.querySelectorAll('.labelfilters')[0];
+if(p) {
+ var multi = document.getElementById('form_l_multi');
+ var l = document.querySelectorAll('.labelfilters input[name=l]');
+ l.forEach(function(el) {
+ el.addEventListener('click', function() {
+ if(multi.checked)
+ return true;
+ l.forEach(function(el2) { el2.checked = el2 == el });
+ });
+ });
+}
diff --git a/lib/VNWeb/User/Lists.pm b/lib/VNWeb/User/Lists.pm
index 980bd807..f20a04bc 100644
--- a/lib/VNWeb/User/Lists.pm
+++ b/lib/VNWeb/User/Lists.pm
@@ -274,9 +274,9 @@ sub opt {
my $opt =
# Presets
- tuwf->reqGet('vnlist') ? { p => 1, l => [1,2,3,4,7,-1,0], s => 'title', o => 'a', c => [qw/vote added started finished/] } :
- tuwf->reqGet('votes') ? { p => 1, l => [7], s => 'voted', o => 'd', c => [qw/vote voted/] } :
- tuwf->reqGet('wishlist') ? { p => 1, l => [5], s => 'title', o => 'a', c => [qw/added/] } :
+ tuwf->reqGet('vnlist') ? { mul => 0, p => 1, l => [1,2,3,4,7,-1,0], s => 'title', o => 'a', c => [qw/vote added started finished/] } :
+ tuwf->reqGet('votes') ? { mul => 0, p => 1, l => [7], s => 'voted', o => 'd', c => [qw/vote voted/] } :
+ tuwf->reqGet('wishlist') ? { mul => 0, p => 1, l => [5], s => 'title', o => 'a', c => [qw/added/] } :
# Full options
tuwf->validate(get =>
p => { upage => 1 },
@@ -285,6 +285,7 @@ sub opt {
o => { onerror => 'a', enum => ['a', 'd'] },
c => { onerror => [], type => 'array', scalar => 1, values => { enum => [qw[ vote voted added modified started finished rel rating ]] } },
q => { required => 0 },
+ mul => { anybool => 1 },
)->data;
# $labels only includes labels we are allowed to see, getting rid of any labels in 'l' that aren't in $labels ensures we only filter on visible labels
@@ -316,9 +317,9 @@ sub filters_ {
span_ class => 'linkradio', sub {
join_ sub { em_ ' / ' }, \&lblfilt_, grep $_->{id} < 10, @$filtlabels;
- em_ ' | ';
- input_ type => 'checkbox', name => 'l', class => 'checkall', value => 0, id => 'form_l_all', tabindex => 10, $opt->{l}->@* == 0 ? (checked => 'checked') : ();
- label_ for => 'form_l_all', 'Select all';
+ em_ ' || ';
+ input_ type => 'checkbox', name => 'mul', value => 1, id => 'form_l_multi', tabindex => 10, $opt->{mul} ? (checked => 'checked') : ();
+ label_ for => 'form_l_multi', 'Multi-select';
debug_ $filtlabels;
};
my @cust = grep $_->{id} >= 10, @$filtlabels;