修改了需求列表的结构,添加了分页,并且修改了新建需求的BUG,

This commit is contained in:
fanqiang 2013-08-04 10:11:38 +08:00
parent f2d4d1dfff
commit 8c80e56019
6 changed files with 76 additions and 52 deletions

View File

@ -4,12 +4,12 @@ class BidsController < ApplicationController
helper :watchers helper :watchers
def index def index
if params[:bid_title]
Bid.creat_bids(params[:bid_budget], params[:bid_deadline], params[:bid_title] , params[:bid_description])
end
# @requirement_title = "4" # @requirement_title = "4"
@offset = 0 @limit = 5
@limit = 20 @bid_count = Bid.count
@bid_pages = Paginator.new @bid_count, @limit, params['page']
@offset ||= @bid_pages.offset
@bids = Bid.offset(@offset).limit(@limit).all @bids = Bid.offset(@offset).limit(@limit).all
end end
@ -96,7 +96,7 @@ class BidsController < ApplicationController
# @message_count = a_message.count # @message_count = a_message.count
respond_to do |format| respond_to do |format|
format.html { redirect_to :back } # format.html
format.js format.js
#format.api { render_api_ok } #format.api { render_api_ok }
end end
@ -120,7 +120,20 @@ class BidsController < ApplicationController
end end
def new_bid def new_bid
if params[:bid_title]
Bid.creat_bids(params[:bid_budget], params[:bid_deadline], params[:bid_title] , params[:bid_description])
end
@limit = 5
@bid_count = Bid.count
@bid_pages = Paginator.new @bid_count, @limit, params['page']
@offset ||= @bid_pages.offset
@bids = Bid.offset(@offset).limit(@limit).all
respond_to do |format|
# format.html
format.html { redirect_to :back }
format.js
# format.api { render_api_ok }
end
end end
def more def more

View File

@ -12,7 +12,8 @@ class Bid < ActiveRecord::Base
validates_length_of :name, :maximum => NAME_LENGTH_LIMIT validates_length_of :name, :maximum => NAME_LENGTH_LIMIT
validates_length_of :description, :maximum => DESCRIPTION_LENGTH_LIMIT validates_length_of :description, :maximum => DESCRIPTION_LENGTH_LIMIT
validates_presence_of :author_id, :name validates_presence_of :author_id, :name, :deadline
# validates_format_of :deadline, :with =>
validate :validate_user validate :validate_user
acts_as_watchable acts_as_watchable

View File

@ -0,0 +1,49 @@
<table width="500px" border="0" style="padding-left: 10px; margin-bottom: 15px; padding-top: 10px;">
<td width="100px" class="font_lighter" style="font-size: 16px;">需求列表</td>
<td>
<div class='icon icon-add' >
<%= toggle_link l(:button_bidding), 'put-bid-form', {:focus => 'project_id'} %>
</div></td>
</table>
<% bids.each do |bid|%>
<table width="80%" border="0" style="padding-left: 10px">
<tr>
<td colspan="2" valign="top" width="50" ><%= link_to image_tag(url_to_avatar(bid.author), :class => 'avatar'), :class => "avatar" %></td>
<td>
<table width="100%" border="0">
<tr>
<td colspan="2" valign="top"><strong><%= link_to(bid.author, user_path(bid.author), :class => 'bid_user') %>:<%= link_to(bid.name, respond_path(bid), :class => 'bid_path') %></strong></td>
</tr>
<tr>
<td width="500">
<table border="0">
<tr>
<td style="color: rgb(255, 0, 0);"><strong>悬赏:¥<%= bid.budget%></strong></td>
<td class="font_lighter">(<%= link_to bid.biding_projects.count, project_for_bid_path(bid)%>)应标</td>
<td class="font_lighter">(<%= link_to bid.commit, respond_path(bid)%>)反馈</td>
<td class="font_lighter">(<%= link_to bid.watcher_users.count, respond_path(bid)%>)关注</td>
</tr>
</table></td>
<td width="200" align="right" class="a"><a class="font_lighter"> <%= format_time bid.created_at %></a></td>
</tr>
<tr>
<td>
<div class="bid-description" style="border-left: 1px solid rgb(225, 225, 225); border-bottom: 1px solid rgb(225, 225, 225); padding-left: 20px; padding-bottom: 10px; margin-bottom: 20px;">
<table>
<tr>
<td> <%= bid.description%> </td>
</tr>
</table>
</div></td>
</tr>
</table></td>
</tr>
</table>
<% end %>
<div class="pagination">
<ul>
<%= pagination_links_full bid_pages %>
<ul>
</div>

View File

@ -4,7 +4,7 @@
} }
</script> </script>
<%= form_tag({:controller => 'bids', <%= form_tag({:controller => 'bids',
:action => 'index', :action => 'new_bid',
:remote => true, :remote => true,
:method => :post, :method => :post,
:id => 'new-bid-form'}) do %> :id => 'new-bid-form'}) do %>

View File

@ -2,47 +2,7 @@
<%= render :partial => 'new_bid' %> <%= render :partial => 'new_bid' %>
</div> </div>
<table width="500px" border="0" style="padding-left: 10px; margin-bottom: 15px; padding-top: 10px;"> <div id="bid-show">
<td width="100px" class="font_lighter" style="font-size: 16px;">需求列表</td> <%= render :partial => 'bid_show', :locals => {:bids => @bids, :bid_pages => @bid_pages} %>
<td> </div>
<div class='icon icon-add' >
<%= toggle_link l(:button_bidding), 'put-bid-form', {:focus => 'project_id'} %>
</div></td>
</table>
<% @bids.each do |bid|%>
<table width="80%" border="0" style="padding-left: 10px">
<tr>
<td colspan="2" valign="top" width="50" ><%= link_to image_tag(url_to_avatar(bid.author), :class => 'avatar'), :class => "avatar" %></td>
<td>
<table width="100%" border="0">
<tr>
<td colspan="2" valign="top"><strong><%= link_to(bid.author, user_path(bid.author), :class => 'bid_user') %>:<%= link_to(bid.name, respond_path(bid), :class => 'bid_path') %></strong></td>
</tr>
<tr>
<td width="500">
<table border="0">
<tr>
<td style="color: rgb(255, 0, 0);"><strong>悬赏:¥<%= bid.budget%></strong></td>
<td class="font_lighter">(<%= link_to bid.biding_projects.count, project_for_bid_path(bid)%>)应标</td>
<td class="font_lighter">(<%= link_to bid.commit, respond_path(bid)%>)反馈</td>
<td class="font_lighter">(<%= link_to bid.watcher_users.count, respond_path(bid)%>)关注</td>
</tr>
</table></td>
<td width="200" align="right" class="a"><a class="font_lighter"> <%= format_time bid.created_at %></a></td>
</tr>
<tr>
<td>
<div class="bid-description" style="border-left: 1px solid rgb(225, 225, 225); border-bottom: 1px solid rgb(225, 225, 225); padding-left: 20px; padding-bottom: 10px; margin-bottom: 20px;">
<table>
<tr>
<td> <%= bid.description%> </td>
</tr>
</table>
</div></td>
</tr>
</table></td>
</tr>
</table>
<% end %>

View File

@ -0,0 +1 @@
$('#bid-show').html('<%= escape_javascript(render(:partial => 'bids/bid_show', :locals => {:bids => @bids, :bid_pages => @bid_pages})) %>');