Nuevo plugin Redmine Questions 0.0.7 light
This commit is contained in:
parent
c5b56fffec
commit
7de6fb4627
51 changed files with 2162 additions and 0 deletions
|
@ -0,0 +1,23 @@
|
|||
<script type="text/javascript">
|
||||
$(function(){
|
||||
<% available_tags = RedmineCrm::Tag.joins(:taggings).joins("INNER JOIN messages ON taggings.taggable_id = messages.id AND taggings.taggable_type = 'Message'").joins("INNER JOIN boards ON messages.board_id = boards.id").where(["boards.project_id = ?", @project]) %>
|
||||
var currentTags = ['<%= available_tags.map(&:name).join("\',\'").html_safe %>'];
|
||||
|
||||
$('#allowSpacesTags').tagit({
|
||||
availableTags: currentTags,
|
||||
allowSpaces: true,
|
||||
caseSensitive: false,
|
||||
removeConfirmation: true
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<span class="message-tags-edit">
|
||||
<%= text_field_tag 'message[tag_list]', "#{@message.tags.map(&:name).join(',').html_safe}", :size => 10, :class => 'hol', :id => "allowSpacesTags" %>
|
||||
</span>
|
||||
|
||||
|
||||
<% content_for :header_tags do %>
|
||||
<%= javascript_include_tag :"tag-it", :plugin => 'redmine_questions' %>
|
||||
<%= stylesheet_link_tag :"jquery.tagit.css", :plugin => 'redmine_questions' %>
|
||||
<% end %>
|
|
@ -0,0 +1,68 @@
|
|||
<h2><%= l(:label_questions) %></h2>
|
||||
|
||||
<div class="filters">
|
||||
<%= form_tag({:controller => "questions", :action => "topics"}, :method => :get, :id => "query_form") do %>
|
||||
<%= hidden_field_tag('project_id', @project.to_param) if @project %>
|
||||
<%= text_field_tag(:topic_search, params[:topic_search] , :autocomplete => "off", :class => "questions-search", :placeholder => l(:label_questions_search) ) %>
|
||||
<%= javascript_tag "observeSearchfield('topic_search', 'forum_list', '#{ escape_javascript(autocomplete_for_topic_questions_path(:project_id => @project, :board_id => @board)) }')" %>
|
||||
|
||||
<% end %>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="forum_list">
|
||||
<% previous_group = false %>
|
||||
<% boards = @project ? @boards : @boards.select{|b| b.topics_count > 0} %>
|
||||
<% if @project %>
|
||||
<ul>
|
||||
<% end %>
|
||||
<% boards.each do |board| %>
|
||||
<% cache(Message.last.updated_on.to_s + board.id.to_s) do %>
|
||||
<% if @project.blank? && (group = board.project) != previous_group %>
|
||||
<% reset_cycle %>
|
||||
</ul>
|
||||
<div class="project-forums">
|
||||
<h3><%= group.blank? ? 'None' : group.name %><%= link_to " \xc2\xbb", project_boards_path(:project_id => group) %></h3>
|
||||
</div>
|
||||
<ul>
|
||||
<% previous_group = group %>
|
||||
<% end %>
|
||||
|
||||
<li class="<%= cycle('odd', 'even') %> ">
|
||||
<h3>
|
||||
<%= link_to h(board.name), {:controller => "boards", :action => 'show', :id => board, :project_id => board.project_id}, :class => "board" %>
|
||||
<span class="topic-count"><%= "(#{board.topics.count})" %></span>
|
||||
</h3>
|
||||
<div class="topic-list">
|
||||
<% board.topics.sort_by{|m| [m.sticky, m.updated_on] }.reverse.first(5).each do |topic| %>
|
||||
<div class="list-item">
|
||||
<span class="topic-subject">
|
||||
<%= link_to h(topic.subject), { :controller => 'messages', :action => 'show', :board_id => board, :id => topic } %>
|
||||
</span><br>
|
||||
<span class="last-author">
|
||||
<% last_update = [topic.last_reply ? topic.last_reply.updated_on : topic.created_on, topic.updated_on].max %>
|
||||
<% last_author = (topic.last_reply && topic.last_reply.updated_on) ? topic.last_reply.author : topic.author %>
|
||||
|
||||
<%= authoring last_update, last_author, :label => :label_updated_time_by %><br />
|
||||
|
||||
</span>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<% content_for :sidebar do %>
|
||||
<%= render :partial => "questions/notice" %>
|
||||
<%= render :partial => "questions/tag_cloud" %>
|
||||
<%= render :partial => "questions/latest_topics" %>
|
||||
<%= render :partial => "questions/voted_topics" %>
|
||||
<% end %>
|
||||
|
||||
<% content_for :header_tags do %>
|
||||
<%= javascript_include_tag :questions, :plugin => 'redmine_questions' %>
|
||||
<% end %>
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
<%
|
||||
scope = Message.where({})
|
||||
scope = scope.where("#{Message.table_name}.parent_id IS NULL")
|
||||
scope = scope.where(["#{Board.table_name}.project_id = ?", @project.id]) if @project
|
||||
@latest_topics = scope.visible.includes(:board).order("#{Message.table_name}.created_on DESC").limit(5)
|
||||
%>
|
||||
<h3><%= l(:label_questions_latest_messages) %></h3>
|
||||
<ul class="related-topics">
|
||||
<% @latest_topics.each do |topic| %>
|
||||
<li class="related-topic">
|
||||
<%= link_to h(topic.subject), { :controller => 'messages', :action => 'show', :board_id => topic.board, :id => topic } %>
|
||||
</li>
|
||||
<% end unless @latest_topics.blank? %>
|
||||
</ul>
|
|
@ -0,0 +1,3 @@
|
|||
<% unless Setting.plugin_redmine_questions[:sidebar_message].blank? %>
|
||||
<div class="wiki"><%= textilizable(Setting.plugin_redmine_questions[:sidebar_message]) %></div>
|
||||
<% end %>
|
|
@ -0,0 +1,35 @@
|
|||
<%
|
||||
limit = 30
|
||||
|
||||
scope = RedmineCrm::Tag.where({})
|
||||
scope = scope.where("#{Project.table_name}.id = ?", @project) if @project
|
||||
scope = scope.where(Project.allowed_to_condition(User.current, :view_messages))
|
||||
|
||||
|
||||
join = []
|
||||
join << "JOIN #{RedmineCrm::Tagging.table_name} ON #{RedmineCrm::Tagging.table_name}.tag_id = #{RedmineCrm::Tag.table_name}.id "
|
||||
join << "JOIN #{Message.table_name} ON #{Message.table_name}.id = #{RedmineCrm::Tagging.table_name}.taggable_id AND #{RedmineCrm::Tagging.table_name}.taggable_type = '#{Message.name}' "
|
||||
join << "JOIN #{Board.table_name} ON #{Board.table_name}.id = #{Message.table_name}.board_id"
|
||||
join << "JOIN #{Project.table_name} ON #{Project.table_name}.id = #{Board.table_name}.project_id"
|
||||
|
||||
group_fields = ""
|
||||
group_fields << ", #{RedmineCrm::Tag.table_name}.created_at" if RedmineCrm::Tag.respond_to?(:created_at)
|
||||
group_fields << ", #{RedmineCrm::Tag.table_name}.updated_at" if RedmineCrm::Tag.respond_to?(:updated_at)
|
||||
|
||||
scope = scope.joins(join.join(' '))
|
||||
scope = scope.select("#{RedmineCrm::Tag.table_name}.*, COUNT(DISTINCT #{RedmineCrm::Tagging.table_name}.taggable_id) AS count")
|
||||
scope = scope.group("#{RedmineCrm::Tag.table_name}.id, #{RedmineCrm::Tag.table_name}.name #{group_fields} HAVING COUNT(*) > 0")
|
||||
scope = scope.order("#{RedmineCrm::Tag.table_name}.name")
|
||||
scope = scope.limit(limit) if limit
|
||||
@available_tags = scope
|
||||
%>
|
||||
|
||||
<h3><%= l(:label_questions_tags) %></h3>
|
||||
<ul class="questions-tags">
|
||||
<% @available_tags.each do |tag| %>
|
||||
<li>
|
||||
<%= link_to tag, {:controller => "questions", :action => "topics", :project_id => @project, :tag => tag.name} %>
|
||||
<span class="count"><%= tag.count %></span>
|
||||
</li>
|
||||
<% end if @available_tags %>
|
||||
</ul>
|
|
@ -0,0 +1,16 @@
|
|||
<%
|
||||
scope = Message.scoped({})
|
||||
scope = scope.where("#{Message.table_name}.parent_id IS NULL")
|
||||
scope = scope.where(["#{Board.table_name}.project_id = ?", @project.id]) if @project
|
||||
scope = scope.where(["#{Message.table_name}.board_id = ?", @board.id]) if @board
|
||||
scope = scope.where(:sticky => true)
|
||||
@sticky_topics = scope.visible.includes(:board).order("#{Message.table_name}.cached_votes_up DESC").limit(10)
|
||||
%>
|
||||
<h3><%= l(:label_questions_most_voted) %></h3>
|
||||
<ul class="related-topics">
|
||||
<% @sticky_topics.each do |topic| %>
|
||||
<li class="related-topic">
|
||||
<%= link_to h(topic.subject), { :controller => 'messages', :action => 'show', :board_id => topic.board, :id => topic } %>
|
||||
</li>
|
||||
<% end unless @sticky_topics.blank? %>
|
||||
</ul>
|
|
@ -0,0 +1,30 @@
|
|||
<% if @topics && @topics.any? %>
|
||||
<% unless params[:tag].blank? %>
|
||||
<div class="title-bar">
|
||||
<h4><%= l(:label_questions_tagged_by, :count => @topics.size, :tag => params[:tag]) %></h4>
|
||||
</div>
|
||||
<% end %>
|
||||
<div id="topics_container">
|
||||
<% @topics.each do |topic| %>
|
||||
<div class="topic">
|
||||
<h3 class="subject">
|
||||
<%= link_to h(topic.subject), { :controller => 'messages', :action => 'show', :board_id => topic.board, :id => topic } %>
|
||||
</h3>
|
||||
<p><%= truncate(topic.content.gsub(/\r\n/, ' ').strip , :length => 100) %></p>
|
||||
<ul class="meta">
|
||||
<li class="votes icon icon-vote"><%= l(:label_questions_votes, :count => topic.count_votes_up - topic.count_votes_down ) %></li>
|
||||
<li class="answers icon icon-comment"><%= l(:label_questions_answers, :count => topic.replies_count) %></li>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
</div>
|
||||
<% if @topic_pages %>
|
||||
<% params[:controller] = 'questions'
|
||||
params[:action] = 'topics'
|
||||
%>
|
||||
<p class="pagination"><%= pagination_links_full @topic_pages, @topic_count %></p>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<p class="nodata"><%= l(:label_no_data) %></p>
|
||||
<% end %>
|
|
@ -0,0 +1,16 @@
|
|||
<%
|
||||
scope = Message.where({})
|
||||
scope = scope.where("#{Message.table_name}.parent_id IS NULL")
|
||||
scope = scope.where(["#{Board.table_name}.project_id = ?", @project.id]) if @project
|
||||
scope = scope.where(["#{Message.table_name}.board_id = ?", @board.id]) if @board
|
||||
scope = scope.where("#{Message.table_name}.cached_votes_up > 0")
|
||||
@most_voted_topics = scope.visible.includes(:board).order("#{Message.table_name}.cached_votes_up DESC").limit(5)
|
||||
%>
|
||||
<h3><%= l(:label_questions_most_voted) %></h3>
|
||||
<ul class="related-topics">
|
||||
<% @most_voted_topics.each do |topic| %>
|
||||
<li class="related-topic">
|
||||
<%= link_to h(topic.subject), { :controller => 'messages', :action => 'show', :board_id => topic.board, :id => topic } %>
|
||||
</li>
|
||||
<% end unless @most_voted_topics.blank? %>
|
||||
</ul>
|
|
@ -0,0 +1 @@
|
|||
<%= render :partial => "questions/topic_list" %>
|
|
@ -0,0 +1,9 @@
|
|||
<h2><%= l(:label_message_new) %></h2>
|
||||
|
||||
<%= form_for @message, :url => {:controller => "messages", :action => 'new'}, :html => {:multipart => true, :id => 'message-form'} do |f| %>
|
||||
<%= render :partial => 'messages/form', :locals => {:f => f} %>
|
||||
<%= submit_tag l(:button_create) %>
|
||||
<%# preview_link({:controller => 'messages', :action => 'preview', :board_id => @board}, 'message-form') %>
|
||||
<% end %>
|
||||
|
||||
<div id="preview" class="wiki"></div>
|
|
@ -0,0 +1,31 @@
|
|||
|
||||
<% if @board %>
|
||||
<%= board_breadcrumb(@board) %>
|
||||
<div class="board details">
|
||||
<h2><%=h @board.name %></h2>
|
||||
<p class="subtitle"><%=h @board.description %></p>
|
||||
<% else %>
|
||||
<h2><%= l(:label_questions) %></h2>
|
||||
<% end %>
|
||||
|
||||
<div class="filters">
|
||||
<%= form_tag({:controller => "questions", :action => "topics"}, :method => :get, :id => "query_form") do %>
|
||||
<%= hidden_field_tag('project_id', @project.to_param) if @project %>
|
||||
<%= hidden_field_tag('board_id', @board.to_param) if @board %>
|
||||
<%= text_field_tag(:topic_search, params[:topic_search], :autocomplete => "off", :class => "questions-search", :placeholder => l(:label_questions_search) ) %>
|
||||
<%= javascript_tag "observeSearchfield('topic_search', 'topics_list', '#{ escape_javascript(autocomplete_for_topic_questions_path(:project_id => @project, :board_id => @board)) }')" %>
|
||||
|
||||
<% end %>
|
||||
|
||||
</div>
|
||||
<% if @board %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div id="topics_list" >
|
||||
<%= render :partial => "questions/topic_list" %>
|
||||
</div>
|
||||
|
||||
<% content_for :sidebar do %>
|
||||
<%= render :partial => "questions/latest_topics" %>
|
||||
<% end %>
|
Loading…
Add table
Add a link
Reference in a new issue