修改了tag的显示
This commit is contained in:
parent
f6d5ef1c69
commit
11df7d2787
|
@ -10,7 +10,6 @@ class PraiseTreadController < ApplicationController
|
|||
@obj_id = params[:obj_id]
|
||||
@obj_type = params[:obj_type]
|
||||
@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
|
||||
|
@ -46,7 +45,6 @@ class PraiseTreadController < ApplicationController
|
|||
@obj_id = params[:obj_id]
|
||||
@obj_type = params[:obj_type]
|
||||
@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
|
||||
|
|
|
@ -31,7 +31,7 @@ class UsersController < ApplicationController
|
|||
accept_api_auth :index, :show, :create, :update, :destroy,:tag_save
|
||||
|
||||
#william
|
||||
before_filter :need_login,:only => :tag_save
|
||||
before_filter :require_login,:only => :tag_save
|
||||
|
||||
|
||||
helper :sort
|
||||
|
|
|
@ -9,17 +9,18 @@ module PraiseTreadHelper
|
|||
end
|
||||
#end
|
||||
|
||||
def get_praise_num(object,flag)
|
||||
def get_praise_num(object)
|
||||
@obj_type = object.class
|
||||
@obj_id = object.id
|
||||
@record = PraiseTreadCache.find_by_object_id_and_object_type(@obj_id,@obj_type)
|
||||
if @record
|
||||
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
|
||||
# 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
|
||||
return (@record.praise_num.to_i-@record.tread_num.to_i)
|
||||
else
|
||||
return 0
|
||||
end
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
<h3><%= issue_heading(@issue) %></h3>
|
||||
|
||||
<style type="text/css"></style>>
|
||||
|
||||
<div class="<%= @issue.css_classes %> details">
|
||||
<% if @prev_issue_id || @next_issue_id %>
|
||||
<div class="next-prev-links contextual">
|
||||
|
@ -37,7 +39,7 @@
|
|||
</p>
|
||||
<!-- added by william -for tag -->
|
||||
<div id="tags">
|
||||
<%= render :partial => 'layouts/tag', :locals => {:obj => @issue,:object_flag => "3" }%>
|
||||
<%= render :partial => 'tags/tag', :locals => {:obj => @issue,:object_flag => "3" }%>
|
||||
</div>
|
||||
<table class="attributes">
|
||||
<%= issue_fields_rows do |rows|
|
||||
|
|
|
@ -66,7 +66,7 @@
|
|||
<table style="font-family:微软雅黑">
|
||||
<tr>
|
||||
<td><!-- added by william -for tag -->
|
||||
<%= render :partial => 'layouts/tag', :locals => {:obj => @bid, :object_flag => "4"}%>
|
||||
<%= render :partial => 'tags/tag', :locals => {:obj => @bid, :object_flag => "4"}%>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
|
|
@ -109,7 +109,7 @@
|
|||
<div class="tag_font">
|
||||
<!-- added by william -for tag -->
|
||||
<div id="tags">
|
||||
<%= render :partial => 'layouts/tag', :locals => {:obj => @project,:object_flag => "2"}%>
|
||||
<%= render :partial => 'tags/tag', :locals => {:obj => @project,:object_flag => "2"}%>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
<div class="tags">
|
||||
<!-- added by william -for tag -->
|
||||
<div id="tags">
|
||||
<%= render :partial => 'layouts/tag', :locals => {:obj => @project,:object_flag => "2"}%>
|
||||
<%= render :partial => 'tags/tag', :locals => {:obj => @project,:object_flag => "2"}%>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<!-- get_praise_num(obj,1)函数中 1代表返回顶得次数 0返回踩的次数 -->
|
||||
<% if User.current.logged? %>
|
||||
<div id="praise_tread_<%= obj.id %>" style="float:right;">
|
||||
|
||||
<% @is_valuate = is_praise_or_tread(obj,user_id)%>
|
||||
|
@ -10,7 +11,7 @@
|
|||
<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>
|
||||
<td align="center"><strong class="font_small_watch"><%= get_praise_num(obj)%></strong></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
|
@ -24,7 +25,7 @@
|
|||
</tr>
|
||||
|
||||
<tr>
|
||||
<td align="center"><strong class="font_small_watch">-<%= get_praise_num(obj,0)%></strong></td>
|
||||
<td align="center"><strong class="font_small_watch"><%= get_praise_num(obj)%></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><%= image_tag("/images/praise_tread/tread_true.png") %> </td>
|
||||
|
@ -40,11 +41,7 @@
|
|||
: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>
|
||||
<td align="center"><strong class="font_small_watch"><%= get_praise_num(obj)%></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> <%= link_to image_tag("/images/praise_tread/tread_false.png"),:controller=>"praise_tread",
|
||||
|
@ -55,3 +52,4 @@
|
|||
<% end %>
|
||||
</div>
|
||||
|
||||
<% end %>
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
|
||||
$('#praise_tread_<%= @obj.id %>').html('<%= j(
|
||||
render :partial => "/praise_tread/praise_tread",:locals => {:obj => @obj,:user_id => User.current.id}
|
||||
)%>');
|
||||
|
|
@ -44,7 +44,7 @@
|
|||
<!-- added by william -for tag -->
|
||||
<div id="tags">
|
||||
<%= tag('img', {:src => "/images/sidebar/tags.png"}, false, false) %>
|
||||
<%= render :partial => 'layouts/tag_name', :locals => {:obj => @project,:object_flag => "2",:non_list_all => true }%>
|
||||
<%= render :partial => 'tags/tag_name', :locals => {:obj => @project,:object_flag => "2",:non_list_all => true }%>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
<div id="tags">
|
||||
<% if User.current.logged? %>
|
||||
<%= tag('img', {:src => "/images/sidebar/tags.png"}, false, false) %>
|
||||
<% end %>
|
||||
<strong><label><%= l(:label_tag) %>:</label></strong>
|
||||
<!-- 1代表是user类型 2代表是project类型 3代表是issue类型 -->
|
||||
<!-- 3 代表的是issue 当是issue是 处理方式与前2个对象不同 -->
|
||||
<% if object_flag == '3' %>
|
||||
<% if User.current.logged? %>
|
||||
<%= toggle_link (image_tag "/images/sidebar/add.png"), 'put-tag-form-issue', {:focus => 'name-issue'} %>
|
||||
<% end %>
|
||||
<div id="tags_show_issue">
|
||||
<%= render :partial => "tags/tag_name",:locals => {:obj => obj,:non_list_all => false ,:object_flag => object_flag} %>
|
||||
</div>
|
||||
<div id="put-tag-form-issue" style="display: none">
|
||||
<%= form_for "tag_for_save",:remote=>true,:url=>tag_path,
|
||||
:update => "tags_show",
|
||||
:complete => '$("#put-tag-form-issue").hide();' do |f| %>
|
||||
<%= f.text_field :name ,:id => "name-issue",:size=>"30" %>
|
||||
<%= f.text_field :object_id,:value=> obj.id,:style=>"display:none"%>
|
||||
<%= f.text_field :object_flag,:value=> object_flag,:style=>"display:none"%>
|
||||
<%= f.submit "add"%>
|
||||
<%= link_to_function l(:button_cancel), '$("#put-tag-form-issue").hide();'%>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<% else %>
|
||||
<% if User.current.logged? %>
|
||||
<%= toggle_link (image_tag "/images/sidebar/add.png"), 'put-tag-form', {:focus => 'name'} %>
|
||||
<% end %>
|
||||
<div id="tags_show">
|
||||
<%= render :partial => "tags/tag_name",:locals => {:obj => obj,:non_list_all => false ,:object_flag => object_flag} %>
|
||||
</div>
|
||||
<div id="put-tag-form" style="display: none">
|
||||
<%= form_for "tag_for_save",:remote=>true,:url=>tag_path,
|
||||
:update => "tags_show",
|
||||
:complete => '$("#put-tag-form").hide();' do |f| %>
|
||||
<%= f.text_field :name ,:id => "name",:size=>"28"%>
|
||||
<%= f.text_field :object_id,:value=> obj.id,:style=>"display:none"%>
|
||||
<%= f.text_field :object_flag,:value=> object_flag,:style=>"display:none"%>
|
||||
<%= f.submit "add"%>
|
||||
<%= link_to_function l(:button_cancel), '$("#put-tag-form").hide();'%>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
|
@ -0,0 +1,61 @@
|
|||
<style type="text/css">
|
||||
.click {
|
||||
background: #b77b1b;
|
||||
}
|
||||
.unclick {
|
||||
background: #b77b1b;
|
||||
}
|
||||
#tag {
|
||||
background: url(/images/issue_tag.png) no-repeat right -19px;
|
||||
border-radius: 5px 5px 5px 5px;
|
||||
color: #3a587d !important;
|
||||
padding: 0px 4px;
|
||||
margin: 3px;
|
||||
display: inline-block;
|
||||
font-size: 11px;
|
||||
text-decoration: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
#tag:hover {
|
||||
color: #fff;
|
||||
}
|
||||
a:visited {
|
||||
text-decoration: none;
|
||||
}
|
||||
</style>
|
||||
<!-- 1代表是user类型 2代表是project类型 3代表是issue类型 4代表需求-->
|
||||
<% @tags = obj.reload.tag_list %>
|
||||
|
||||
<% if non_list_all and (@tags.size > 0) %>
|
||||
<!-- 这里是显示的非主页的tag 所以当tag数量较多时 不必全部显示 用“更多”代替 -->
|
||||
<% if @tags.size > Setting.show_tags_length.to_i then %>
|
||||
<% i = 0 %>
|
||||
<% until i>Setting.show_tags_length.to_i do %>
|
||||
<div id="tag" class="click unclick">
|
||||
<%= link_to @tags[i], :controller => "tags",:action => "index",:q => @tags[i],:object_flag => object_flag,:obj_id => obj.id %>
|
||||
</div>
|
||||
<% i += 1%>
|
||||
<% end %>
|
||||
<%= link_to l(:label_more_tags),:action => "show",:id => obj.id %>
|
||||
|
||||
<% else %>
|
||||
|
||||
<% @tags.each do |tag| %>
|
||||
<div id="tag" class="click unclick">
|
||||
<%= link_to tag,:controller => "tags",:action => "index",:q=>tag,:object_flag => object_flag,:obj_id => obj.id
|
||||
%>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% else %>
|
||||
<!-- 用来显示三大对象的主页中的tag 故是全部显示 -->
|
||||
<% if @tags.size > 0 %>
|
||||
<% @tags.each do |tag| %>
|
||||
<div id="tag" class="click unclick">
|
||||
<%= link_to tag,:controller => "tags",:action => "index",:q=>tag ,:object_flag => object_flag,:obj_id => obj.id %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% end %>
|
|
@ -149,7 +149,7 @@
|
|||
<div class="newsplitcontentleft">
|
||||
<!-- added by william -for tag -->
|
||||
<div id="tags">
|
||||
<%= render :partial => 'layouts/tag', :locals => {:obj => @user,:object_flag => "1"}%>
|
||||
<%= render :partial => 'tags/tag', :locals => {:obj => @user,:object_flag => "1"}%>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
|
||||
|
||||
<% if @obj_flag == '3'%>
|
||||
$('#tags_show_issue').html('<%= escape_javascript(render :partial => 'layouts/tag_name',
|
||||
$('#tags_show_issue').html('<%= escape_javascript(render :partial => 'tags/tag_name',
|
||||
:locals => {:obj => @obj,:non_list_all => false,:object_flag => @obj_flag}) %>');
|
||||
$('#put-tag-form-issue').hide();
|
||||
$('#name-issue').val("");
|
||||
<% else %>
|
||||
$('#tags_show').html('<%= escape_javascript(render :partial => 'layouts/tag_name',
|
||||
$('#tags_show').html('<%= escape_javascript(render :partial => 'tags/tag_name',
|
||||
:locals => {:obj => @obj,:non_list_all => false,:object_flag => @obj_flag}) %>');
|
||||
$('#put-tag-form').hide();
|
||||
$('#name').val("");
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 3.8 KiB |
Loading…
Reference in New Issue