summaryrefslogtreecommitdiff
path: root/lib/VNWeb
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2021-07-10 11:25:59 +0200
committerYorhel <git@yorhel.nl>2021-07-10 11:26:01 +0200
commitecf86fe11c220e408846d570678547278169c00a (patch)
tree2e1dd8f0344c6faa05b5d99d00ed7e49bcb96b31 /lib/VNWeb
parent195f6ca1e3a00281fba92ba9fccfc62e6f850ab1 (diff)
Consistently place UList widget before title + add placeholder
Placeholder to prevent relayouts while the Elm modules are being loaded. This required a change to the way that the elm_() placeholder argument works, so affected a bit more code.
Diffstat (limited to 'lib/VNWeb')
-rw-r--r--lib/VNWeb/HTML.pm5
-rw-r--r--lib/VNWeb/Producers/Page.pm2
-rw-r--r--lib/VNWeb/TableOpts.pm4
-rw-r--r--lib/VNWeb/ULists/Lib.pm4
-rw-r--r--lib/VNWeb/ULists/List.pm17
-rw-r--r--lib/VNWeb/VN/List.pm4
6 files changed, 25 insertions, 11 deletions
diff --git a/lib/VNWeb/HTML.pm b/lib/VNWeb/HTML.pm
index f71d7e6b..70fa1b5b 100644
--- a/lib/VNWeb/HTML.pm
+++ b/lib/VNWeb/HTML.pm
@@ -132,7 +132,8 @@ sub elm_ {
my($mod, $schema, $data, $placeholder) = @_;
die "Elm data without a schema" if defined $data && !defined $schema;
push tuwf->req->{pagevars}{elm}->@*, [ $mod, $data ? ($schema eq 'raw' ? $data : $schema->analyze->coerce_for_json($data, unknown => 'remove')) : () ];
- div_ id => sprintf('elm%d', $#{ tuwf->req->{pagevars}{elm} }), $placeholder//'';
+ my @arg = (id => sprintf 'elm%d', $#{ tuwf->req->{pagevars}{elm} });
+ $placeholder ? $placeholder->(@arg) : div_ @arg, '';
}
@@ -378,7 +379,7 @@ sub _maintabs_subscribe_ {
subreview => $sub->{subreview}||0,
subapply => $sub->{subapply}||0,
}, sub {
- a_ href => '#', class => ($noti && (!defined $sub->{subnum} || $sub->{subnum})) || $sub->{subnum} || $sub->{subreview} || $sub->{subapply} ? 'active' : 'inactive', '🔔';
+ a_ @_, href => '#', class => ($noti && (!defined $sub->{subnum} || $sub->{subnum})) || $sub->{subnum} || $sub->{subreview} || $sub->{subapply} ? 'active' : 'inactive', '🔔';
};
};
}
diff --git a/lib/VNWeb/Producers/Page.pm b/lib/VNWeb/Producers/Page.pm
index b0a5c86d..73b7f798 100644
--- a/lib/VNWeb/Producers/Page.pm
+++ b/lib/VNWeb/Producers/Page.pm
@@ -99,8 +99,8 @@ sub rel_ {
for my $v (@vn) {
tr_ class => 'vn', sub {
td_ colspan => 8, sub {
- a_ href => "/$v->{id}", title => $v->{original}||$v->{title}, $v->{title};
ulists_widget_ $v;
+ a_ href => "/$v->{id}", title => $v->{original}||$v->{title}, $v->{title};
};
my $ropt = { id => $v->{id}, prod => 1 };
release_row_ $_, $ropt for $vn{$v->{id}}->@*;
diff --git a/lib/VNWeb/TableOpts.pm b/lib/VNWeb/TableOpts.pm
index 432bf548..fa976f40 100644
--- a/lib/VNWeb/TableOpts.pm
+++ b/lib/VNWeb/TableOpts.pm
@@ -220,7 +220,9 @@ sub elm_ {
sorts => [ map +{ id => $_->{sort_id}, name => $_->{name} }, grep defined $_->{sort_id}, values $o->{col_order}->@* ],
vis => [ map +{ id => $_->{vis_id}, name => $_->{name} }, grep defined $_->{vis_id}, values $o->{col_order}->@* ],
}, sub {
- TUWF::XML::input_ type => 'hidden', name => 's', value => $self->query_encode if defined $self->query_encode
+ TUWF::XML::div_ @_, sub {
+ TUWF::XML::input_ type => 'hidden', name => 's', value => $self->query_encode if defined $self->query_encode
+ }
};
}
diff --git a/lib/VNWeb/ULists/Lib.pm b/lib/VNWeb/ULists/Lib.pm
index c1b6e0db..9127fb7f 100644
--- a/lib/VNWeb/ULists/Lib.pm
+++ b/lib/VNWeb/ULists/Lib.pm
@@ -31,6 +31,10 @@ sub ulists_widget_ {
vid => $v->{id},
labels => $v->{on_vnlist} ? $v->{vnlist_labels} : undef,
full => undef,
+ }, sub {
+ my $img = !$v->{on_vnlist} ? 'add' :
+ (reverse sort map "l$_->{id}", grep $_->{id} >= 1 && $_->{id} <= 5, $v->{vnlist_labels}->@*)[0] || 'unknown';
+ img_ @_, src => config->{url_static}.'/f/list-'.$img.'.svg', class => "ulist-widget-icon liststatus_icon $img";
} if auth;
}
diff --git a/lib/VNWeb/ULists/List.pm b/lib/VNWeb/ULists/List.pm
index fc0bbf9e..35703aa1 100644
--- a/lib/VNWeb/ULists/List.pm
+++ b/lib/VNWeb/ULists/List.pm
@@ -112,8 +112,9 @@ sub vn_ {
td_ mkclass(tc_vote => 1, compact => $own, stealth => $own), sub {
txt_ fmtvote $v->{vote} if !$own;
- elm_ 'UList.VoteEdit' => $VNWeb::ULists::Elm::VNVOTE, { uid => $uid, vid => $v->{id}, vote => fmtvote($v->{vote}) }, fmtvote $v->{vote}
- if $own && ($v->{vote} || sprintf('%08d', $v->{c_released}||0) < strftime '%Y%m%d', gmtime);
+ elm_ 'UList.VoteEdit' => $VNWeb::ULists::Elm::VNVOTE, { uid => $uid, vid => $v->{id}, vote => fmtvote($v->{vote}) }, sub {
+ div_ @_, fmtvote $v->{vote}
+ } if $own && ($v->{vote} || sprintf('%08d', $v->{c_released}||0) < strftime '%Y%m%d', gmtime);
} if in vote => $opt->{c};
td_ class => 'tc_rating', sub {
@@ -125,7 +126,9 @@ sub vn_ {
my @l = grep $labels{$_->{id}} && $_->{id} != 7, @$labels;
my $txt = @l ? join ', ', map $_->{label}, @l : '-';
if($own) {
- elm_ 'UList.LabelEdit' => $VNWeb::ULists::Elm::VNLABELS_OUT, { vid => $v->{id}, selected => [ grep $_ != 7, $v->{labels}->@* ] }, $txt;
+ elm_ 'UList.LabelEdit' => $VNWeb::ULists::Elm::VNLABELS_OUT, { vid => $v->{id}, selected => [ grep $_ != 7, $v->{labels}->@* ] }, sub {
+ div_ @_, $txt;
+ };
} else {
txt_ $txt;
}
@@ -141,12 +144,16 @@ sub vn_ {
td_ class => 'tc_started', sub {
txt_ $v->{started}||'' if !$own;
- elm_ 'UList.DateEdit' => $VNWeb::ULists::Elm::VNDATE, { uid => $uid, vid => $v->{id}, date => $v->{started}||'', start => 1 }, $v->{started}||'' if $own;
+ elm_ 'UList.DateEdit' => $VNWeb::ULists::Elm::VNDATE, { uid => $uid, vid => $v->{id}, date => $v->{started}||'', start => 1 }, sub {
+ div_ @_, $v->{started}||''
+ } if $own;
} if in started => $opt->{c};
td_ class => 'tc_finished', sub {
txt_ $v->{finished}||'' if !$own;
- elm_ 'UList.DateEdit' => $VNWeb::ULists::Elm::VNDATE, { uid => $uid, vid => $v->{id}, date => $v->{finished}||'', start => 0 }, $v->{finished}||'' if $own;
+ elm_ 'UList.DateEdit' => $VNWeb::ULists::Elm::VNDATE, { uid => $uid, vid => $v->{id}, date => $v->{finished}||'', start => 0 }, sub {
+ div_ @_, $v->{finished}||''
+ } if $own;
} if in finished => $opt->{c};
td_ class => 'tc_rel', sub { rdate_ $v->{c_released} } if in rel => $opt->{c};
diff --git a/lib/VNWeb/VN/List.pm b/lib/VNWeb/VN/List.pm
index 7a6ecca9..8bbfe858 100644
--- a/lib/VNWeb/VN/List.pm
+++ b/lib/VNWeb/VN/List.pm
@@ -79,9 +79,9 @@ sub listing_ {
table_ class => 'stripe', sub {
thead_ sub { tr_ sub {
td_ class => 'tc_score', sub { txt_ 'Score'; sortable_ 'tagscore', $opt, \&url } if $tagscore;
+ td_ class => 'tc_ulist', '' if auth;
td_ class => 'tc_title', sub { txt_ 'Title'; sortable_ 'title', $opt, \&url };
td_ class => 'tc_dev', 'Developer' if $opt->{s}->vis('developer');
- td_ class => 'tc_ulist', '';
td_ class => 'tc_plat', '';
td_ class => 'tc_lang', '';
td_ class => 'tc_rel', sub { txt_ 'Released'; sortable_ 'released', $opt, \&url };
@@ -91,13 +91,13 @@ sub listing_ {
} };
tr_ sub {
td_ class => 'tc_score', sub { tagscore_ $_->{tagscore} } if $tagscore;
+ td_ class => 'tc_ulist', sub { ulists_widget_ $_ } if auth;
td_ class => 'tc_title', sub { a_ href => "/$_->{id}", title => $_->{original}||$_->{title}, $_->{title} };
td_ class => 'tc_dev', sub {
join_ ' & ', sub {
a_ href => "/$_->{id}", title => $_->{original}||$_->{name}, $_->{name};
}, sort { $a->{name} cmp $b->{name} || $a->{id} <=> $b->{id} } $_->{developers}->@*;
} if $opt->{s}->vis('developer');
- td_ class => 'tc_ulist', sub { ulists_widget_ $_ };
td_ class => 'tc_plat', sub { join_ '', sub { platform_ $_ if $_ ne 'unk' }, sort $_->{platforms}->@* };
td_ class => 'tc_lang', sub { join_ '', sub { abbr_ class => "icons lang $_", title => $LANGUAGE{$_}, '' }, reverse sort $_->{lang}->@* };
td_ class => 'tc_rel', sub { rdate_ $_->{c_released} };