1.重新定义了顶和踩得规则:
对于为评价的问题,同时显示顶和踩的数字,并且数字的“+”“-”标成黑色; 对于评价的问题,如果评价是顶,则只显示所有顶的次数;反之,亦然; 2.在问题列表中也添加了顶和踩的功能; 3.对于问题列表的描述,在描述内容前添加了“描述:”, 所以为空的情况下,该处显示占位依然存在,使列表显示格式统一
This commit is contained in:
parent
4bc217b52c
commit
cf9aa12727
|
@ -1,10 +1,17 @@
|
|||
class PraiseTreadController < ApplicationController
|
||||
|
||||
accept_api_auth :tread_plus,:praise_plus
|
||||
before_filter :require_login,:only => [:praise_plus,:tread_plus]
|
||||
|
||||
def praise_plus
|
||||
@obj = nil
|
||||
# @is_in_list = nil
|
||||
if request.get?
|
||||
@obj_id = params[:obj_id]
|
||||
@obj_type = params[:obj_type]
|
||||
@obj = praise_tread_plus(@obj_type,@obj_id,1)
|
||||
@obj = find_object_by_type_and_id(@obj_type,@obj_id)
|
||||
# @is_in_list = params[:is_in_list]
|
||||
praise_tread_plus(@obj_type,@obj_id,1)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -34,10 +41,13 @@ class PraiseTreadController < ApplicationController
|
|||
|
||||
def tread_plus
|
||||
@obj = nil
|
||||
# @is_in_list = nil
|
||||
if request.get?
|
||||
@obj_id = params[:obj_id]
|
||||
@obj_type = params[:obj_type]
|
||||
@obj = praise_tread_plus(@obj_type,@obj_id,0)
|
||||
@obj = find_object_by_type_and_id(@obj_type,@obj_id)
|
||||
# @is_in_list = params[:is_in_list]
|
||||
praise_tread_plus(@obj_type,@obj_id,0)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -79,14 +89,11 @@ class PraiseTreadController < ApplicationController
|
|||
#再创建或更新praise_tread_cache表
|
||||
@ptc = PraiseTreadCache.find_by_object_id_and_object_type(id,type)
|
||||
@ptc = @ptc.nil? ? PraiseTreadCache.new : @ptc
|
||||
@ptc.object_id = id.to_i
|
||||
@ptc.object_type = type
|
||||
@ptc.save
|
||||
@ptc.plus(1)
|
||||
@ptc.object_id = id.to_i
|
||||
@ptc.object_type = type
|
||||
@ptc.save
|
||||
@ptc.plus(flag,1)
|
||||
end
|
||||
|
||||
@obj = find_object_by_type_and_id(type,id)
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.js
|
||||
|
|
|
@ -28,10 +28,10 @@ class UsersController < ApplicationController
|
|||
before_filter :require_admin, :except => [:show, :index,:tag_save, :user_projects, :user_newfeedback, :user_comments, :watch_bids, :info, :user_watchlist, :user_fanslist,:edit]
|
||||
before_filter :find_user, :only => [:user_fanslist, :user_watchlist, :show, :edit, :update, :destroy, :edit_membership,
|
||||
:destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments, :watch_bids, :info]
|
||||
accept_api_auth :index, :show, :create, :update, :destroy
|
||||
accept_api_auth :index, :show, :create, :update, :destroy,:tag_save
|
||||
|
||||
#william
|
||||
before_filter :require_login,:only=>[:tag_save]
|
||||
before_filter :require_login,:only => :tag_save
|
||||
|
||||
|
||||
helper :sort
|
||||
|
|
|
@ -9,14 +9,19 @@ module PraiseTreadHelper
|
|||
end
|
||||
#end
|
||||
|
||||
def get_praise_num(object)
|
||||
@obj_type = object.class.name.underscore
|
||||
def get_praise_num(object,flag)
|
||||
@obj_type = object.class
|
||||
@obj_id = object.id
|
||||
@record = PraiseTreadCache.find_by_object_id_and_object_type(@obj_id,@obj_type)
|
||||
if @record
|
||||
return @record.praise_num
|
||||
else
|
||||
return 0
|
||||
case flag
|
||||
when 1
|
||||
return @record.praise_num.nil? ? 0 : @record.praise_num
|
||||
when 0
|
||||
return @record.tread_num.nil? ? 0 : @record.tread_num
|
||||
end
|
||||
else
|
||||
return 0
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,8 +1,13 @@
|
|||
class PraiseTreadCache < ActiveRecord::Base
|
||||
attr_accessible :object_id,:object_type,:praise_num,:tread_num
|
||||
|
||||
def plus(num)
|
||||
self.update_attribute(:praise_num, self.praise_num.to_i + num)
|
||||
def plus(flag,num)
|
||||
case flag
|
||||
when 0
|
||||
self.update_attribute(:tread_num, self.tread_num.to_i + num)
|
||||
when 1
|
||||
self.update_attribute(:praise_num, self.praise_num.to_i + num)
|
||||
end
|
||||
end
|
||||
|
||||
def minus(num)
|
||||
|
|
|
@ -72,23 +72,27 @@
|
|||
|
||||
<li id="issue-<%= issue.id %>" class="hascontextmenu-1 <%= issue.css_classes %> <%= level > 0 ? "idnt idnt-#{level}" : nil %>">
|
||||
<% column_content = ( query.inline_columns.map {|column| "#{column_content_new(column, issue)}"}) %>
|
||||
|
||||
<%= render :partial => "/praise_tread/praise_tread",
|
||||
:locals => {:obj => issue,:user_id =>User.current.id}%>
|
||||
|
||||
<% if issue.tracker.name == 'Bug' %>
|
||||
<%= image_tag("/images/task.png", :class => "img-tag-issues") %>
|
||||
<% end %>
|
||||
<% if issue.tracker.name == '任务'%>
|
||||
<%= image_tag("/images/issues.png", :class => "img-tag-issues") %>
|
||||
<% end %>
|
||||
|
||||
<ul class="issue_list">
|
||||
<ul class="list-group-item-meta">
|
||||
<span><%= link_to issue.author.name, user_path(issue.author), :class => "bid_user_u" %></span><%= l(:label_post_on)%><span>
|
||||
<% a = [] %>
|
||||
<% a << column_content[1] %>
|
||||
<% a << "##{column_content[0]}" << "(#{raw column_content[2]}):" << column_content[4] %>
|
||||
<%= link_to a.join(' '), issue_path(issue) %>
|
||||
<span> <%= link_to issue.author.name, user_path(issue.author), :class => "bid_user_u" %></span><%= l(:label_post_on)%> <span> <% a = [] %>
|
||||
<% a << column_content[1] %>
|
||||
<% a << "##{column_content[0]}" << "(#{raw column_content[2]}):" << column_content[4] %>
|
||||
<%= link_to a.join(' '), issue_path(issue) %>
|
||||
</ul>
|
||||
<ul class="list-group-item-meta">
|
||||
<div class="issue-list-description">
|
||||
<%= issue.description %>
|
||||
<%= l(:field_description)%>:<%= issue.description %>
|
||||
</div>
|
||||
</ul>
|
||||
<ul class="list-group-item-meta">
|
||||
|
@ -97,7 +101,9 @@
|
|||
<% end %>
|
||||
<!-- <%= raw column_content[6] %> -->
|
||||
<%= l(:label_updated_time_on, format_date(issue.updated_on)).html_safe %>
|
||||
<div class="find-comment-class"><span><%= link_to l(:label_find_all_comments), issue_path(issue) %></span><%= l(:label_comments_count, :count => issue.journals.all.count) %></div>
|
||||
<div class="find-comment-class">
|
||||
<span><%= link_to l(:label_find_all_comments), issue_path(issue) %></span><%= l(:label_comments_count, :count => issue.journals.all.count) %>
|
||||
</div>
|
||||
</ul>
|
||||
</ul>
|
||||
</li>
|
||||
|
|
|
@ -23,7 +23,12 @@
|
|||
|
||||
<div class="subject">
|
||||
<%= render_issue_subject_with_tree(@issue) %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 顶和踩 -->
|
||||
<%= render :partial => "/praise_tread/praise_tread",
|
||||
:locals => {:obj => @issue,:user_id =>User.current.id}%>
|
||||
|
||||
<p class="author">
|
||||
<%= authoring @issue.created_on, @issue.author %>.
|
||||
<% if @issue.created_on != @issue.updated_on %>
|
||||
|
@ -34,10 +39,6 @@
|
|||
<div id="tags">
|
||||
<%= render :partial => 'layouts/tag', :locals => {:obj => @issue,:object_flag => "3" }%>
|
||||
</div>
|
||||
<span id="praise_tread" style="float:right;">
|
||||
<%= render :partial => "/praise_tread/praise_tread",
|
||||
:locals => {:obj => @issue,:user_id =>User.current.id}%>
|
||||
</span>
|
||||
<table class="attributes">
|
||||
<%= issue_fields_rows do |rows|
|
||||
rows.left l(:field_status), h(@issue.status.name), :class => 'status'
|
||||
|
|
|
@ -1,22 +1,57 @@
|
|||
<span id="praise_tread">
|
||||
<% @is_valuate = is_praise_or_tread(obj,user_id)%>
|
||||
|
||||
<% if @is_valuate.size > 0 %>
|
||||
|
||||
<% @flag = @is_valuate.first.praise_or_tread %>
|
||||
<% if @flag == 1 %> <!-- praise 1 -->
|
||||
<%= image_tag("/images/praise_tread/praise_true.png") %> <strong class="font_small_watch"><%= get_praise_num(obj)%></strong> <%= image_tag("/images/praise_tread/tread_false.png") %>
|
||||
<!-- get_praise_num(obj,1)函数中 1代表返回顶得次数 0返回踩的次数 -->
|
||||
<div id="praise_tread_<%= obj.id %>" style="float:right;">
|
||||
|
||||
<% elsif @flag == 0 %> <!-- tread 0-->
|
||||
<%= image_tag("/images/praise_tread/praise_false.png") %> <strong class="font_small_watch"><%= get_praise_num(obj)%></strong> <%= image_tag("/images/praise_tread/tread_true.png") %>
|
||||
<% end %>
|
||||
<% @is_valuate = is_praise_or_tread(obj,user_id)%>
|
||||
<% if @is_valuate.size > 0 %> <!-- 评价过 1代表赞 0代表踩 -->
|
||||
<% @flag = @is_valuate.first.praise_or_tread %>
|
||||
<% if @flag == 1 %> <!-- 顶过 -->
|
||||
<table style="line-height: 1px">
|
||||
<tr>
|
||||
<td ><%= image_tag("/images/praise_tread/praise_true.png") %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center"><strong class="font_small_watch">+<%= get_praise_num(obj,1)%></strong></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><%= image_tag("/images/praise_tread/tread_false.png") %></td>
|
||||
</tr>
|
||||
</table>
|
||||
<% elsif @flag == 0 %> <!-- 踩过 0-->
|
||||
<table style="line-height: 1px">
|
||||
<tr>
|
||||
<td > <%= image_tag("/images/praise_tread/praise_false.png") %></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td align="center"><strong class="font_small_watch">-<%= get_praise_num(obj,0)%></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><%= image_tag("/images/praise_tread/tread_true.png") %> </td>
|
||||
</tr>
|
||||
</table>
|
||||
<% end %>
|
||||
|
||||
<% else %>
|
||||
<% else %>
|
||||
|
||||
<table style="line-height: 1px">
|
||||
<tr>
|
||||
<td > <%= link_to image_tag("/images/praise_tread/praise_false.png"),
|
||||
:controller=>"praise_tread",:action=>"praise_plus",:remote=>true,:obj_id => obj.id,:obj_type => obj.class%> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center">+<strong class="font_small_watch"><%= get_praise_num(obj,1)%></strong></td>
|
||||
</tr>
|
||||
<tr><td align="center">---</td></tr>
|
||||
<tr>
|
||||
<td align="center">-<strong class="font_small_watch"><%= get_praise_num(obj,0)%></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> <%= link_to image_tag("/images/praise_tread/tread_false.png"),:controller=>"praise_tread",
|
||||
:action=>"tread_plus",:remote=>true,:obj_id => obj.id,:obj_type => obj.class %></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<%= link_to image_tag("/images/praise_tread/praise_false.png"),
|
||||
:controller=>"praise_tread",:action=>"praise_plus",:remote=>true,:obj_id => obj.id,:obj_type => obj.class %> <strong class="font_small_watch"><%= get_praise_num(obj)%></strong> <%= link_to image_tag("/images/praise_tread/tread_false.png"),:controller=>"praise_tread",
|
||||
:action=>"tread_plus",:remote=>true,:obj_id => obj.id,:obj_type => obj.class %>
|
||||
|
||||
<% end %>
|
||||
</span>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
$('#praise_tread').html('<%= j(
|
||||
|
||||
$('#praise_tread_<%= @obj.id %>').html('<%= j(
|
||||
render :partial => "/praise_tread/praise_tread",:locals => {:obj => @obj,:user_id => User.current.id}
|
||||
)%>');
|
||||
|
|
Loading…
Reference in New Issue