Skip to content

Commit

Permalink
Merge branch 'master' of git@github.com:medwezys/lazy_acc
Browse files Browse the repository at this point in the history
  • Loading branch information
titas committed Apr 11, 2010
2 parents c9a1eba + ef43666 commit c453bb8
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 43 deletions.
21 changes: 21 additions & 0 deletions app/helpers/buckets_helper.rb
@@ -1,2 +1,23 @@
module BucketsHelper
def count_bar_width(color, curr_budget, curr_reserved, available_pixels = 750)
curr_budget += 1
curr_reserved += 1
min_width = 50

red = available_pixels * (curr_reserved/curr_budget)
if red < min_width
red = min_width
elsif available_pixels-red < min_width
red = available_pixels - min_width
end

ret = case color
when 'red'
red
else
available_pixels - red
end

return ret.to_i
end
end
41 changes: 11 additions & 30 deletions app/views/buckets/index.html.erb
@@ -1,53 +1,34 @@
<h1>Listing buckets</h1>

<!-- <table>
<tr>
<th>Title</th>
<th>Description</th>
<th>User</th>
</tr>
<% @buckets.each do |bucket| %>
<tr>
<div id="#{bucket.name}" class="bucket">
</div>
</tr>
<tr>
<td><%=h bucket.title %></td>
<td><%=h bucket.description %></td>
<td><%=h bucket.user_id %></td>
<td><%= link_to 'Show', bucket %></td>
<td><%= link_to 'Edit', edit_bucket_path(bucket) %></td>
<td><%= link_to 'Destroy', bucket, :confirm => 'Are you sure?', :method => :delete %></td>
</tr>
<% end %>
</table> -->
<h1>Your buckets</h1>

<% @buckets.each do |bucket| %>
<div class="bucket_title">
<%= link_to bucket.title, bucket %>
<br/>
Total budget for this month:
<%= bucket.current_budget_amount %>
<%= curr_budget = bucket.current_budget_amount %>
<% curr_reserved = bucket.current_trans_amount %>
</div>
<div id="#{bucket.name}" class="bucket">
<ul class="bucklist">
<li class="redleft">

</li>
<li class="redin" style="width: 40%;">
<%= curr_reserved = bucket.current_trans_amount %> $
<li class="redin" style=<%="width:#{count_bar_width('red', curr_budget, curr_reserved)}px;"%>>
<%= curr_reserved %> $
</li>
<li class="greenin" style="width: 40%;">
YYY $
<li class="greenin" style=<%="width:#{count_bar_width('green', curr_budget, curr_reserved)}px;"%>>
<%= curr_budget - curr_reserved %> $
</li>
<li class="greenright">

</li>
</ul>
<br/>
</div>
<div class="bucket_links">
<%= link_to "Manage transactions", transactions_path(:for_bucket => bucket.id) %>
<%= link_to "Manage bills", bills_path(:for_bucket => bucket.id) %>
</div>
<% end %>
<br />

Expand Down
Binary file modified db/development.sqlite3
Binary file not shown.
15 changes: 8 additions & 7 deletions db/schema.rb
Expand Up @@ -9,7 +9,7 @@
#
# It's strongly recommended to check this file into your version control system.

ActiveRecord::Schema.define(:version => 20100410123521) do
ActiveRecord::Schema.define(:version => 20100411072716) do

create_table "bills", :force => true do |t|
t.integer "bucket_id"
Expand All @@ -29,7 +29,7 @@
t.integer "user_id"
t.datetime "created_at"
t.datetime "updated_at"
t.integer "credit_debet", :default => -1
t.integer "credit_debet"
end

create_table "budgets", :force => true do |t|
Expand Down Expand Up @@ -65,16 +65,17 @@
create_table "users", :force => true do |t|
t.datetime "created_at"
t.datetime "updated_at"
t.string "login", :null => false
t.string "crypted_password", :null => false
t.string "password_salt", :null => false
t.string "persistence_token", :null => false
t.integer "login_count", :default => 0, :null => false
t.string "login", :null => false
t.string "crypted_password", :null => false
t.string "password_salt", :null => false
t.string "persistence_token", :null => false
t.integer "login_count", :default => 0, :null => false
t.datetime "last_request_at"
t.datetime "last_login_at"
t.datetime "current_login_at"
t.string "last_login_ip"
t.string "current_login_ip"
t.boolean "has_current_budgets"
end

add_index "users", ["last_request_at"], :name => "index_users_on_last_request_at"
Expand Down
12 changes: 6 additions & 6 deletions public/stylesheets/layout.css
Expand Up @@ -589,12 +589,7 @@ ul.submenu2 a:hover {
font-weight: 800;
padding: 23px;
}
.greenin *{

}
.redin *{

}

.bucklist{
list-style: none;
/* float: left;
Expand All @@ -610,4 +605,9 @@ ul.submenu2 a:hover {
text-align: center;
font-weight: 700;
font-size: 14px;
}
.bucket_links{
text-align: center;
font-weight: 700;
margin-bottom: 20px;
}

0 comments on commit c453bb8

Please sign in to comment.