diff --git a/Gemfile b/Gemfile
index ea74fd509..e752dc356 100644
--- a/Gemfile
+++ b/Gemfile
@@ -13,6 +13,7 @@ gem 'exception_notification' # Send error trace
gem 'execjs'
gem 'jquery-rails', '2.1.4'
gem 'jquery-ui-rails'
+gem "select2-rails"
gem 'kaminari', :git => 'git://github.com/amatsuda/kaminari.git'
# gem "memcached", "~> 1.4.3"
diff --git a/Gemfile.lock b/Gemfile.lock
index 62118728a..93e49c01b 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -141,6 +141,7 @@ GEM
jquery-rails
railties (>= 3.1.0)
json (1.7.7)
+ libv8 (3.11.8.13)
mail (2.4.4)
i18n (>= 0.4.0)
mime-types (~> 1.16)
@@ -224,6 +225,7 @@ GEM
rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0)
rake (10.0.3)
+ rb-readline (0.4.2)
rdoc (3.12.1)
json (~> 1.4)
redis (3.0.2)
@@ -233,6 +235,7 @@ GEM
chinese_pinyin (>= 0.3.0)
redis (>= 2.1.1)
redis-namespace (>= 1.0.2)
+ ref (1.0.2)
resque (1.23.0)
multi_json (~> 1.0)
redis-namespace (~> 1.0)
@@ -275,6 +278,9 @@ GEM
railties (~> 3.2.0)
sass (>= 3.1.10)
tilt (~> 1.3)
+ select2-rails (3.3.0)
+ sass-rails (~> 3.2)
+ thor (~> 0.14)
selenium-webdriver (2.30.0)
childprocess (>= 0.2.5)
multi_json (~> 1.0)
@@ -313,6 +319,9 @@ GEM
sunspot (= 1.3.3)
sunspot_solr (1.3.3)
terminal-table (1.4.5)
+ therubyracer (0.11.4)
+ libv8 (~> 3.11.8.12)
+ ref
thor (0.17.0)
tilt (1.3.3)
tinymce-rails (3.5.8)
@@ -357,6 +366,7 @@ DEPENDENCIES
jquery-rails (= 2.1.4)
jquery-ui-rails
kaminari!
+ libv8 (~> 3.11.8)
mime-types
mini_magick
mongo_session_store-rails3 (= 3.0.6)
@@ -373,6 +383,7 @@ DEPENDENCIES
radius
rails (~> 3.2.9)
rake
+ rb-readline
redis (>= 2.1.1)
redis-namespace
redis-search
@@ -384,6 +395,7 @@ DEPENDENCIES
rspec-rails (~> 2.0)
rubyzip
sass-rails
+ select2-rails
shoulda-matchers
simplecov
sinatra
@@ -393,6 +405,7 @@ DEPENDENCIES
sunspot-rails-tester
sunspot_mongo
sunspot_solr
+ therubyracer
tinymce-rails
uglifier
watchr
diff --git a/app/assets/javascripts/desktop.js b/app/assets/javascripts/desktop.js
index c55534a4a..be81ab5ed 100644
--- a/app/assets/javascripts/desktop.js
+++ b/app/assets/javascripts/desktop.js
@@ -16,4 +16,4 @@
//= require orbitdesktop
//= require jquery.gridster
//= require desktop/books_pages
-//= require jquery.tokeninput
+//= require select2
diff --git a/app/assets/stylesheets/desktop.css b/app/assets/stylesheets/desktop.css
index 2ae194e5e..f3d3f91ef 100644
--- a/app/assets/stylesheets/desktop.css
+++ b/app/assets/stylesheets/desktop.css
@@ -15,4 +15,5 @@
*= require desktop/desktop-media
*= require desktop/desktop-timeline
*= require orbit-bar
-*/
\ No newline at end of file
+ *= require select2
+*/
diff --git a/vendor/built_in_modules/personal_conference/app/assets/javascripts/personal_conference/desktop/conference_pages.js b/vendor/built_in_modules/personal_conference/app/assets/javascripts/personal_conference/desktop/conference_pages.js
index 96a235cf2..a60201e06 100644
--- a/vendor/built_in_modules/personal_conference/app/assets/javascripts/personal_conference/desktop/conference_pages.js
+++ b/vendor/built_in_modules/personal_conference/app/assets/javascripts/personal_conference/desktop/conference_pages.js
@@ -1,116 +1,230 @@
orbitDesktop.prototype.initializeConferencePapers = function(target,url,cache){ // this init conference papers
- this.initializeConferencePapers.formCallback = function(data){
- if(data.success){
- o.notify(data.msg,"success");
- o.sub_menu_item($("div[content-type=menu] a").eq(0));
- }else{
- o.notify(data.msg,"alert");
- }
+ this.initializeConferencePapers.formCallback = function(data){
+ if(data.success){
+ o.notify(data.msg,"success");
+ o.sub_menu_item($("div[content-type=menu] a").eq(0));
+ }else{
+ o.notify(data.msg,"alert");
+ }
+ }
+
+ this.initializeConferencePapers.list = function(){ // to open list part in conference papers page
+ var conferenceData;
+ var bindHandlers = function(){ // to bind handlers for list page
+ o.simple_drop_down();
}
- this.initializeConferencePapers.list = function(){ // to open list part in conference papers page
- var conferenceData;
- var bindHandlers = function(){ // to bind handlers for list page
- o.simple_drop_down();
- }
-
- var bindSecondaryHandlers = function(){
- $("#conference_p div#paper_list a.icon-check-empty").click(function(){
- if($(this).hasClass("icon-check-empty")){
- $(this).switchClass("icon-check-empty","icon-check",0);
- } else if($(this) .hasClass("icon-check")) {
- $(this).switchClass("icon-check","icon-check-empty",0);
- } else if($(this).hasClass("icon-star")){
- $(this).removeClass("icon-star").addClass("icon-star-empty");
- } else if($(this).hasClass("icon-star-empty")){
- $(this).removeClass("icon-star-empty").addClass("icon-star");
- }
- return false;
- })
- }
- }
- this.initializeConferencePapers.paperDelete = function(data,dom){
- var parent = dom.parent().parent();
- if(data.success){
- parent.hide("slide",function(){parent.remove();});
- o.notify(data.msg,"success");
+ var bindSecondaryHandlers = function(){
+ $("#conference_p div#paper_list a.icon-check-empty").click(function(){
+ if($(this).hasClass("icon-check-empty")){
+ $(this).switchClass("icon-check-empty","icon-check",0);
+ } else if($(this) .hasClass("icon-check")) {
+ $(this).switchClass("icon-check","icon-check-empty",0);
+ } else if($(this).hasClass("icon-star")){
+ $(this).removeClass("icon-star").addClass("icon-star-empty");
+ } else if($(this).hasClass("icon-star-empty")){
+ $(this).removeClass("icon-star-empty").addClass("icon-star");
}
+ return false;
+ })
}
-
- this.initializeConferencePapers.editpaper = function(){
- o.highlight_sub_menu_item(1)
+ }
+ this.initializeConferencePapers.paperDelete = function(data,dom){
+ var parent = dom.parent().parent();
+ if(data.success){
+ parent.hide("slide",function(){parent.remove();});
+ o.notify(data.msg,"success");
}
+ }
- this.initializeConferencePapers.addpaper = function(){ // to open add pages in conference papers page
- var bindHandlers = function(){ // to bind handlers for add page
- o.simple_drop_down();
- $('#add_plugin_file a.add').click(function(){
- var new_id = $(this).prev().attr('value');
- var old_id = new RegExp("new_writing_conference_files", "g");
- $(this).prev().attr('value', parseInt(new_id) + 1);
- var x = get_html(old_id,new_id);
- var newfield = $(x);
- $(this).parents('table').append(newfield);
- newfield.find('.action a.delete').click(function(){
- newfield.remove();
- });
- return false;
+ this.initializeConferencePapers.cancelpaper = function(){
+ o.highlight_sub_menu_item(0);
+ }
+
+ this.initializeConferencePapers.editpaper = function(){
+ o.highlight_sub_menu_item(1);
+ var uploadFiles = function(){
+ $('#add_plugin_file a.add').click(function(){
+ var new_id = $(this).prev().attr('value');
+ var old_id = new RegExp("new_writing_conference_files", "g");
+ $(this).prev().attr('value', parseInt(new_id) + 1);
+ var x = get_html(old_id,new_id);
+ var newfield = $(x);
+ $(this).parents('table').append(newfield);
+ newfield.find('.action a.delete').click(function(){
+ newfield.remove();
});
-
- $('.action a.remove_existing_record').click(function(){
- $(this).next('.should_destroy').attr('value', 1);
- $("tr#add_plugin_file_" + $(this).prev().attr('value')).hide();
- });
- }
- bindHandlers();
+ return false;
+ });
+ $('.action a.remove_existing_record').click(function(){
+ $(this).next('.should_destroy').attr('value', 1);
+ $("tr#add_plugin_file_" + $(this).prev().attr('value')).hide();
+ });
}
- this.initializeConferencePapers.conference = function(){ // to open add pages in conference papers page
- var bindHandlers = function(){ // to bind handlers for add page
- o.simple_drop_down();
- }
- bindHandlers();
+ var tokesplits = function(){
+ $("#writing_conference_author_tokens").select2({
+ multiple: true,
+ minimumInputLength: 1,
+ width: "300px;",
+ formatResult: function movieFormatResult(coAuthor) {
+ var markup = "";
+ if (coAuthor.text !== undefined && coAuthor.email !== undefined) {
+ if(!coAuthor.email){
+ markup += coAuthor.text + " -- none email";
+ } else {
+ markup += coAuthor.text + " -- " + coAuthor.email;
+ }
+ }else if (coAuthor.email !== undefined) {
+ markup += coAuthor.text;
+ }
+ return markup;
+ },
+ ajax: {
+ url: "/panel/personal_conference/desktop/conference_pages/new.json",
+ dataType: 'json',
+ quietMillis: 100,
+ tokenSeparators: [","],
+ data: function (search, page) {
+ return {q: search};
+ },
+ results: function (data, page) {
+ return {results: data.results};
+ }
+ },
+ });
+
+ $("#writing_conference_author_tokens").select2("container").find("ul.select2-choices").sortable({
+ containment: 'parent',
+ start: function() { $("#writing_conference_author_tokens").select2("onSortStart"); },
+ update: function() { $("#writing_conference_author_tokens").select2("onSortEnd"); }
+ });
}
- this.initializeConferencePapers.coAuthorformCallback = function(data){
- if(data.success){
- o.notify(data.msg,"success");
- o.sub_menu_item($("div[content-type=menu] a").eq(3));
- }else{
- o.notify(data.msg,"alert");
- }
+ var preData = function(){
+ $("#writing_conference_author_tokens").select2('data', JSON.parse($("#writing_conference_author_tokens").attr('data-pre')));
+ }
+
+ uploadFiles();
+ tokesplits();
+ preData();
+ }
+
+ this.initializeConferencePapers.addpaper = function(){ // to open add pages in conference papers page
+ var uploadFiles = function(){
+ $('#add_plugin_file a.add').click(function(){
+ var new_id = $(this).prev().attr('value');
+ var old_id = new RegExp("new_writing_conference_files", "g");
+ $(this).prev().attr('value', parseInt(new_id) + 1);
+ var x = get_html(old_id,new_id);
+ var newfield = $(x);
+ $(this).parents('table').append(newfield);
+ newfield.find('.action a.delete').click(function(){
+ newfield.remove();
+ });
+ return false;
+ });
+ $('.action a.remove_existing_record').click(function(){
+ $(this).next('.should_destroy').attr('value', 1);
+ $("tr#add_plugin_file_" + $(this).prev().attr('value')).hide();
+ });
+ }
+
+ console.log("hi");
+ var bindHandlers = function(){
+ o.simple_drop_down();
+ }
+
+ var tokesplits = function(){
+ $("#writing_conference_author_tokens").select2({
+ multiple: true,
+ minimumInputLength: 1,
+ width: "300px;",
+ formatResult: function movieFormatResult(coAuthor) {
+ var markup = "";
+ if (coAuthor.text !== undefined && coAuthor.email !== undefined) {
+ if(!coAuthor.email){
+ markup += coAuthor.text + " -- none email";
+ } else {
+ markup += coAuthor.text + " -- " + coAuthor.email;
+ }
+ }else if (coAuthor.email !== undefined) {
+ markup += coAuthor.text;
+ }
+ return markup;
+ },
+ ajax: {
+ url: "/panel/personal_conference/desktop/conference_pages/new.json",
+ dataType: 'json',
+ quietMillis: 100,
+ tokenSeparators: [","],
+ data: function (search, page) {
+ return {q: search};
+ },
+ results: function (data, page) {
+ return {results: data.results};
+ }
+ },
+ });
+
+ $("#writing_conference_author_tokens").select2("container").find("ul.select2-choices").sortable({
+ containment: 'parent',
+ start: function() { $("#writing_conference_author_tokens").select2("onSortStart"); },
+ update: function() { $("#writing_conference_author_tokens").select2("onSortEnd"); }
+ });
+ }
+
+ bindHandlers();
+ uploadFiles();
+ tokesplits();
+ }
+
+ this.initializeConferencePapers.conference = function(){ // to open add pages in conference papers page
+ var bindHandlers = function(){ // to bind handlers for add page
+ o.simple_drop_down();
+ }
+ bindHandlers();
+ }
+
+ this.initializeConferencePapers.coAuthorformCallback = function(data){
+ if(data.success){
+ o.notify(data.msg,"success");
+ o.sub_menu_item($("div[content-type=menu] a").eq(3));
+ }else{
+ o.notify(data.msg,"alert");
+ }
+ }
+ this.initializeConferencePapers.coauthor = function(){ // to open add pages in coauthor page
+ var bindHandlers = function(){ // to bind handlers for add page
+ o.simple_drop_down();
}
- this.initializeConferencePapers.coauthor = function(){ // to open add pages in coauthor page
- var bindHandlers = function(){ // to bind handlers for add page
- o.simple_drop_down();
- }
bindHandlers();
}
this.initializeConferencePapers.coauthorRelationForm = function(data){
if(data.success){
- o.notify(data.msg,"success");
- $("#co_author_relation_table").html(data.newvalue);
- }else{
- o.notify(data.msg,"alert");
+ o.notify(data.msg,"success");
+ $("#co_author_relation_table").html(data.newvalue);
+ }else{
+ o.notify(data.msg,"alert");
}
}
this.initializeConferencePapers.coauthorRelationEditForm = function(data){
if(data.success){
- o.notify(data.msg,"success");
- $("#co_author_relation_table").html(data.newvalue);
- }else{
- o.notify(data.msg,"alert");
+ o.notify(data.msg,"success");
+ $("#co_author_relation_table").html(data.newvalue);
+ }else{
+ o.notify(data.msg,"alert");
}
}
- this.initializeConferencePapers.allnone = function(d,o){
+ this.initializeConferencePapers.allnone = function(d,o){
switch(o.attr("href")){
case "all":
$("div.overview a.icon-check-empty").removeClass("icon-check-empty").addClass("icon-check");
- break;
+ break;
case "none":
$("div.overview a.icon-check").removeClass("icon-check").addClass("icon-check-empty");
- break;
+ break;
}
- }
+ }
};
diff --git a/vendor/built_in_modules/personal_conference/app/controllers/panel/personal_conference/desktop/conference_co_author_relations_controller.rb b/vendor/built_in_modules/personal_conference/app/controllers/panel/personal_conference/desktop/conference_co_author_relations_controller.rb
index 001f9f424..0da30e7c8 100644
--- a/vendor/built_in_modules/personal_conference/app/controllers/panel/personal_conference/desktop/conference_co_author_relations_controller.rb
+++ b/vendor/built_in_modules/personal_conference/app/controllers/panel/personal_conference/desktop/conference_co_author_relations_controller.rb
@@ -28,7 +28,7 @@ class Panel::PersonalConference::Desktop::ConferenceCoAuthorRelationsController
if @conference_co_author_relation.save
newv = render_to_string partial: "show_form", object: @conference_co_author_relations
- render json: {success: true, msg: t("create_success") , newvalue: newv}.to_json
+ render json: {success: true, msg: t('create_success') , newvalue: newv}.to_json
else
error_msg = @conference_co_author_relation.errors.full_messages.join("
")
render json: {success: false, msg: error_msg}.to_json
@@ -40,7 +40,7 @@ class Panel::PersonalConference::Desktop::ConferenceCoAuthorRelationsController
if @conference_co_author_relation.update_attributes(params[:conference_co_author_relation])
@conference_co_author_relations = ConferenceCoAuthorRelation.all
newv = render_to_string partial: "show_form", object: @conference_co_author_relations
- render json: {success: true, msg: t("update_success"), newvalue: newv}.to_json
+ render json: {success: true, msg: t('update_success'), newvalue: newv}.to_json
else
error_msg = @conference_co_author.errors.full_messages.join("
")
render json: {success: false, msg: error_msg}.to_json
diff --git a/vendor/built_in_modules/personal_conference/app/controllers/panel/personal_conference/desktop/conference_pages_controller.rb b/vendor/built_in_modules/personal_conference/app/controllers/panel/personal_conference/desktop/conference_pages_controller.rb
index a257719b8..93c307404 100644
--- a/vendor/built_in_modules/personal_conference/app/controllers/panel/personal_conference/desktop/conference_pages_controller.rb
+++ b/vendor/built_in_modules/personal_conference/app/controllers/panel/personal_conference/desktop/conference_pages_controller.rb
@@ -32,19 +32,20 @@ class Panel::PersonalConference::Desktop::ConferencePagesController < Applicatio
WritingConference.where(create_user_id: current_user.id).map{|j|j.conference_title}.uniq
if (not params[:q].nil?) and (current_user.name.include?params[:q])
- @user = [{ :id => 0, :name => current_user.name}] # self account name
+ @user = [{ :id => 0, :text => current_user.name, :email => current_user.email}] # self account name
else
@user = []
end
- @co_authors = ConferenceCoAuthor.where(name_id: current_user.id, :co_author => /#{params[:q]}/)
- @co_authors = [{ :id => params[:q], :name => params[:q] }] + # search string
- @user + # self account name
- @co_authors.map{|m| { :id => m.id, :name => m.co_author } } # match pattern
+ @co_authors = ConferenceCoAuthor.where(name_id: current_user.id, :co_author => /#{params[:q]}/).asc(:co_author)
+ # search string + self account name + match pattern
+ @co_authors = [{ :id => params[:q], :text => params[:q], :email => "#{t("add")} #{t("author")}" }] +
+ @user +
+ @co_authors.map{|m| { :id => m.id, :text => m.co_author, :email => m.email } }
respond_to do |format|
format.html { render :layout => false}
- format.json { render :json => @co_authors.to_json }
+ format.json { render :json => {:results => @co_authors}.to_json }
end
end
diff --git a/vendor/built_in_modules/personal_conference/app/helpers/panel/personal_conference/desktop/conference_pages_helper.rb b/vendor/built_in_modules/personal_conference/app/helpers/panel/personal_conference/desktop/conference_pages_helper.rb
index c30254c47..41b4fb685 100644
--- a/vendor/built_in_modules/personal_conference/app/helpers/panel/personal_conference/desktop/conference_pages_helper.rb
+++ b/vendor/built_in_modules/personal_conference/app/helpers/panel/personal_conference/desktop/conference_pages_helper.rb
@@ -83,12 +83,13 @@ module Panel::PersonalConference::Desktop::ConferencePagesHelper
def generate_authors_name ids
author_name = ids.map{|m|
if m == "0"
- {:id => 0, :name => current_user.name}
+ #{:id => 0, :text => current_user.name, :email => current_user.email }
+ {:id => 0, :text => current_user.name }
else
- {:id => m, :name => ConferenceCoAuthor.find(m).co_author}
+ #{:id => m, :text => ConferenceCoAuthor.find(m).co_author, :email => ConferenceCoAuthor.find(m).email}
+ {:id => m, :text => ConferenceCoAuthor.find(m).co_author}
end
}
-
author_name.to_json
end
end
diff --git a/vendor/built_in_modules/personal_conference/app/models/writing_conference.rb b/vendor/built_in_modules/personal_conference/app/models/writing_conference.rb
index c74eccbcf..090f54d1f 100644
--- a/vendor/built_in_modules/personal_conference/app/models/writing_conference.rb
+++ b/vendor/built_in_modules/personal_conference/app/models/writing_conference.rb
@@ -42,6 +42,7 @@ class WritingConference
validates :paper_title, :at_least_one => true
before_validation :add_http
after_save :save_writing_conference_files
+ before_save :update_co_author
validates :url, :format => /^(http|https):\/\/(([a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5})|((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))(:[0-9]{1,5})?(\/.*)?/i, :unless => Proc.new{self.url.blank?}
attr_reader :author_tokens
@@ -49,10 +50,10 @@ class WritingConference
def author_tokens=(ids)
authors_ids = ids.split(",").map{|id|
begin
- ConferenceCoAuthor.find(m).id
+ ConferenceCoAuthor.find(id).id
rescue
if id != "0"
- new_co_author = ConferenceCoAuthor.new(:co_author => id, :name_id => create_user_id)
+ new_co_author = ConferenceCoAuthor.new(:co_author => id)
new_co_author.save
new_co_author.id
else
@@ -63,6 +64,19 @@ class WritingConference
self.conference_co_author_ids = authors_ids
end
+ def update_co_author
+ if new_record?
+ current_user = self.create_user_id
+ else
+ current_user = self.update_user_id
+ end
+
+ self.conference_co_author_ids.each do |id|
+ co_author = ConferenceCoAuthor.find(id)
+ co_author.update_attribute(:name_id, current_user)
+ end
+ end
+
def self.search( category_id = nil )
if category_id.to_s.size > 0
find(:all, :conditions => {writing_conference_category_id: category_id}).desc( :is_top, :title )
diff --git a/vendor/built_in_modules/personal_conference/app/views/panel/personal_conference/desktop/conference_pages/_form.html.erb b/vendor/built_in_modules/personal_conference/app/views/panel/personal_conference/desktop/conference_pages/_form.html.erb
index 1fc2679be..53cdf8b85 100644
--- a/vendor/built_in_modules/personal_conference/app/views/panel/personal_conference/desktop/conference_pages/_form.html.erb
+++ b/vendor/built_in_modules/personal_conference/app/views/panel/personal_conference/desktop/conference_pages/_form.html.erb
@@ -1,9 +1,8 @@