From 437b1c052d065ce2d2c8adc8f1c0ca3504242083 Mon Sep 17 00:00:00 2001 From: Matchu Date: Fri, 15 Jul 2011 17:21:18 -0400 Subject: [PATCH] quantity form on your items page --- app/controllers/closet_hangers_controller.rb | 2 +- app/helpers/application_helper.rb | 2 +- app/stylesheets/closet_hangers/_index.sass | 47 ++++++++++++++---- .../closet_hangers/_closet_hanger.html.haml | 7 ++- app/views/closet_hangers/index.html.haml | 3 +- public/stylesheets/compiled/screen.css | 48 +++++++++++++++++-- 6 files changed, 91 insertions(+), 18 deletions(-) diff --git a/app/controllers/closet_hangers_controller.rb b/app/controllers/closet_hangers_controller.rb index eb059dda..98f606b9 100644 --- a/app/controllers/closet_hangers_controller.rb +++ b/app/controllers/closet_hangers_controller.rb @@ -31,7 +31,7 @@ class ClosetHangersController < ApplicationController flash[:success] = "Success! You do not own #{@item.name}." end - redirect_to @item + redirect_to params[:return_to] || @item end alias_method :create, :update diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 6c338888..7496defa 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -32,7 +32,7 @@ module ApplicationHelper def flashes raw(flash.inject('') do |html, pair| key, value = pair - html + content_tag('p', value, :class => key) + html + content_tag('p', value, :class => "flash #{key}") end) end diff --git a/app/stylesheets/closet_hangers/_index.sass b/app/stylesheets/closet_hangers/_index.sass index c2826e54..2d8aafbc 100644 --- a/app/stylesheets/closet_hangers/_index.sass +++ b/app/stylesheets/closet_hangers/_index.sass @@ -1,6 +1,10 @@ body.closet_hangers-index #title float: left + margin-bottom: .5em + + .flash + clear: both #import-link +awesome-button @@ -13,13 +17,38 @@ body.closet_hangers-index clear: both text-align: center - .object .quantity - +opacity(.75) - background: white - font-size: 16px - font-weight: bold - padding: 2px 4px - position: absolute - left: ($object-width - $object-img-size) / 2 + $object-padding - top: $object-img-size - 24px + .object + .quantity + +opacity(.75) + background: white + padding: 2px 4px + position: absolute + left: ($object-width - $object-img-size) / 2 + $object-padding + text-align: left + top: $object-img-size - 24px + + form + display: none + + span, input[type=number] + font-size: 16px + font-weight: bold + + &:hover + .quantity + +opacity(1) + top: $object-img-size - 30px + + span + display: none + + form + display: inline + + input[type=number] + padding: 2px + width: 2em + + input[type=submit] + font-size: 85% diff --git a/app/views/closet_hangers/_closet_hanger.html.haml b/app/views/closet_hangers/_closet_hanger.html.haml index 67fe5234..5c767cbd 100644 --- a/app/views/closet_hangers/_closet_hanger.html.haml +++ b/app/views/closet_hangers/_closet_hanger.html.haml @@ -1,4 +1,9 @@ .object = render :partial => 'items/item_link', :locals => {:item => closet_hanger.item} - %span.quantity{:title => "You own #{pluralize closet_hanger.quantity, closet_hanger.item.name}"}= closet_hanger.quantity + .quantity + %span{:title => "You own #{pluralize closet_hanger.quantity, closet_hanger.item.name}"}= closet_hanger.quantity + = form_for closet_hanger, :url => user_item_closet_hanger_path(current_user, closet_hanger.item) do |f| + = hidden_field_tag :return_to, request.fullpath + = f.number_field :quantity, :min => 0, :required => true, :title => "You own #{pluralize closet_hanger.quantity, closet_hanger.item.name}" + = f.submit "Save" diff --git a/app/views/closet_hangers/index.html.haml b/app/views/closet_hangers/index.html.haml index 56e81d09..7a9bf0b8 100644 --- a/app/views/closet_hangers/index.html.haml +++ b/app/views/closet_hangers/index.html.haml @@ -1,6 +1,7 @@ - if user_is?(@user) - title 'Your Items' - = link_to "Import closet from Neopets", new_closet_page_path, :id => 'import-link' + - content_for :before_flashes do + = link_to "Import closet from Neopets", new_closet_page_path, :id => 'import-link' - else - title "#{@user.name}'s Items" #closet-hangers diff --git a/public/stylesheets/compiled/screen.css b/public/stylesheets/compiled/screen.css index f5af8b29..dd0f88db 100644 --- a/public/stylesheets/compiled/screen.css +++ b/public/stylesheets/compiled/screen.css @@ -552,8 +552,13 @@ div.jGrowl div.jGrowl-closer { /* line 2, ../../../app/stylesheets/closet_hangers/_index.sass */ body.closet_hangers-index #title { float: left; + margin-bottom: 0.5em; } -/* line 5, ../../../app/stylesheets/closet_hangers/_index.sass */ +/* line 6, ../../../app/stylesheets/closet_hangers/_index.sass */ +body.closet_hangers-index .flash { + clear: both; +} +/* line 9, ../../../app/stylesheets/closet_hangers/_index.sass */ body.closet_hangers-index #import-link { /* http://www.zurb.com/blog_uploads/0000/0617/buttons-03.html */ -moz-border-radius: 5px; @@ -591,25 +596,58 @@ body.closet_hangers-index #import-link:active { body.closet_hangers-index #import-link:hover { background-color: #ee4b00; } -/* line 12, ../../../app/stylesheets/closet_hangers/_index.sass */ +/* line 16, ../../../app/stylesheets/closet_hangers/_index.sass */ body.closet_hangers-index #closet-hangers { clear: both; text-align: center; } -/* line 16, ../../../app/stylesheets/closet_hangers/_index.sass */ +/* line 21, ../../../app/stylesheets/closet_hangers/_index.sass */ body.closet_hangers-index #closet-hangers .object .quantity { -moz-opacity: 0.75; -webkit-opacity: 0.75; -o-opacity: 0.75; -khtml-opacity: 0.75; background: white; - font-size: 16px; - font-weight: bold; padding: 2px 4px; position: absolute; left: 16px; + text-align: left; top: 56px; } +/* line 30, ../../../app/stylesheets/closet_hangers/_index.sass */ +body.closet_hangers-index #closet-hangers .object .quantity form { + display: none; +} +/* line 33, ../../../app/stylesheets/closet_hangers/_index.sass */ +body.closet_hangers-index #closet-hangers .object .quantity span, body.closet_hangers-index #closet-hangers .object .quantity input[type=number] { + font-size: 16px; + font-weight: bold; +} +/* line 38, ../../../app/stylesheets/closet_hangers/_index.sass */ +body.closet_hangers-index #closet-hangers .object:hover .quantity { + -moz-opacity: 1; + -webkit-opacity: 1; + -o-opacity: 1; + -khtml-opacity: 1; + top: 50px; +} +/* line 42, ../../../app/stylesheets/closet_hangers/_index.sass */ +body.closet_hangers-index #closet-hangers .object:hover .quantity span { + display: none; +} +/* line 45, ../../../app/stylesheets/closet_hangers/_index.sass */ +body.closet_hangers-index #closet-hangers .object:hover .quantity form { + display: inline; +} +/* line 48, ../../../app/stylesheets/closet_hangers/_index.sass */ +body.closet_hangers-index #closet-hangers .object:hover .quantity form input[type=number] { + padding: 2px; + width: 2em; +} +/* line 52, ../../../app/stylesheets/closet_hangers/_index.sass */ +body.closet_hangers-index #closet-hangers .object:hover .quantity input[type=submit] { + font-size: 85%; +} /* line 3, ../../../app/stylesheets/closet_pages/_new.sass */ body.closet_pages-new #closet-page-form, body.closet_pages-create #closet-page-form {