From 628042ec74da65c4572fa5e9473b94649a5a7a37 Mon Sep 17 00:00:00 2001 From: Michal Vaner Date: Thu, 4 Sep 2008 14:14:25 +0200 Subject: [PATCH] Make administration interface work --- PciIds/Html/Admin.pm | 35 ++++++++++++++++------------- PciIds/Html/Util.pm | 5 +++-- static/common.css | 44 ++++++++++++++++++++++++++++++++++++ static/print.css | 27 +--------------------- static/screen.css | 53 +++++--------------------------------------- 5 files changed, 72 insertions(+), 92 deletions(-) create mode 100644 static/common.css diff --git a/PciIds/Html/Admin.pm b/PciIds/Html/Admin.pm index ea8cf9a..8ad40da 100644 --- a/PciIds/Html/Admin.pm +++ b/PciIds/Html/Admin.pm @@ -38,14 +38,14 @@ sub genHist( $$$$$$$$$$$ ) { } print "Note: ".encode( $note )."
" if defined $note && $note ne ''; print safeEncode( $disc ); - print "\n"; + print "\n"; print "\n" if defined $delname } sub genNewForm( $ ) { my( $num ) = @_; print "TODO combo"; - print "Name: Note:
\n"; + print "Name: Note:
\n"; print "\n"; print "\n"; } @@ -90,17 +90,24 @@ sub genNewAdminForm( $$$$$ ) { print "\n"; print "

\n"; print ""; - genPathBare( $req, $addr, 0, 0, 0 ); + genPathBare( $req, $addr, 1, 0 ); print "" if( $subcnt ); $subcnt = 0; $cnt ++; print ""; print "" if hasRight( $auth->{'accrights'}, 'prune' ) || ( !defined $actHist && !$tables->hasChildren( $addr->get() ) ); - genHist( 'main-history', $actEmail, $actLogin, $actTime, $actName, $actNote, $actDisc, "loc-$cnt-sel", 'seen', undef, undef ) if( defined $actHist ); + print ""; + if( defined $actHist ) { + genHist( 'main-history', $actEmail, $actLogin, $actTime, $actName, $actNote, $actDisc, "loc-$cnt-sel", 'seen', undef, undef ); + } else { + print ""; + } } $hiscnt ++; $subcnt ++; genHist( 'unseen-history', $email, $login, $time, $name, $note, $disc, "loc-$cnt-sel", $hist, "del-$hiscnt", "del-$hist" ); + print ""; + print ""; } print "\n" if( defined( $subcnt ) ); if( $started ) { @@ -144,12 +151,10 @@ sub submitAdminForm( $$$$ ) { my $maxcnt = getFormValue( 'max-cnt', 0 ); my $maxhiscnt = getFormValue( 'max-hiscnt', 0 ); $errors = ''; - # Scan for approved and deleted items + # Scan for deleted histories for( my $i = 1; $i <= $maxhiscnt; $i ++ ) { my( $del ) = getFormValue( "del-$i", '' ) =~ /^del-(\d+)$/; $deleted{$del} = 1 if( defined $del && $del ne '' ); - my( $appr ) = getFormValue( "appr-$i", '' ) =~ /^appr-(\d+)$/; - $approved{$appr} = 1 if( defined $appr && $appr ne '' ); } for( my $i = 1; $i <= $maxcnt; $i ++ ) { my( $sel ) = getFormValue( "loc-$i-sel", '' ) =~ /^(\d+)$/; @@ -166,17 +171,14 @@ sub submitAdminForm( $$$$ ) { delete $approved{$id}; } } - #Do the deletes and approves + #Do the deletes + my %modified; foreach my $del ( keys %deleted ) { $tables->deleteHistory( $del ); + $modified{getFormValue( "owner-$del", '' )} = 1; tulog( $authid, "Discussion deleted $del" ); } - foreach my $appr ( keys %approved ) { - $tables->markChecked( $appr ); - tulog( $authid, "Discussion checked $appr" ); - } #Handle the items - my $defaultSeen = getFormValue( 'default-seen', '' ) =~ /^default-seen$/; for( my $i = 1; $i <= $maxcnt; $i ++ ) { my $addr = PciIds::Address::new( getFormValue( "loc-$i", '' ) ); next if $collision{$addr->get()}; @@ -203,8 +205,9 @@ sub submitAdminForm( $$$$ ) { appendError( "You must specify name if you set note at item ".$addr->pretty() ); next; } + my $action = $modified{$addr->get()}; + $action = 1 if getFormValue( "loc-$i-sel", '' ) eq 'seen'; my( $select ) = getFormValue( "loc-$i-sel", '' ) =~ /^(\d+)$/; - my $action = 0; if( defined $name || defined $discussion || $delete ) { my $histId = $tables->submitHistory( { 'name' => $name, 'note' => $note, 'text' => $discussion, 'delete' => $delete }, $auth, $addr ); $tables->markChecked( $histId ); @@ -219,12 +222,12 @@ sub submitAdminForm( $$$$ ) { $action = 1; notify( $tables, $addr->get(), $select, 2, 2 ); } - if( $action && $defaultSeen ) {#Approve anything in this item + if( $action ) {#Approve anything in this item my $subcnt = getFormValue( "loc-$i-subcnt", 0 ); for( my $j = 1; $j <= $subcnt; $j ++ ) { my( $id ) = getFormValue( "his-$i-$j", '' ) =~ /^(\d+)$/; next unless defined $id; - next if $approved{$id} || $deleted{$id}; + next if $deleted{$id}; $tables->markChecked( $id ); tulog( $authid, "Discussion checked $id" ); } diff --git a/PciIds/Html/Util.pm b/PciIds/Html/Util.pm index d27435d..d883f9f 100644 --- a/PciIds/Html/Util.pm +++ b/PciIds/Html/Util.pm @@ -21,6 +21,7 @@ sub genHtmlHead( $$$ ) { print ''.encode( $caption )."\n"; print "\n"; print "\n"; + print "\n"; print $metas if( defined( $metas ) ); print "\n"; } @@ -150,7 +151,7 @@ sub HTTPRedirect( $$ ) { return HTTP_SEE_OTHER; } -sub genPathBare( $$$$$ ) { +sub genPathBare( $$$$ ) { my( $req, $address, $printAddr, $started ) = @_; my $path; if( defined $address ) { @@ -183,7 +184,7 @@ sub genPath( $$$ ) { my( $req, $address, $printAddr ) = @_; print "

\n"; print "

Main"; - genPathBare( $req, $address, $printAddr, 1, 1 ); + genPathBare( $req, $address, $printAddr, 1 ); print "

\n"; } diff --git a/static/common.css b/static/common.css new file mode 100644 index 0000000..4412bbe --- /dev/null +++ b/static/common.css @@ -0,0 +1,44 @@ +form table, +table.subnodes +{ + width: 100%; + table-layout: fixed; +} +col.name-col +{ + width: 60%; +} +form table col.label +{ + width: 15%; +} +form table col.edit +{ + width: 85%; +} +input.text, +input.password, +textarea +{ + width: 100%; +} +input.jump +{ + width: 8em; +} +form.jump p +{ + margin-top: 0px; +} +form.admin col.author +{ + width: 20%; +} +form.admin col.main +{ + width: 74%; +} +form.admin col.controls +{ + width: 3%; +} diff --git a/static/print.css b/static/print.css index 0cb1e38..98f0a8c 100644 --- a/static/print.css +++ b/static/print.css @@ -1,4 +1,4 @@ -.menu, .navigation, .navigation-menu +.navigation, .lmenu, .rmenu { overflow: hidden; display: none; @@ -25,28 +25,3 @@ border-bottom: dotted; border-bottom-width: 1px; } -form table, -table.subnodes -{ - width: 100%; - table-layout: fixed; -} -col.name-col -{ - width: 60%; -} -form table -col.label -{ - width: 15%; -} -col.edit -{ - width: 85%; -} -input.text, -input.password, -textarea -{ - width: 100%; -} diff --git a/static/screen.css b/static/screen.css index 3e7c650..9c4c25b 100644 --- a/static/screen.css +++ b/static/screen.css @@ -83,54 +83,6 @@ ul.navigation { margin-left: -1em; /* Hack. Move the place the bullets would take if they were there back left. */ } -form table, -table.subnodes -{ - width: 100%; - table-layout: fixed; -} -col.name-col -{ - width: 60%; -} -form table col.label -{ - width: 15%; -} -form table col.edit -{ - width: 85%; -} -input.text, -input.password, -textarea -{ - width: 100%; -} -input.jump -{ - width: 8em; -} -form.jump p -{ - margin-top: 0px; -} -form.admin col.author -{ - width: 20%; -} -form.admin col.main -{ - width: 74%; -} -form.admin col.controls -{ - width: 3%; -} -form.admin table -{ - background: #BBBBFF; -} form.admin tr.label td.deletes { background: red; @@ -139,3 +91,8 @@ form.admin .newhistory { background: #FFFFCC; } +form.admin td.empty, +form.admin table +{ + background: #BBBBFF; +} -- 2.39.2