为用户活动添加分页功能

This commit is contained in:
fanqiang 2013-08-08 10:04:44 +08:00
parent dc12301e4f
commit 4676eed9a3
7 changed files with 94 additions and 53 deletions

View File

@ -20,20 +20,20 @@ class BidsController < ApplicationController
limit = @bid_count % @limit
@bids = @bids.offset(@offset).limit(limit).all.reverse
end
# @limit = api_offset_and_limit({:limit => 5})
# @bids = Bid.visible
# @bids = @bids.like(params[:name]) if params[:name].present?
# @bid_count = @bids.count
# @bid_pages = Paginator.new @bid_count, @limit, params['page']
# @offset ||= @bid_pages.reverse_offset
# #@bids = @bids.offset(@offset).limit(@limit).all.reverse
# unless @offset == 0
# @bids = @bid_count.offset(@offset).limit(@limit).all.reverse
# else
# limit = @bid_count%@limit
# @bids = @bid_count.offset(@offset).limit(limit).all.reverse
# end
# #end
# @limit = api_offset_and_limit({:limit => 5})
# @bids = Bid.visible
# @bids = @bids.like(params[:name]) if params[:name].present?
# @bid_count = @bids.count
# @bid_pages = Paginator.new @bid_count, @limit, params['page']
# @offset ||= @bid_pages.reverse_offset
# #@bids = @bids.offset(@offset).limit(@limit).all.reverse
# unless @offset == 0
# @bids = @bid_count.offset(@offset).limit(@limit).all.reverse
# else
# limit = @bid_count%@limit
# @bids = @bid_count.offset(@offset).limit(limit).all.reverse
# end
# #end
end
def show
@ -71,6 +71,7 @@ class BidsController < ApplicationController
end
end
###添加应标项目
def add
project = Project.where('name = ?', params[:bid]).first
bid_message = params[:bid_for_save][:bid_message]
@ -83,7 +84,9 @@ class BidsController < ApplicationController
end
end
## 新建留言
def create
if params[:bid_message].size>0
message = params[:bid_message][:message]
refer_user_id = params[:bid_message][:reference_user_id].to_i
@ -100,12 +103,13 @@ class BidsController < ApplicationController
@bid.set_commit(@jour.count)
respond_to do |format|
# format.html { redirect_to_referer_or {render :text => 'Watcher added.', :layout => true}}
format.js
#format.api { render_api_ok }
end
end
##删除留言
def destroy
JournalsForMessage.delete_message(params[:object_id])
@jour = @bid.journals_for_messages
@ -125,6 +129,7 @@ class BidsController < ApplicationController
end
end
##引用
def new
@jour = JournalsForMessage.find(params[:journal_id]) if params[:journal_id]
if @jour
@ -143,6 +148,7 @@ class BidsController < ApplicationController
render_404
end
##新建需求
def new_bid
if params[:bid_title]
bid = Bid.creat_bids(params[:bid_budget], params[:bid_deadline], params[:bid_title] , params[:bid_description])

View File

@ -178,8 +178,19 @@ class UsersController < ApplicationController
activity.scope_select {|t| !has["show_#{t}"].nil?}
events = activity.events(nil, nil, :limit => 10)
end
@events = []
@events_by_day = events.group_by(&:event_date)
@events_by_day.keys.sort.reverse.each do |day|
@events += @events_by_day[day].sort {|x,y| y.event_datetime <=> x.event_datetime}
end
@offset, @limit = api_offset_and_limit({:limit => 10})
@activity_count = @events.size
@activity_pages = Paginator.new @activity_count, @limit, params['page']
@offset ||= @activity_pages.offset
@events_by_day_ = @events.slice(@offset,@limit)
#Modified by nie
unless User.current.admin?
if !@user.active? #|| (@user != User.current && @memberships.empty? && events.empty?)

View File

@ -1,4 +1,27 @@
<!-- fq -->
<style>
input[type="submit"].bid_btn {
vertical-align: middle;
width: 80px;
height: 30px;
line-height: 18px;
font-size: 14px;
color: rgb(255, 255, 255);
background: url("../images/button/bg105.jpg") no-repeat scroll left top transparent;
padding: 0px 0px 4px 0px;
border-radius: 2px;
border: 1px solid rgb(148, 148, 148);
box-shadow: none;
text-shadow: none;
margin-top: -10px;
margin-right: -5px;
}
textarea:focus {
border: #d5dee9 1px solid;
}
</style>
<script type="text/javascript" language="javascript">
function clearInfo(id, content) {
var text = $('#' + id);
@ -21,7 +44,7 @@
:id => 'new-bid-form'}) do %>
<%= error_messages_for 'bid' %>
<table border="0" width="600px" style="border-left: 1px solid #acaeb1; border-right: 1px solid #acaeb1;
border-top: 1px solid #acaeb1; border-bottom: 1px solid #acaeb1; margin-top: 60px; margin-left: 30px;">
border-top: 1px solid #acaeb1; border-bottom: 1px solid #acaeb1; margin-top: 30px; margin-left: 30px;">
<tr>
<td><%= text_field_tag 'bid_title', "为你的需求起个名字~~", :class => 'noline', :required => true, :onfocus => "clearInfo('bid_title', '为你的需求起个名字~~')", :onblur => "showInfo('bid_title', '为你的需求起个名字~~')"%></td>
</tr>
@ -29,25 +52,29 @@ border-top: 1px solid #acaeb1; border-bottom: 1px solid #acaeb1; margin-top: 60p
<td><div class="tableline"></div></td>
</tr>
<tr>
<td><%= text_area_tag 'bid_description', "说出你的需求>找到威客来帮你>支付担保金让威客开始工作 >验收付款并评价", :class => 'noline', :required => true, :style => "resize: none;", :rows => 8,
:onfocus => "clearInfo('bid_description', '说出你的需求>找到威客来帮你>支付担保金让威客开始工作 >验收付款并评价')", :onblur => "showInfo('bid_description', '说出你的需求>找到威客来帮你>支付担保金让威客开始工作 >验收付款并评价')" %></td>
<td><%= text_area_tag 'bid_description', "说出你的需求>找到威客来帮你>支付担保金让威客开始工作>验收付款并评价", :class => 'noline', :required => true, :style => "resize: none;", :rows => 6,
:onfocus => "clearInfo('bid_description', '说出你的需求>找到威客来帮你>支付担保金让威客开始工作>验收付款并评价')", :onblur => "showInfo('bid_description', '说出你的需求>找到威客来帮你>支付担保金让威客开始工作>验收付款并评价')" %></td>
</tr>
<tr>
<td><div class="tableline"></div></td>
</tr>
<tr>
<td><%= text_field_tag 'bid_budget', "支付担保金额", :class => 'noline', :required => true %></td>
<td><%= text_field_tag 'bid_budget', "支付担保金额", :class => 'noline', :required => true,
:onfocus => "clearInfo('bid_budget', '支付担保金额')", :onblur => "showInfo('bid_budget', '支付担保金额')" %>
</td>
</tr>
<tr>
<td><div class="tableline"></div></td>
</tr>
<tr>
<td><%= text_field_tag 'bid_deadline', "投资时限 yyyy-mm-dd", :class => 'noline', :required => true, :onfocus => "clearInfo('bid_deadline')"%><%= calendar_for('bid_deadline')%></td>
<td><%= text_field_tag 'bid_deadline', "投资时限 yyyy-mm-dd", :class => 'noline', :required => true,
:onfocus => "clearInfo('bid_deadline', '投资时限 yyyy-mm-dd')", :onblur => "showInfo('bid_deadline', '投资时限 yyyy-mm-dd')"%>
<%= calendar_for('bid_deadline')%></td>
</tr>
</table>
<table id="bidding_table" border="0" width="600" style="margin-top: 20px; margin-left: 30px;">
<table id="bidding_table" border="0" width="600" style="margin-top: 10px; margin-left: 30px;">
<tr>
<td align="right"><%= submit_tag l(:button_new_bid) %></td>
<td align="right"> <%= submit_tag l(:button_new_bid), :name => nil , :class => "bid_btn", :onmouseout => "this.style.backgroundPosition = 'left top'", :onmouseover => "this.style.backgroundPosition = 'left -30px'"%> </td>
</tr>
</table>
<%end%>

View File

@ -1,9 +1,5 @@
<!-- fq -->
<% if User.current.logged? %>
<div id="put-bid-form" style="display: none">
<%= render :partial => 'new_bid' %>
</div>
<% end %>
<%= form_tag(bids_path, :method => :get) do %>
<div class="project-search-block">
<span><%=l(:label_bid_plural)%></span>
@ -13,6 +9,13 @@
</div>
</div>
<%end%>
<% if User.current.logged? %>
<div id="put-bid-form" style="display: none">
<%= render :partial => 'new_bid' %>
</div>
<% end %>
<div id="bid-show">
<%= render :partial => 'bid_show', :locals => {:bids => @bids, :bid_pages => @bid_pages} %>
</div>

View File

@ -107,15 +107,7 @@
</div>
</div>
<!--扩充-->
<div class="user_other_model">
<div class="font_title_left">
<strong>访客统计</strong>
</div>
<hr />
<tr>
总访问量1232
</tr>
</div>
</div>
</div>

View File

@ -1,7 +1,6 @@
<% unless @events_by_day.empty? %>
<div id="activity">
<% @events_by_day.keys.sort.reverse.each do |day| %>
<% @events_by_day[day].sort {|x,y| y.event_datetime <=> x.event_datetime }.each do |e| -%>
<% @events_by_day_.each do |e| %>
<table width="660" border="0" align="left" style="border-bottom: 1px solid rgb(225, 225, 225); margin-bottom: 10px;">
<tr>
<!-- fq -->
@ -24,15 +23,17 @@
</tr>
<tr>
<td align="left"><a class="font_lighter"></a></td>
<td width="200" align="right" class="a"><span class="font_lighter"><%= format_activity_day(day) %></span></td>
<td width="200" align="right" class="a"><span class="font_lighter"><%= format_time(e.event_datetime) %></span></td>
</tr>
<!-- <tr><div class="line_under"></div></tr> -->
</table></td>
</tr>
<% end %>
</table>
<% end %>
</div>
<% else %>
<%= l(:label_user_activities) %>
<div class="pagination" style="float:left;">
<ul>
<%= pagination_links_full @activity_pages %>
<ul>
</div>
<% end %>

View File

@ -1676,13 +1676,12 @@ a.bid_user {
font-size:12px;
}
input[type='text'].noline {
border-style: none;
border-color: white;
border-width: medium;
font-size: 16px;
border: #d5dee9 1px solid;
font-size: 12px;
color: #ACAEB1;
padding: 10px 0px;
width: 100%;
padding: 10px 5px;
width: 98%;
cursor: text;
}
.noline {
/*border-style: none;
@ -1690,13 +1689,15 @@ input[type='text'].noline {
border: #d5dee9 1px solid;
font-size: 12px;
color: #ACAEB1;
padding: 10px 0px;
width: 100%;
padding: 10px 5px;
width: 98%;
cursor: text;
}
.grayline{
border-color: #ACAEB1;
border-width: 1px;
border: #d5dee9 1px solid;
font-size: 12px;
color: #ACAEB1;
width: 100%;
}
div.tableline{
height: 1px;