ÍêÉÆTagÄ£¿é¡£

This commit is contained in:
william 2013-08-01 20:38:38 +08:00
parent bf1f9b8e19
commit 4c5ba2b6df
8 changed files with 61 additions and 54 deletions

View File

@ -31,6 +31,8 @@ class TagsController < ApplicationController
@obj = Project.find_by_id(@obj_id)
when '3' then
@obj = Issue.find_by_id(@obj_id)
when '4' then
@obj = Bid.find_by_id(@obj_id)
else
@obj = nil
end

View File

@ -1,19 +0,0 @@
class Tag < ActiveRecord::Base
attr_accessible :content
#添加代ç 
has_many :projects, :through => :project_tags
has_many :project_tags, :class_name => 'ProjectTags'
#确定contentä¸ä¼šè¢«é‡å¤å†™å…¥
validates_uniqueness_of :content
validates_presence_of :content
#添加tag内容
def self.add_content(content)
@tag=Tag.new
@tag.content = content
@tag.save
true
end
end
#添加结æŸ

View File

@ -29,8 +29,7 @@
<%= authoring @issue.created_on, @issue.author %>.
<% if @issue.created_on != @issue.updated_on %>
<%= l(:label_updated_time, time_tag(@issue.updated_on)).html_safe %>.
<% end %>
<% end %>
</p>
<!-- added by william -for tag -->
<div id="tags">

View File

@ -1,7 +1,26 @@
<label><%= l(:label_tag) %>:</label>
<!-- 1代表是user类型 2代表是project类型 3代表是issue类型 -->
<!-- 3 代表的是issue 当是issue是 处ç†æ–¹å¼ä¸Žå‰2个对象ä¸åŒ -->
<div id="tags" class="inf_user_context">
<label><%= l(:label_tag) %>:</label>
<!-- 1代表是user类型 2代表是project类型 3代表是issue类型 -->
<!-- 3 代表的是issue 当是issue是 处ç†æ–¹å¼ä¸Žå‰2个对象ä¸åŒ -->
<% if object_flag == '3' %>
<%= toggle_link (image_tag "/images/add.png"), 'put-tag-form-issue', {:focus => 'name'} %>
<div id="tags_show_issue">
<%= render :partial => "layouts/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"%>
<%= 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>
<% else %>
<%= toggle_link (image_tag "/images/add.png"), 'put-tag-form', {:focus => 'name'} %>
<div id="tags_show">
<%= render :partial => "layouts/tag_name",:locals => {:obj => obj,:non_list_all => false ,:object_flag => object_flag} %>
@ -17,4 +36,5 @@
<%= link_to_function l(:button_cancel), '$("#put-tag-form").hide();'%>
<% end %>
</div>
</div>
<% end %>

View File

@ -19,9 +19,8 @@
<div id="wrapper">
<div id="wrapper2">
<div id="wrapper3">
<%=render :partial => 'layouts/base_header'%>
<%= render :partial => 'layouts/base_header'%>
<div id="main" class="">
<div id="sidebar">
<div class="main_context">
@ -29,9 +28,7 @@
<div class="inf_user_image">
<table>
<tr>
<td align="left" valign="middle">
<%= link_to image_tag(url_to_avatar(@user), :class => "avatar"), user_path(@user), :class => "avatar" %>
</td>
<td align="left" valign="middle"> <%= link_to image_tag(url_to_avatar(@user), :class => "avatar"), user_path(@user), :class => "avatar" %> </td>
<td>
<table>
<tr>
@ -59,20 +56,9 @@
关注 (<%= link_to @bid.watcher_users.count, home_path %>) &nbsp;应标项目 (<%= link_to @bid.biding_projects.count, home_path %>)å馈(<%= @bid.commit%>)
</div>
</div>
<div class="inf_user_context">
<table style="font-family:微软雅黑">
<tr>
<th>标签云:</th>
</tr>
<tr>
<td><!-- added by william -for tag -->
<div id="tags">
<%= render :partial => 'layouts/tag', :locals => {:obj => @bid,:object_flag => "4"}%>
</div></td>
</tr>
</table>
</div>
<!-- added by william -for tag -->
<%= render :partial => 'layouts/tag', :locals => {:obj => @bid,:object_flag => "4"}%>
<div class="user_fans">
<div class="font_title_left">
<strong>关注</strong>
@ -81,11 +67,9 @@
<div class="left_wf">
<table>
<tr>
<td style="padding-top: 5px">
<% for user in @bid.watcher_users%>
<%= link_to image_tag(url_to_avatar(user), :class => "avatar"), user_path(user), :class => "avatar" %>
<% end%>
</td>
<td style="padding-top: 5px"> <% for user in @bid.watcher_users%>
<%= link_to image_tag(url_to_avatar(user), :class => "avatar"), user_path(user), :class => "avatar" %>
<% end%> </td>
<tr>
<tr>
<td align="right"><%= link_to "显示所有关注",home_path %>(<%= link_to @bid.watcher_users.count, home_path %>)</td>

View File

@ -8,7 +8,6 @@
</li>
<% end %>
<% end %>
<% if users_results.size > 0 %>
<hr />
<h3>Users:</h3>

View File

@ -1,4 +1,16 @@
<div class="splitcontentleft">
<style type="text/css">
.tags_left{
width: 30%;
float:left;
}
.tags_right{
padding-top:18px;
width: 68%;
float:right;
}
</style>
<div class="tags_left">
<ul>
<li>
Selected Tags
@ -15,7 +27,7 @@
</ul>
</div>
<div class="splitcontentright">
<div class="tags_right">
<h2>Search Results</h2>
<div id="filter-menu" align="right">
<%= link_to "Issue",:action => "index"%>(<%= @issues_tags_num %>)|

View File

@ -1,4 +1,14 @@
$('#tags_show').html('<%= escape_javascript(render :partial => 'layouts/tag_name',:locals => {:obj => @obj,:non_list_all => false,:object_flag => @obj_flag}) %>');
<% if @obj_flag == '3'%>
$('#tags_show_issue').html('<%= escape_javascript(render :partial => 'layouts/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',
:locals => {:obj => @obj,:non_list_all => false,:object_flag => @obj_flag}) %>');
$('#put-tag-form').hide();
$('#name').val("");
<% end %>