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,117 @@
|
|||
class QuestionsController < ApplicationController
|
||||
unloadable
|
||||
|
||||
before_filter :find_optional_project, :only => [:autocomplete_for_topic, :topics]
|
||||
before_filter :find_optional_board, :only => [:autocomplete_for_topic, :topics]
|
||||
before_filter :find_topic, :authorize, :only => :vote
|
||||
before_filter :find_topics, :only => [:topics, :autocomplete_for_topic]
|
||||
|
||||
helper :questions
|
||||
if Redmine::VERSION.to_s > '2.1'
|
||||
helper :boards
|
||||
end
|
||||
include QuestionsHelper
|
||||
|
||||
def index
|
||||
@boards = Board.visible.includes(:last_message => :author).includes(:messages).order(:project_id)
|
||||
# show the board if there is only one
|
||||
if @boards.size == 1
|
||||
@board = @boards.first
|
||||
redirect_to project_board_url(@board, :project_id => @board.project)
|
||||
else
|
||||
render "boards/index"
|
||||
end
|
||||
end
|
||||
|
||||
def topics
|
||||
end
|
||||
|
||||
def vote
|
||||
User.current.voted_for?(@topic) ? @topic.dislike(User.current.becomes(Principal)) : @topic.like(User.current.becomes(Principal))
|
||||
respond_to do |format|
|
||||
format.html { redirect_to_referer_or {render :text => (watching ? 'Vote added.' : 'Vote removed.'), :layout => true}}
|
||||
end
|
||||
end
|
||||
|
||||
def autocomplete_for_topic
|
||||
render :layout => false
|
||||
end
|
||||
|
||||
def convert_issue
|
||||
issue = Issue.visible.find(params[:issue_id])
|
||||
board = Board.visible.find(params[:board_id])
|
||||
message = Message.new
|
||||
message.author = issue.author
|
||||
message.created_on = issue.created_on
|
||||
message.board = board
|
||||
message.subject = issue.subject
|
||||
message.content = issue.description.blank? ? issue.subject : issue.description
|
||||
message.watchers = issue.watchers
|
||||
message.add_watcher(issue.author)
|
||||
message.attachments = issue.attachments
|
||||
issue.journals.select{|j| !j.notes.blank?}.each do |journal|
|
||||
reply = Message.new
|
||||
reply.author = journal.user
|
||||
reply.created_on = journal.created_on
|
||||
reply.subject = "Re: #{message.subject}"
|
||||
reply.content = journal.notes
|
||||
reply.board = board
|
||||
message.children << reply
|
||||
end
|
||||
if message.save
|
||||
issue.destroy if params[:destroy]
|
||||
redirect_to board_message_path(board, message)
|
||||
else
|
||||
redirect_back_or_default({:controller => 'issues', :action => 'show', :id => issue})
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def find_topics
|
||||
seach = params[:q] || params[:topic_search]
|
||||
|
||||
columns = ["subject", "content"]
|
||||
tokens = seach.to_s.scan(%r{((\s|^)"[\s\w]+"(\s|$)|\S+)}).collect{|m| m.first.gsub(%r{(^\s*"\s*|\s*"\s*$)}, '')}.uniq.select {|w| w.length > 1 }
|
||||
tokens = [] << tokens unless tokens.is_a?(Array)
|
||||
token_clauses = columns.collect {|column| "(LOWER(#{column}) LIKE ?)"}
|
||||
sql = (['(' + token_clauses.join(' OR ') + ')'] * tokens.size).join(' AND ')
|
||||
find_options = [sql, * (tokens.collect {|w| "%#{w.downcase}%"} * token_clauses.size).sort]
|
||||
|
||||
scope = Message.joins(:board).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(find_options) unless tokens.blank?
|
||||
scope = scope.visible.includes(:board).order("#{Message.table_name}.updated_on DESC")
|
||||
|
||||
@topic_count = scope.count
|
||||
@limit = per_page_option
|
||||
@topic_pages = Paginator.new(self, @topic_count, @limit, params[:page])
|
||||
@offset = @topic_pages.current.offset
|
||||
scope = scope.limit(@limit).offset(@offset)
|
||||
scope = scope.tagged_with(params[:tag]) unless params[:tag].blank?
|
||||
@topics = scope
|
||||
end
|
||||
|
||||
def find_topic
|
||||
@topic = Message.visible.find(params[:id]) unless params[:id].blank?
|
||||
@board = @topic.board
|
||||
@project = @board.project
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
end
|
||||
|
||||
def find_optional_board
|
||||
@board = Board.visible.find(params[:board_id]) unless params[:board_id].blank?
|
||||
@project = @board.project if @board
|
||||
allowed = User.current.allowed_to?({:controller => params[:controller], :action => params[:action]}, @project, :global => true)
|
||||
allowed ? true : deny_access
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
15
plugins/redmine_questions/app/helpers/questions_helper.rb
Normal file
15
plugins/redmine_questions/app/helpers/questions_helper.rb
Normal file
|
@ -0,0 +1,15 @@
|
|||
module QuestionsHelper
|
||||
def vote_tag(object, user, options={})
|
||||
content_tag("span", vote_link(object, user))
|
||||
end
|
||||
|
||||
def vote_link(object, user)
|
||||
return '' unless user && user.logged? && user.respond_to?('voted_for?')
|
||||
voted = user.voted_for?(object)
|
||||
url = {:controller => 'questions', :action => 'vote', :id => object}
|
||||
link_to((voted ? l(:button_questions_unvote) : l(:button_questions_vote)), url,
|
||||
:class => (voted ? 'icon icon-vote' : 'icon icon-unvote'))
|
||||
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1 @@
|
|||
<%= render :partial => "questions/forums" %>
|
64
plugins/redmine_questions/app/views/boards/show.html.erb
Normal file
64
plugins/redmine_questions/app/views/boards/show.html.erb
Normal file
|
@ -0,0 +1,64 @@
|
|||
<%= board_breadcrumb(@board) %>
|
||||
|
||||
<div class="board details">
|
||||
<div class="contextual">
|
||||
<%= link_to_if_authorized l(:label_message_new),
|
||||
{:controller => 'messages', :action => 'new', :board_id => @board},
|
||||
:class => 'icon icon-add',
|
||||
:onclick => 'showAndScrollTo("add-message", "message_subject"); return false;' %>
|
||||
<%= content_tag('span', watcher_link(@board, User.current), :id => 'watcher') %>
|
||||
</div>
|
||||
|
||||
<div id="add-message" style="display:none;">
|
||||
<% if authorize_for('messages', 'new') %>
|
||||
<h2><%= link_to h(@board.name), :controller => 'boards', :action => 'show', :project_id => @project, :id => @board %> » <%= l(:label_message_new) %></h2>
|
||||
<%= form_for @message, :url => {:controller => 'messages', :action => 'new', :board_id => @board}, :html => {:multipart => true, :id => 'message-form'} do |f| %>
|
||||
<%= render :partial => 'messages/form', :locals => {:f => f} %>
|
||||
<p><%= submit_tag l(:button_create) %>
|
||||
<%= preview_link({:controller => 'messages', :action => 'preview', :board_id => @board}, 'message-form') %> |
|
||||
<%= link_to l(:button_cancel), "#", :onclick => '$("#add-message").hide(); return false;' %></p>
|
||||
<% end %>
|
||||
<div id="preview" class="wiki"></div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<h2><%=h @board.name %></h2>
|
||||
<p class="subtitle"><%=h @board.description %></p>
|
||||
|
||||
<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 %>
|
||||
<% no_filters = true %>
|
||||
|
||||
<%= 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>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="topics_list" >
|
||||
<%= render :partial => "questions/topic_list" %>
|
||||
</div>
|
||||
|
||||
<% other_formats_links do |f| %>
|
||||
<%= f.link_to 'Atom', :url => {:key => User.current.rss_key} %>
|
||||
<% end %>
|
||||
|
||||
|
||||
<% content_for :sidebar do %>
|
||||
<%= render :partial => "questions/notice" %>
|
||||
<%= render :partial => "questions/tag_cloud" %>
|
||||
<%= render :partial => "questions/voted_topics" %>
|
||||
<% end %>
|
||||
|
||||
<% html_title @board.name %>
|
||||
|
||||
<% content_for :header_tags do %>
|
||||
<%= auto_discovery_link_tag(:atom, {:format => 'atom', :key => User.current.rss_key}, :title => "#{@project}: #{@board}") %>
|
||||
<%= javascript_include_tag :questions, :plugin => 'redmine_questions' %>
|
||||
<% end %>
|
39
plugins/redmine_questions/app/views/messages/_form.html.erb
Normal file
39
plugins/redmine_questions/app/views/messages/_form.html.erb
Normal file
|
@ -0,0 +1,39 @@
|
|||
<%= error_messages_for 'message' %>
|
||||
<% replying ||= false %>
|
||||
|
||||
<div class="box">
|
||||
<!--[form:message]-->
|
||||
<p style=<%= "display:none;" if replying %> ><label for="message_subject"><%= l(:field_subject) %></label><br />
|
||||
<%= f.text_field :subject, :style => "width: 80%;", :id => "message_subject" %>
|
||||
<% unless replying %>
|
||||
|
||||
<% if @message.safe_attribute? 'sticky' %>
|
||||
<%= f.check_box :sticky %> <%= label_tag 'message_sticky', l(:label_board_sticky) %>
|
||||
<% end %>
|
||||
<% if @message.safe_attribute? 'locked' %>
|
||||
<%= f.check_box :locked %> <%= label_tag 'message_locked', l(:label_board_locked) %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</p>
|
||||
|
||||
<% if !replying && !@message.new_record? && @message.safe_attribute?('board_id') %>
|
||||
<p><label><%= l(:label_board) %></label><br />
|
||||
<%= f.select :board_id, boards_options_for_select(@message.project.boards) %></p>
|
||||
<% end %>
|
||||
|
||||
<p>
|
||||
<%= label_tag "message_content", l(:description_message_content), :class => "hidden-for-sighted" %>
|
||||
<%= f.text_area :content, :cols => 80, :rows => 15, :class => 'wiki-edit', :id => 'message_content' %></p>
|
||||
<%= wikitoolbar_for 'message_content' %>
|
||||
<!--[eoform:message]-->
|
||||
|
||||
<% if !replying && @message.safe_attribute?('tag_list') %>
|
||||
<p>
|
||||
<label for="message_tag_list"><%= l(:field_questions_tags) %></label><br />
|
||||
<%= render :partial => 'questions/form_tags' %>
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
<p><%= l(:label_attachment_plural) %><br />
|
||||
<%= render :partial => 'attachments/form', :locals => {:container => @message} %></p>
|
||||
</div>
|
18
plugins/redmine_questions/app/views/messages/edit.html.erb
Normal file
18
plugins/redmine_questions/app/views/messages/edit.html.erb
Normal file
|
@ -0,0 +1,18 @@
|
|||
<%= board_breadcrumb(@message) %>
|
||||
|
||||
<h2><%= avatar(@topic.author, :size => "24") %><%=h @topic.subject %></h2>
|
||||
|
||||
<%= form_for @message, {
|
||||
:as => :message,
|
||||
:url => {:action => 'edit'},
|
||||
:html => {:multipart => true,
|
||||
:id => 'message-form',
|
||||
:method => :post}
|
||||
} do |f| %>
|
||||
<%= render :partial => 'form',
|
||||
:locals => {:f => f, :replying => !@message.parent.nil?} %>
|
||||
<%= submit_tag l(:button_save) %>
|
||||
<%= preview_link({:controller => 'messages', :action => 'preview', :board_id => @board, :id => @message}, 'message-form') %>
|
||||
<% end %>
|
||||
<div id="preview" class="wiki"></div>
|
||||
|
144
plugins/redmine_questions/app/views/messages/show.html.erb
Normal file
144
plugins/redmine_questions/app/views/messages/show.html.erb
Normal file
|
@ -0,0 +1,144 @@
|
|||
<%= board_breadcrumb(@message) %>
|
||||
|
||||
<div class="contextual">
|
||||
<%= content_tag('span', watcher_link(@topic, User.current), :id => 'watcher') %>
|
||||
<% voted = User.current.voted_for?(@topic) %>
|
||||
<%= link_to(
|
||||
voted ? l(:button_questions_unvote) : l(:button_questions_vote),
|
||||
{:controller => 'questions', :action => 'vote', :id => @topic},
|
||||
:class => 'icon ' + (voted ? 'icon-vote' : 'icon-unvote')
|
||||
) if User.current.allowed_to?(:vote_messages, @project) %>
|
||||
|
||||
<%= link_to(
|
||||
l(:button_quote),
|
||||
{:action => 'quote', :id => @topic},
|
||||
:remote => true,
|
||||
:method => 'get',
|
||||
:class => 'icon icon-comment',
|
||||
:remote => true) if !@topic.locked? && authorize_for('messages', 'reply') %>
|
||||
<%= link_to(
|
||||
l(:button_edit),
|
||||
{:action => 'edit', :id => @topic},
|
||||
:class => 'icon icon-edit'
|
||||
) if @message.editable_by?(User.current) %>
|
||||
<%= link_to(
|
||||
l(:button_delete),
|
||||
{:action => 'destroy', :id => @topic},
|
||||
:method => :post,
|
||||
:data => {:confirm => l(:text_are_you_sure)},
|
||||
:class => 'icon icon-del'
|
||||
) if @message.destroyable_by?(User.current) %>
|
||||
</div>
|
||||
|
||||
<div class="message details">
|
||||
<h2><%=h @topic.subject %></h2>
|
||||
<%= avatar(@topic.author, :size => "32") %>
|
||||
<p class="author"><%= link_to_user @topic.author %><br>
|
||||
<%= l(:label_questions_added_time, :value => time_tag(@topic.created_on)).html_safe %>
|
||||
</p>
|
||||
<div class="wiki">
|
||||
<%= textilizable(@topic, :content) %>
|
||||
</div>
|
||||
<%= link_to_attachments @topic, :author => false %>
|
||||
|
||||
</div>
|
||||
<br />
|
||||
|
||||
<% unless @replies.empty? %>
|
||||
<h3 class="comments"><%= l(:label_reply_plural) %> (<%= @reply_count %>)</h3>
|
||||
<% @replies.each do |message| %>
|
||||
<div class="message reply" id="<%= "message-#{message.id}" %>">
|
||||
<div class="contextual">
|
||||
<% liked = User.current.voted_for?(message) %>
|
||||
<%= link_to(
|
||||
message.count_votes_up > 0 ? "(#{message.count_votes_up})" : "",
|
||||
{:controller => 'questions', :action => 'vote', :id => message},
|
||||
:class => 'vote icon ' + (liked ? 'icon-vote' : 'icon-unvote')
|
||||
) if true || User.current.allowed_to?(:vote_messages, @project) %>
|
||||
<%= link_to(
|
||||
image_tag('comment.png'),
|
||||
{:action => 'quote', :id => message},
|
||||
:remote => true,
|
||||
:method => 'get',
|
||||
:title => l(:button_quote)) if !@topic.locked? && authorize_for('messages', 'reply') %>
|
||||
<%= link_to(
|
||||
image_tag('edit.png'),
|
||||
{:action => 'edit', :id => message},
|
||||
:title => l(:button_edit)
|
||||
) if message.editable_by?(User.current) %>
|
||||
<%= link_to(
|
||||
image_tag('delete.png'),
|
||||
{:action => 'destroy', :id => message},
|
||||
:method => :post,
|
||||
:data => {:confirm => l(:text_are_you_sure)},
|
||||
:title => l(:button_delete)
|
||||
) if message.destroyable_by?(User.current) %>
|
||||
</div>
|
||||
<% if Setting.gravatar_enabled? %>
|
||||
<div class="avatar">
|
||||
<%= message_avatar = avatar(message.author, :size => "32") %>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="reply-details <%= 'use-avatar' unless message_avatar.blank? %>">
|
||||
<h4 class="author"><%= authoring message.created_on, message.author %></h4>
|
||||
<div class="wiki"><%= textilizable message, :content, :attachments => message.attachments %></div>
|
||||
<%= link_to_attachments message, :author => false %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<p class="pagination"><%= pagination_links_full @reply_pages, @reply_count, :per_page_links => false %></p>
|
||||
<% end %>
|
||||
|
||||
<% if !@topic.locked? && authorize_for('messages', 'reply') %>
|
||||
<p><%= toggle_link l(:button_reply), "reply", :focus => 'message_content' %></p>
|
||||
<div id="reply" style="display:none;">
|
||||
<%= form_for @reply, :as => :reply, :url => {:action => 'reply', :id => @topic}, :html => {:multipart => true, :id => 'message-form'} do |f| %>
|
||||
<%= render :partial => 'form', :locals => {:f => f, :replying => true} %>
|
||||
<%= submit_tag l(:button_submit) %>
|
||||
<%= preview_link({:controller => 'messages', :action => 'preview', :board_id => @board}, 'message-form') %>
|
||||
<% end %>
|
||||
<div id="preview" class="wiki"></div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
|
||||
<% content_for :sidebar do %>
|
||||
<h3><%= l(:label_questions_message) %></h3>
|
||||
<ul class="question-meta">
|
||||
<li class="votes icon icon-vote">
|
||||
<%= l(:label_questions_votes, :count => @topic.count_votes_up - @topic.count_votes_down ) %>
|
||||
</li>
|
||||
<li class="views icon icon-view">
|
||||
<%= l(:label_questions_views, :count => @topic.view_count ) %>
|
||||
</li>
|
||||
<% unless @topic.tags.blank? %>
|
||||
<li class="tags icon icon-tag">
|
||||
<%=
|
||||
@topic.tags.collect do |tag|
|
||||
link_to tag, {:controller => "questions", :action => "topics", :project_id => @project, :tag => tag.name}
|
||||
end.join(', ').html_safe
|
||||
%>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
|
||||
<h3><%= l(:label_questions_related_messages) %></h3>
|
||||
<ul class="related-topics">
|
||||
<%# Board.all.map(&:topics).flatten.first(5).each do |topic| %>
|
||||
<% tokens = @topic.subject.strip.scan(%r{((\s|^)"[\s\w]+"(\s|$)|\S+)}).collect {|m| m.first.gsub(%r{(^\s*"\s*|\s*"\s*$)}, '')} || "" %>
|
||||
<% if ActiveRecord::VERSION::MAJOR >= 4 %>
|
||||
<% related_topics = Message.where(tokens.map{ |t| "subject LIKE '%#{t}%'" }.join(' OR ')).to_a.compact if tokens %>
|
||||
<% else %>
|
||||
<% related_topics = Message.search(tokens, @project, :limit => 5)[0].select{|m| m != @topic && m.parent_id == nil }.compact if tokens %>
|
||||
<% end %>
|
||||
<% related_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 if related_topics %>
|
||||
</ul>
|
||||
|
||||
|
||||
<% end %>
|
||||
|
||||
<% html_title @topic.subject %>
|
|
@ -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 %>
|
|
@ -0,0 +1,3 @@
|
|||
<p><label for="settings_sidebar_message"><%= l(:label_questions_sidebar_message) %></label>
|
||||
<%= text_area_tag 'settings[sidebar_message]', @settings[:sidebar_message], :class => 'wiki-edit', :rows => 5 %>
|
||||
</p>
|
Loading…
Add table
Add a link
Reference in a new issue