Actualizado plugin Redmine Questions 1.0.0 light

This commit is contained in:
Manuel Cillero 2019-03-21 17:52:05 +01:00
parent 27e60f8ec1
commit 5d7889f1c9
140 changed files with 5342 additions and 1430 deletions

View file

@ -0,0 +1,43 @@
<%= error_messages_for @question_item %>
<%= fields_for :question, @question_item do |f| %>
<div class="box">
<!--[form:message]-->
<p><label for="message_subject"><%= l(:field_subject) %></label><br />
<%= f.text_field :subject, :id => "question_subject", :size => 120%>
</p>
<p><label><%= l(:label_questions_section) %></label><br />
<%= f.select :section_id, options_from_collection_for_select(QuestionsSection.where(:project_id => @project),:id, :name, f.object.section_id), :style => "width: 80%;", :required => true %>
<%= javascript_tag do %>
$('#question_section_id').change(function() {
$.ajax({
url: '<%= escape_javascript update_form_questions_path(:id => @question_item, :format => 'js', :project_id => @project) %>',
type: 'put',
data: $('#question_form').serialize()
});
});
<% end %>
<%= link_to(image_tag('add.png', :style => 'vertical-align: middle;'),
(@project ? new_project_questions_section_url(:project_id => @project) : new_questions_section_url ),
:remote => true,
:method => 'get',
:title => l(:label_questions_section_new),
:class => "add_section",
:tabindex => 200) if User.current.allowed_to?(:manage_sections, @project) %>
</p>
<% if @question_item.is_idea? %>
<p><label><%= l(:field_status) %></label><br />
<%= f.select :status_id, options_from_collection_for_select(QuestionsStatus.sorted,:id, :name, @question_item.status_id ), :include_blank => true %>
</p>
<% end %>
<p>
<%= f.text_area :content, :cols => 80, :rows => 15, :class => 'wiki-edit', :id => 'question_content', :label => l(:label_questions_message) %>
</p>
<%= wikitoolbar_for 'question_content' %>
<!--[eoform:question]-->
<p>
<%= l(:label_attachment_plural) %><br />
<%= render :partial => 'attachments/form', :locals => {:container => @question_item} %>
</p>
</div>
<% end %>

View file

@ -1,23 +0,0 @@
<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 %>

View file

@ -1,68 +0,0 @@
<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 %>

View file

@ -1,14 +1,8 @@
<%
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>
<% Question.visible.by_date.in_project(@project).limit(5).each do |question| %>
<li class="related-topic">
<%= link_to h(question.subject), { :controller => 'questions', :action => 'show', :id => question, :project_id => @project } %>
</li>
<% end %>
</ul>

View file

@ -1,3 +0,0 @@
<% unless Setting.plugin_redmine_questions[:sidebar_message].blank? %>
<div class="wiki"><%= textilizable(Setting.plugin_redmine_questions[:sidebar_message]) %></div>
<% end %>

View file

@ -0,0 +1,18 @@
<%
@popular_topics = Question.
visible.
in_project(@project).
in_section(@section).
positive.
by_views.
by_votes.
limit(5)
%>
<h3><%= l(:label_questions_most_popular) %></h3>
<ul class="related-topics">
<% @popular_topics.each do |question| %>
<li class="related-topic">
<%= link_to h(question.subject), { :controller => 'questions', :action => 'show', :section_id => question.section, :id => question } %>
</li>
<% end unless @popular_topics.blank? %>
</ul>

View file

@ -0,0 +1,65 @@
<div class="contextual">
<%= content_tag('span', watcher_link(@question_item, User.current), :id => 'watcher') %>
<%= link_to(l(:button_edit), edit_question_path(@question_item), :class => 'icon icon-edit' ) if @question_item.editable_by?(User.current)
%>
<%= link_to(l(:button_delete), question_path(@question_item), :method => :delete, :data => {:confirm => l(:text_are_you_sure)}, :class => 'icon icon-del') if @question_item.destroyable_by?(User.current)
%>
</div>
<h1 class="question-title"><%=h @question_item.subject %></h1>
<%= render :partial => 'question_item', :object => @question_item %>
<% if @question_item.section.allow_answering? %>
<div id="answers">
<% if @answers.any? %>
<h3><%= l(:label_questions_answer_plural) %> (<%= @answer_count %>)</h3>
<% @answers.each do |answer| %>
<%= render :partial => 'questions_answers/answer_item', :locals => { :question_item => answer } %>
<% end %>
<span class="pagination"><%= pagination_links_full @answer_pages, @answer_count %></span>
<% end %>
<% if @question_item.allow_answering? && User.current.allowed_to?(:add_answers, @project) %>
<h3><%= l(:label_questions_your_answer) %></h3>
<div id="reply" >
<%= form_for @answer, :as => :answer, :url => question_answers_path(@question_item), :html => {:multipart => true, :id => 'answer-form'} do |f| %>
<%= render :partial => 'questions_answers/form', :locals => {:f => f, :replying => true} %>
<%= submit_tag l(:button_submit) %>
<% end %>
<div id="preview" class="wiki"></div>
</div>
<% end %>
</div>
<% end %>
<% content_for :sidebar do %>
<h3><%= l(:label_questions_message) %></h3>
<ul class="question-meta">
<li class="views icon icon-view">
<%= l(:label_questions_views, :count => @question_item.views ) %>
</li>
</ul>
<% if @question_item.convertable_by?(User.current) && User.current.allowed_to?(:add_issues, @project) %>
<h3><%= l(:label_questions_actions) %></h3>
<ul class="action">
<li>
<%= link_to(
l(:button_questions_to_issue),
convert_to_issue_project_question_path(@project, @question_item)
)
%>
</li>
</ul>
<% end %>
<h3><%= l(:label_questions_related_questions) %></h3>
<ul class="related-topics">
<% Question.visible.related(@question_item, 5).each do |question| %>
<li class="related-topic">
<%= link_to h(question.subject), { :controller => 'questions', :action => 'show', :board_id => nil, :id => question } %>
</li>
<% end %>
</ul>
<% end %>

View file

@ -0,0 +1,23 @@
<div class="question<%= " votable" if question_item.allow_voting? %> div-table" id="question_<%= question_item.id %>">
<a href="#<%= question_item.id %>" class="wiki-anchor"></a>
<% if question_item.allow_voting? && User.current.allowed_to?(:vote_questions, @project) %>
<div class="vote">
<%= render :partial => 'questions_votes/question_item_vote', :locals => {:question_item => question_item} %>
</div>
<% end %>
<div class="question-container div-table-cell">
<%= avatar(question_item.author, :size => "32") %>
<p class="author">
<%= link_to_user question_item.author %><br>
<%= l(:label_questions_added_time, :value => time_tag(question_item.created_on)).html_safe %>
</p>
<div class="wiki">
<%= textilizable(question_item, :content) %>
</div>
<%= link_to_attachments question_item, :author => false %>
<%= render :partial => 'questions_comments/comments_container', :locals => { :question_item => question_item } %>
</div>
</div>

View file

@ -0,0 +1,47 @@
<% if @question_items && @question_items.any? %>
<% unless params[:tag].blank? %>
<div class="title-bar">
<h4><%= l(:label_questions_tagged_by, :count => @question_items.size, :tag => params[:tag]) %></h4>
</div>
<% end %>
<div id="forum_list">
<div id="topics_container" class="<%= " votable" if @section && @section.allow_voting? %>">
<% @question_items.each do |question| %>
<div class="topic">
<% if @section && @section.allow_voting? %>
<div class="topic-vote">
<span class="vote-score"><%= question.weighted_score %></span>
<label><%= l(:label_questions_x_votes, :count => question.weighted_score.abs) %></label>
<% if question.answered? %>
<div class="status-answered" title="Answered"></div>
<% end %>
</div>
<% end %>
<div class="topic-content">
<h3 class="subject">
<%= link_to h(question.subject), { :controller => 'questions', :action => 'show', :project_id => question.project, :id => question } %>
<%= question_status_tag(question.status) %>
</h3>
<p><%= truncate(Question.to_text(textilizable(question.content)), :length => 100) %></p>
<ul class="meta">
<% if question.allow_answering? %>
<li class="answers icon icon-comment"><%= l(:label_questions_answers, :count => question.answers_count) %></li>
<% end %>
<li class="views icon icon-view"><%= l(:label_questions_views, :count => question.views ) %></li>
</ul>
</div>
</div>
<% end %>
</div>
</div>
<% if @topic_pages %>
<% params[:controller] = 'questions'
params[:action] = 'topics'
%>
<p class="pagination"><%= pagination_links_full @topic_pages, @topic_count %></p>
<% end %>
<% else %>
<p style="display: inline-block"></p>
<p class="nodata"><%= l(:label_no_data) %></p>
<% end %>

View file

@ -1,35 +0,0 @@
<%
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>

View file

@ -1,16 +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)
# 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(:featured => true)
# @featured_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| %>
<% @featured_questions.each do |question| %>
<li class="related-topic">
<%= link_to h(topic.subject), { :controller => 'messages', :action => 'show', :board_id => topic.board, :id => topic } %>
<%= link_to h(question.subject), { :controller => 'questions', :action => 'show', :project_id => question.project, :id => question } %>
</li>
<% end unless @sticky_topics.blank? %>
</ul>
<% end unless @featured_topics.blank? %>
</ul>

View file

@ -1,8 +1,8 @@
<% 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>
<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| %>
@ -26,5 +26,5 @@
<p class="pagination"><%= pagination_links_full @topic_pages, @topic_count %></p>
<% end %>
<% else %>
<p class="nodata"><%= l(:label_no_data) %></p>
<% end %>
<p class="nodata"><%= l(:label_no_data) %></p>
<% end %>

View file

@ -1,16 +0,0 @@
<%
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>

View file

@ -0,0 +1 @@
<%= render :partial => "questions/question_list" %>

View file

@ -1 +0,0 @@
<%= render :partial => "questions/topic_list" %>

View file

@ -0,0 +1,15 @@
<h2><%= avatar(@question_item.author, :size => "24") %><%=h @question_item.subject %></h2>
<%= form_for @question_item, { :url => question_path(@question_item), :html => {:multipart => true,
:id => 'question_form', :method => :put}} do |f| %>
<%= back_url_hidden_field_tag %>
<div id="all_attributes">
<%= render :partial => 'form', :locals => {:f => f} %>
</div>
<%= submit_tag l(:button_save) %>
<%= preview_link({:controller => 'questions', :action => 'preview', :question_id => @question_item}, 'question_form') %>
<% end %>
<div id="preview" class="wiki"></div>

View file

@ -0,0 +1,35 @@
<% html_title l(:label_questions) %>
<div class="questions" >
<div class="contextual">
<%= link_to(l(:label_questions_new),
{:controller => 'questions', :action => 'new', :section_id => @section},
:class => 'icon icon-add') if User.current.allowed_to?(:add_questions, @project) %>
<%= link_to(l(:label_questions_section_edit),
{:controller => 'questions_sections', :action => 'edit', :id => @section},
:class => 'icon icon-edit') if @section && User.current.allowed_to?(:manage_sections, @project) %>
</div>
<%= question_breadcrumb @section %>
<h2 class="section-title">
<%= @section ? @section.name : l(:label_questions)%>
</h2>
<% if @section && !@section.description.blank? %>
<em class="info"><%= @section.description %></em>
<% end %>
<div class="filters">
<%= form_tag({:controller => "questions", :action => "index"}, :method => :get, :id => "query_form") do %>
<%= 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_subject_questions_path(:project_id => @project, :section_id => @section)) }')" %>
<% end %>
</div>
</div>
<div id="topics_list" >
<%= render :partial => "questions/question_list" %>
</div>
<% content_for :sidebar do %>
<%= render :partial => "questions/latest_topics" %>
<%= render :partial => "questions/popular_topics" %>
<% end %>

View file

@ -1,9 +1,12 @@
<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} %>
<%= form_for @question_item, { :url => questions_path, :html => {:multipart => true,
:id => 'question_form'}} do |f| %>
<div id="all_attributes">
<%= render :partial => 'form', :locals => {:f => f} %>
</div>
<%= submit_tag l(:button_create) %>
<%# preview_link({:controller => 'messages', :action => 'preview', :board_id => @board}, 'message-form') %>
<% preview_link({:controller => 'questions', :action => 'preview', :id => @question_item}, 'question_form') %>
<% end %>
<div id="preview" class="wiki"></div>

View file

@ -0,0 +1,6 @@
<%= question_breadcrumb @question_item %>
<%= render :partial => 'question' if QA_VERSION_TYPE.match(/Light/) %>
<% html_title @question_item.subject %>

View file

@ -1,31 +0,0 @@
<% 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 %>

View file

@ -0,0 +1 @@
$('#all_attributes').html('<%= escape_javascript(render :partial => 'form') %>');