summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2008-12-07 15:07:27 +0100
committerYorhel <git@yorhel.nl>2008-12-07 15:07:27 +0100
commitaaa0cf49ce27ff453dfd648e193597198c86372f (patch)
tree6fb0b1bee0559b21b765099e32c6316705be01ef
parent201ffccacef9f54778f79aba9f164295c18d6017 (diff)
Batch editing of wishlist
...all wishlist related pages are now pretty much done as well ^^
-rw-r--r--lib/VNDB/Handler/ULists.pm39
-rw-r--r--lib/VNDB/Util/CommonHTML.pm8
-rw-r--r--static/f/script.js10
-rw-r--r--static/f/style.css8
4 files changed, 62 insertions, 3 deletions
diff --git a/lib/VNDB/Handler/ULists.pm b/lib/VNDB/Handler/ULists.pm
index bb714b6e..f8603014 100644
--- a/lib/VNDB/Handler/ULists.pm
+++ b/lib/VNDB/Handler/ULists.pm
@@ -65,6 +65,17 @@ sub wishlist {
);
return 404 if $f->{_err};
+ if($own && $self->reqMethod eq 'POST') {
+ my $frm = $self->formValidate(
+ { name => 'sel', required => 0, default => 0, multi => 1, template => 'int' },
+ { name => 'wishbatch', required => 1, enum => [ -1..$#{$self->{wishlist_status}} ] },
+ );
+ if(!$frm->{_err} && @{$frm->{sel}} && $frm->{sel}[0]) {
+ $self->dbWishListDel($uid, $frm->{sel}) if $frm->{wishbatch} == -1;
+ $self->dbWishListAdd($frm->{sel}, $uid, $frm->{wishbatch}) if $frm->{wishbatch} >= 0;
+ }
+ }
+
my($list, $np) = $self->dbWishListGet(
uid => $uid,
order => $f->{s}.' '.($f->{o} eq 'a' ? 'ASC' : 'DESC'),
@@ -91,7 +102,11 @@ sub wishlist {
end;
end;
+ form action => "/u$uid/wish?f=$f->{f};o=$f->{o};s=$f->{s};p=$f->{p}", method => 'post'
+ if $own;
+
$self->htmlBrowse(
+ class => 'wishlist',
items => $list,
nextpage => $np,
options => $f,
@@ -102,17 +117,35 @@ sub wishlist {
[ Priority => '' ],
[ Added => 'added' ],
],
- row => sub {
+ row => sub {
my($s, $n, $i) = @_;
Tr $n % 2 == 0 ? (class => 'odd') : ();
td class => 'tc1';
- a href => "/v$i->{vid}", title => $i->{original}||$i->{title}, shorten $i->{title}, 70;
+ input type => 'checkbox', name => 'sel', value => $i->{vid}
+ if $own;
+ a href => "/v$i->{vid}", title => $i->{original}||$i->{title}, ' '.shorten $i->{title}, 70;
end;
td class => 'tc2', ucfirst $self->{wishlist_status}[$i->{wstat}];
td class => 'tc3', date $i->{added}, 'compact';
end;
- }
+ },
+ footer => sub {
+ return if !$own;
+ Tr;
+ td colspan => 3;
+ Select name => 'wishbatch', id => 'wishbatch';
+ option '-- with selected --';
+ optgroup label => 'Change priority';
+ option value => $_, $self->{wishlist_status}[$_]
+ for (0..$#{$self->{wishlist_status}});
+ end;
+ option value => -1, 'remove from wishlist';
+ end;
+ end;
+ end;
+ },
);
+ end if $own;
$self->htmlFooter;
}
diff --git a/lib/VNDB/Util/CommonHTML.pm b/lib/VNDB/Util/CommonHTML.pm
index 0c7ba0a5..68e12411 100644
--- a/lib/VNDB/Util/CommonHTML.pm
+++ b/lib/VNDB/Util/CommonHTML.pm
@@ -140,6 +140,7 @@ sub htmlHiddenMessage {
# be sorted
# row => subroutine ref, which is called for each item in $list, arguments will be
# $self, $item_number (starting from 0), $item_value
+# footer => subroutine ref, called after all rows have been processed
sub htmlBrowse {
my($self, %opt) = @_;
@@ -179,6 +180,13 @@ sub htmlBrowse {
$opt{row}->($self, $_+1, $opt{items}[$_])
for 0..$#{$opt{items}};
+ # footer
+ if($opt{footer}) {
+ tfoot;
+ $opt{footer}->($self);
+ end;
+ }
+
end;
end;
diff --git a/static/f/script.js b/static/f/script.js
index 533ab41f..c7755e54 100644
--- a/static/f/script.js
+++ b/static/f/script.js
@@ -278,6 +278,16 @@ DOMLoad(function() {
if(this.selectedIndex != 0)
location.href = location.href+'/wish?s='+this.options[this.selectedIndex].value;
};
+ // Batch Wishlist editing
+ i = x('wishbatch');
+ if(i)
+ i.onchange = function() {
+ var frm = this;
+ while(frm.nodeName.toLowerCase() != 'form')
+ frm = frm.parentNode;
+ if(this.selectedIndex != 0)
+ frm.submit();
+ };
// Advanced VN search
diff --git a/static/f/style.css b/static/f/style.css
index 6e5f0cce..6917dd8c 100644
--- a/static/f/style.css
+++ b/static/f/style.css
@@ -819,6 +819,14 @@ ul#catselect li li.exc { background-position: 0px -33px; color: #c00; }
+/***** Wishlist browser ******/
+
+.wishlist .tc1 { padding-top: 0; padding-bottom: 0; }
+.wishlist tfoot td { padding: 0 0 0 25px }
+
+
+
+
/***** Warning/Notice Box *****/