[Bps-public-commit] App-Changeloggr branch, vote-sidebar, created. fbca27f389ff5a826b6e872a64ba5b70be56d3db

sartak at bestpractical.com sartak at bestpractical.com
Tue Aug 4 20:35:29 EDT 2009


The branch, vote-sidebar has been created
        at  fbca27f389ff5a826b6e872a64ba5b70be56d3db (commit)

- Log -----------------------------------------------------------------
commit cf04040fe3c66532d077b8fced5d688d7e31714d
Author: Shawn M Moore <sartak at gmail.com>
Date:   Tue Aug 4 20:35:05 2009 -0400

    Begin moving the vote form to the sidebar

diff --git a/lib/App/Changeloggr/View.pm b/lib/App/Changeloggr/View.pm
index d76e7bf..6f81dd6 100644
--- a/lib/App/Changeloggr/View.pm
+++ b/lib/App/Changeloggr/View.pm
@@ -152,7 +152,15 @@ sub show_change {
     my $change = shift;
     my %args = @_;
 
-    div { id is 'keybindings' };
+    my $id = $change->id;
+
+    render_region(
+        name      => "vote_$id",
+        path      => '/change/vote',
+        arguments => {
+            change => $id,
+        },
+    );
 
     div {
         { class is "change" };
@@ -190,7 +198,6 @@ sub show_change {
             li { "Date: " . $change->date };
         };
 
-        my $id = $change->id;
         render_region(
             name      => "change_$id",
             path      => '/change/more',
@@ -234,8 +241,6 @@ sub show_change {
 
         if ($args{voting_form}) {
             hr {};
-            show_vote_form($change);
-            hr {};
             show_rewording_form($change);
         }
     };
@@ -268,103 +273,109 @@ template '/change/more' => sub {
     };
 };
 
-sub show_vote_form {
-    my $change = shift;
-
+template '/change/vote' => sub {
+    my $change = M('Change', id => get('change'));
     my $changelog = $change->changelog;
     my $valid_tags = $change->prioritized_tags;
 
-    form {
+    div {
+        id is 'vote_buttons';
         h4 { 'Vote!' };
-        my $vote = new_action(
-            class     => "CreateVote",
-            arguments => { change_id => $change->id }
-        );
 
-        render_param($vote, 'change_id');
-        if ($valid_tags->count == 0 || $changelog->incremental_tags) {
-            render_param($vote, 'tag');
-
-            my $label = $changelog->incremental_tags ? 'Vote and add tag' : 'Vote';
-            form_submit(
-                label   => $label,
-                onclick     => [
-                    { submit => $vote, refresh_self => 1 },
-                    { refresh => 'score' },
-                ],
-            );
-        }
+        form {
+            ul {
+                my $vote = new_action(
+                    class     => "CreateVote",
+                    arguments => { change_id => $change->id }
+                );
 
-        if ($valid_tags->count) {
-            my $tag_number = 0;
-            my $voted_cusp = 0;
-            while (my $valid_tag = $valid_tags->next) {
-                my $label;
-                my $count = $change->count_of_tag($valid_tag);
-
-                # This is actually checking count+1, not id. It's count+1
-                # because id 0 (aka count 0) records are not loaded. :/
-                ++$tag_number;
-                if ($count > 0) {
-                    $label = _('%1 (%2)', $valid_tag->text, $count);
-                }
-                else {
-                    $label = $valid_tag->text;
-
-                    # Add a newline between tags that have been selected for
-                    # this change and tags that haven't
-                    if (!$voted_cusp) {
-                        $voted_cusp = 1;
-                        br {} unless $tag_number == 1;
+                render_param($vote, 'change_id');
+                if ($valid_tags->count == 0 || $changelog->incremental_tags) {
+                    render_param($vote, 'tag');
+
+                    my $label = $changelog->incremental_tags ? 'Vote and add tag' : 'Vote';
+                    li {
+                        form_submit(
+                            label   => $label,
+                            onclick     => [
+                                { submit => $vote, refresh_self => 1 },
+                                { refresh => 'score' },
+                            ],
+                        );
                     }
                 }
 
-                $vote->button(
-                    class       => "vote",
-                    label       => $label,
-                    key_binding => $valid_tag->hotkey,
-                    tooltip     => $valid_tag->tooltip,
-                    onclick     => [
-                        { submit => $vote, refresh_self => 1 },
-                        { refresh => 'score' },
-                    ],
-                    arguments   => { tag => $valid_tag->text },
-                );
-            }
+                if ($valid_tags->count) {
+                    my $tag_number = 0;
+                    my $voted_cusp = 0;
+                    while (my $valid_tag = $valid_tags->next) {
+                        my $label;
+                        my $count = $change->count_of_tag($valid_tag);
+
+                        # This is actually checking count+1, not id. It's count+1
+                        # because id 0 (aka count 0) records are not loaded. :/
+                        ++$tag_number;
+                        if ($count > 0) {
+                            $label = _('%1 (%2)', $valid_tag->text, $count);
+                        }
+                        else {
+                            $label = $valid_tag->text;
+                        }
+
+                        li {
+                            $vote->button(
+                                class       => "vote",
+                                label       => $label,
+                                key_binding => $valid_tag->hotkey,
+                                tooltip     => $valid_tag->tooltip,
+                                onclick     => [
+                                    { submit => $vote, refresh_self => 1 },
+                                    { refresh => 'score' },
+                                ],
+                                arguments   => { tag => $valid_tag->text },
+                            );
+                        };
+                    }
 
-            p {
-                attr { class => 'tags_link' };
-                hyperlink(
-                    label => _('Legend'),
-                    url   => '/changelog/' . $changelog->name . '/tags',
-                );
-            }
-        }
-        hr {};
-        $vote->button(
-            class       => "vote",
-            label       => 'Skip this change',
-            onclick     => [
-                { submit => $vote, refresh_self => 1 },
-                { refresh => 'score' },
-            ],
-            arguments   => { tag => '_skip' },
-        );
+                    p {
+                        attr { class => 'tags_link' };
+                        hyperlink(
+                            label => _('Legend'),
+                            url   => '/changelog/' . $changelog->name . '/tags',
+                        );
+                    }
+                }
+                hr {};
+                li {
+                    $vote->button(
+                        class       => "vote",
+                        label       => 'Skip this change',
+                        onclick     => [
+                            { submit => $vote, refresh_self => 1 },
+                            { refresh => 'score' },
+                        ],
+                        arguments   => { tag => '_skip' },
+                    );
+                };
 
-        my $user = Jifty->web->current_user->user_object;
-        if ($user->votes->count) {
-            my $undo = new_action('UndoVote');
-            $undo->button(
-                class   => "vote",
-                label   => "Undo previous vote",
-                onclick     => [
-                    { submit => $undo, refresh_self => 1 },
-                    { refresh => 'score' },
-                ],
-            );
+                my $user = Jifty->web->current_user->user_object;
+                if ($user->votes->count) {
+                    my $undo = new_action('UndoVote');
+                    li {
+                        $undo->button(
+                            class   => "vote",
+                            label   => "Undo previous vote",
+                            onclick     => [
+                                { submit => $undo, refresh_self => 1 },
+                                { refresh => 'score' },
+                            ],
+                        );
+                    };
+                }
+            }
         }
-    }
-}
+    };
+};
 
 sub show_rewording_form {
     my $change = shift;

commit fbca27f389ff5a826b6e872a64ba5b70be56d3db
Author: Shawn M Moore <sartak at gmail.com>
Date:   Tue Aug 4 20:35:14 2009 -0400

    CSS updates

diff --git a/share/web/static/css/change.css b/share/web/static/css/change.css
index c61dc85..7d09134 100644
--- a/share/web/static/css/change.css
+++ b/share/web/static/css/change.css
@@ -7,7 +7,7 @@ input.button.vote {
   margin: 0.3em;
 }
 
-#region-vote-on-change div#keybindings {
+#region-vote-on-change div#vote_buttons {
   background: #224;
   border: 1px solid #445;
   border-left: none;
@@ -22,30 +22,6 @@ input.button.vote {
   -moz-border-radius-bottomright: 10px;
 }
 
-dl.keybindings {
-  margin-top: 0;
-}
-
-dl.keybindings dt {
-  clear: left;
-  float: left;
-  text-align: right;
-  font-family: monospace;
-  font-size: 125%;
-}
-
-dl.keybindings dt:after {
-  content: "";
-}
-
-dl.keybindings dd:before {
-  content: " - ";
-}
-
-dl.keybindings dd {
-  float: left;
-}
-
 .change_message {
   font-family: monospace;
 }

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list