将at js data整合到文件中

This commit is contained in:
guange 2015-12-09 09:59:13 +08:00
parent 57d05d147e
commit 3476731b83
7 changed files with 50 additions and 32 deletions

View File

@ -0,0 +1,25 @@
#coding=utf-8
class AtController < ApplicationController
respond_to :js
def show
type = params[:type]
case type
when "Issue"
@users = find_issue(params)
else
end
end
private
def find_issue(params)
#1. issues list persons
#2. project persons
issue = Issue.find(params[:id])
journals = issue.journals
at_persons = journals.map(&:user) + issue.project.users
at_persons.uniq{|u| u.id}.delete_if{|u| u.id == User.current.id}
end
end

View File

@ -142,24 +142,17 @@ class IssuesController < ApplicationController
@project_base_tag = (params[:project_id] || @issue.project) ? 'base_projects':'base'#by young @project_base_tag = (params[:project_id] || @issue.project) ? 'base_projects':'base'#by young
@available_watchers = (@issue.project.users.sort + @issue.watcher_users).uniq @available_watchers = (@issue.project.users.sort + @issue.watcher_users).uniq
#id name email respond_to do |format|
#1. issues list persons format.html {
#2. project persons retrieve_previous_and_next_issue_ids
@at_persons = @journals.map(&:user) + @issue.project.users render :template => 'issues/show', :layout => @project_base_tag#by young
@at_persons = @at_persons.uniq{|u| u.id}.delete_if{|u| u.id == User.current.id} }
@at_persons = nil format.api
format.atom { render :template => 'journals/index', :layout => false, :content_type => 'application/atom+xml' }
respond_to do |format|`` format.pdf {
format.html { pdf = issue_to_pdf(@issue, :journals => @journals)
retrieve_previous_and_next_issue_ids send_data(pdf, :type => 'application/pdf', :filename => filename_for_content_disposition("#{@project.identifier}-#{@issue.id}.pdf") )
render :template => 'issues/show', :layout => @project_base_tag#by young }
}
format.api
format.atom { render :template => 'journals/index', :layout => false, :content_type => 'application/atom+xml' }
format.pdf {
pdf = issue_to_pdf(@issue, :journals => @journals)
send_data(pdf, :type => 'application/pdf', :filename => filename_for_content_disposition("#{@project.identifier}-#{@issue.id}.pdf") )
}
end end
end end

View File

@ -2624,15 +2624,7 @@ int main(int argc, char** argv){
opt = {enable_at: true, prettify: false, init_activity: false}.merge default_opt opt = {enable_at: true, prettify: false, init_activity: false}.merge default_opt
ss = '' ss = ''
if opt[:enable_at] if opt[:enable_at]
ss = '<script type="text/javascript">' ss += %Q|<script src="/at/#{opt[:enable_at][:id]}.js?type=#{opt[:enable_at][:type]}" type="text/javascript"></script>|
ss += 'window.atPersonLists = [];'
@at_persons && @at_persons.each_with_index do |person,index|
ss += "var o = {id: #{index}, name: '#{person.show_name}', login: '#{person.login}', searchKey: '#{person.get_at_show_name}'};"
ss += "atPersonLists.push(o);"
end
ss += "</script>"
end end
ss += javascript_include_tag("/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg') ss += javascript_include_tag("/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg')

8
app/views/at/show.js.erb Normal file
View File

@ -0,0 +1,8 @@
(function(){
window.atPersonLists = [];
<% @users && @users.each_with_index do |person,index| %>
var o = {id: <%=index%>, name: '<%=person.show_name%>', login: '<%=person.login%>', searchKey: '<%=person.get_at_show_name%>'};
atPersonLists.push(o);
<% end %>
})();

View File

@ -1,5 +1,5 @@
<%= content_for(:header_tags) do %> <%= content_for(:header_tags) do %>
<%= import_ke(enable_at: true) %> <%= import_ke(enable_at: {id: @issue.id, type: 'Issue'}) %>
<% end %> <% end %>
<div class="project_r_h"> <div class="project_r_h">

View File

@ -1035,13 +1035,14 @@ RedmineApp::Application.routes.draw do
match 'system_log/clear' match 'system_log/clear'
##ended by lizanle ##ended by lizanle
resources :git_callback do resources :git_callback do
collection do collection do
post 'post_update' post 'post_update'
end end
end end
resources :at
Dir.glob File.expand_path("plugins/*", Rails.root) do |plugin_dir| Dir.glob File.expand_path("plugins/*", Rails.root) do |plugin_dir|
file = File.join(plugin_dir, "config/routes.rb") file = File.join(plugin_dir, "config/routes.rb")
if File.exists?(file) if File.exists?(file)

View File

@ -1,4 +1,4 @@
function enableAt(_editor) { var enableAt = function(_editor) {
var editor = _editor; var editor = _editor;
if(editor.edit == undefined || editor.edit.iframe == undefined){ if(editor.edit == undefined || editor.edit.iframe == undefined){
return; return;
@ -11,7 +11,7 @@ function enableAt(_editor) {
console.log("enable at"); console.log("enable at");
$.fn.atwho.debug = true; $.fn.atwho.debug = true;
if(!atPersonLists){ if("undefined" === (typeof atPersonLists) || !atPersonLists){
return; return;
} }
var names = atPersonLists; var names = atPersonLists;
@ -32,7 +32,6 @@ function enableAt(_editor) {
} }
$inputor = $(ifrBody).atwho(at_config); $inputor = $(ifrBody).atwho(at_config);
window.aaa= $inputor;
$inputor.caret('pos', 47); $inputor.caret('pos', 47);
$inputor.focus().atwho('run'); $inputor.focus().atwho('run');
}; };