issue列表开启AT功能

This commit is contained in:
guange 2015-12-06 15:03:12 +08:00
parent 55bb9f68e0
commit af31946586
9 changed files with 1321 additions and 31 deletions

View File

@ -142,6 +142,13 @@ class IssuesController < ApplicationController
@project_base_tag = (params[:project_id] || @issue.project) ? 'base_projects':'base'#by young
@available_watchers = (@issue.project.users.sort + @issue.watcher_users).uniq
#id name email
#1. issues list persons
#2. project persons
@at_persons = []
@journals.each {|j| @at_persons << j.user unless @at_persons.include?(j.user)}
@issue.project.users.each {|u| @at_persons << u unless @at_persons.include?(u)}
respond_to do |format|``
format.html {
retrieve_previous_and_next_issue_ids

View File

@ -2619,4 +2619,38 @@ int main(int argc, char** argv){
true
end
end
def import_ke(default_opt={})
opt = {enable_at: true, prettify: false, init_activity: false}.merge default_opt
ss = ''
if opt[:enable_at]
ss = '<script type="text/javascript">'
ss += 'window.atPersonLists = [];'
@at_persons && @at_persons.each_with_index do |person,index|
ss += "var o = {id: #{index}, name: '#{person.get_at_show_name}', email: '#{person.mail}'};"
ss += "atPersonLists.push(o);"
end
ss += "</script>"
end
ss += javascript_include_tag("/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg')
if opt[:enable_at]
ss += javascript_include_tag('/assets/kindeditor/at/jquery.caret.min.js', '/assets/kindeditor/at/jquery.atwho.js', '/assets/kindeditor/at/config.js')
ss += stylesheet_link_tag("/assets/kindeditor/at/jquery.atwho.css")
end
if opt[:prettify]
ss += javascript_include_tag 'prettify'
ss += stylesheet_link_tag 'prettify'
end
if opt[:init_activity]
ss += javascript_include_tag "init_activity_KindEditor"
end
ss.html_safe
end
end

View File

@ -409,11 +409,15 @@ class User < Principal
else
name = lastname+firstname
end
name = name.empty? || name.nil? ? login : name
name
name.empty? || name.nil? ? login : name
end
## end
def get_at_show_name
name = show_name
name = "#{name} #{self.login}" if name != self.login
end
#added by nie
def count_new_journal_reply
count = self.journal_reply.count

View File

@ -1,4 +1,7 @@
<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' %>
<%= content_for(:header_tags) do %>
<%= import_ke(enable_at: true) %>
<% end %>
<div class="project_r_h">
<h2 class="project_h2"><%= l(:label_issue_edit) %></h2>
</div>

View File

@ -543,23 +543,26 @@ ActiveRecord::Schema.define(:version => 20151204062220) do
add_index "documents", ["created_on"], :name => "index_documents_on_created_on"
add_index "documents", ["project_id"], :name => "documents_project_id"
create_table "dts", :force => true do |t|
t.string "IPLineCode"
t.string "Description"
t.string "Num"
t.string "Variable"
t.string "TraceInfo"
t.string "Method"
create_table "dts", :primary_key => "Num", :force => true do |t|
t.string "Defect", :limit => 50
t.string "Category", :limit => 50
t.string "File"
t.string "IPLine"
t.string "Review"
t.string "Category"
t.string "Defect"
t.string "PreConditions"
t.string "StartLine"
t.string "Method"
t.string "Module", :limit => 20
t.string "Variable", :limit => 50
t.integer "StartLine"
t.integer "IPLine"
t.string "IPLineCode", :limit => 200
t.string "Judge", :limit => 15
t.integer "Review", :limit => 1
t.string "Description"
t.text "PreConditions", :limit => 2147483647
t.text "TraceInfo", :limit => 2147483647
t.text "Code", :limit => 2147483647
t.integer "project_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.datetime "created_at"
t.datetime "updated_at"
t.integer "id", :null => false
end
create_table "enabled_modules", :force => true do |t|
@ -891,16 +894,6 @@ ActiveRecord::Schema.define(:version => 20151204062220) do
add_index "journal_details", ["journal_id"], :name => "journal_details_journal_id"
create_table "journal_details_copy", :force => true do |t|
t.integer "journal_id", :default => 0, :null => false
t.string "property", :limit => 30, :default => "", :null => false
t.string "prop_key", :limit => 30, :default => "", :null => false
t.text "old_value"
t.text "value"
end
add_index "journal_details_copy", ["journal_id"], :name => "journal_details_journal_id"
create_table "journal_replies", :id => false, :force => true do |t|
t.integer "journal_id"
t.integer "user_id"
@ -970,7 +963,6 @@ ActiveRecord::Schema.define(:version => 20151204062220) do
t.integer "course_group_id", :default => 0
end
add_index "members", ["course_id"], :name => "index_members_on_course_id"
add_index "members", ["project_id"], :name => "index_members_on_project_id"
add_index "members", ["user_id", "project_id", "course_id"], :name => "index_members_on_user_id_and_project_id", :unique => true
add_index "members", ["user_id"], :name => "index_members_on_user_id"

View File

@ -1,5 +1,6 @@
module RailsKindeditor
module Helper
EVAL_STR = %Q|eval(function(){ if(typeof enablePasteImg ==='function'){enablePasteImg(self);} if(typeof enableAt ==='function'){enableAt(self);} this.loadPlugin("autoheight")})|
def kindeditor_tag(name, content = nil, options = {})
id = sanitize_to_id(name)
@ -9,7 +10,7 @@ module RailsKindeditor
output << text_area_tag(name, content, input_html)
output << javascript_tag(js_replace(id, options.merge(window_onload: 'true',
:autoHeightMode=>true,
afterCreate: 'eval(function(){enablePasteImg(self);this.loadPlugin("autoheight")})',
afterCreate: EVAL_STR,
emotionsBasePath: 'http://' + Setting.host_name
)))
end
@ -22,7 +23,7 @@ module RailsKindeditor
output_buffer << build_text_area_tag(name, method, self, options, input_html)
output_buffer << javascript_tag(js_replace(input_html['id'],options.merge(window_onload: 'true',
:autoHeightMode=>true,
afterCreate: 'eval(function(){enablePasteImg(self);this.loadPlugin("autoheight")})',
afterCreate: EVAL_STR,
emotionsBasePath: 'http://' + Setting.host_name
)))
end

View File

@ -0,0 +1,39 @@
function enableAt(_editor) {
var editor = _editor;
if(editor.edit == undefined || editor.edit.iframe == undefined){
return;
}
var ifr = editor.edit.iframe[0];
var doc = ifr.contentDocument || iframe.contentWindow.document;
var ifrBody = doc.body;
ifrBody.contentEditable = true;
console.log("enable at");
$.fn.atwho.debug = true;
if(!atPersonLists){
return;
}
var names = atPersonLists;
//var names = ["Jacob","Isabella","Ethan","Emma","Michael","Olivia","Alexander","Sophia","William","Ava","Joshua","Emily","Daniel","Madison","Jayden","Abigail","Noah","Chloe","你好","你你你", "가"];
//
//var names = $.map(names,function(value,i) {
// return {'id':i,'name':value,'email':value+"@email.com"};
//});
var at_config = {
at: "@",
data: names,
insertTpl: '@${name}',
displayTpl: "<li>${name} <small>${email}</small></li>",
limit: 200
}
$inputor = $(ifrBody).atwho(at_config);
window.aaa= $inputor;
$inputor.caret('pos', 47);
$inputor.focus().atwho('run');
};

View File

@ -0,0 +1,49 @@
.atwho-view {
position:absolute;
top: 0;
left: 0;
display: none;
margin-top: 18px;
background: white;
color: black;
border: 1px solid #DDD;
border-radius: 3px;
box-shadow: 0 0 5px rgba(0,0,0,0.1);
min-width: 120px;
max-height: 200px;
overflow: auto;
z-index: 11110 !important;
}
.atwho-view .cur {
background: #3366FF;
color: white;
}
.atwho-view .cur small {
color: white;
}
.atwho-view strong {
color: #3366FF;
}
.atwho-view .cur strong {
color: white;
font:bold;
}
.atwho-view ul {
/* width: 100px; */
list-style:none;
padding:0;
margin:auto;
}
.atwho-view ul li {
display: block;
padding: 5px 10px;
border-bottom: 1px solid #DDD;
cursor: pointer;
/* border-top: 1px solid #C8C8C8; */
}
.atwho-view small {
font-size: smaller;
color: #777;
font-weight: normal;
}

File diff suppressed because it is too large Load Diff