Merge branch 'desktop' into desktop_work

* desktop:
  tinyscrollbar pagination fixed
  insert and remove columns
  Major tinyscrollbar update
  modify translation for journal_co_author_relation button
  modify nil of email string and sort
  remove redundant space of co_author sample data
  make index of list can be hightline list when click cancel button
  fixed author sample data generation and model method
  add author filter for journal and fix some bug
  have done conference author filter, journal haven't been done, yet
This commit is contained in:
Rueshyna 2013-03-12 14:16:25 +08:00
commit 470dbea22d
23 changed files with 493 additions and 249 deletions

View File

@ -13,6 +13,7 @@ gem 'exception_notification' # Send error trace
gem 'execjs' gem 'execjs'
gem 'jquery-rails', '2.1.4' gem 'jquery-rails', '2.1.4'
gem 'jquery-ui-rails' gem 'jquery-ui-rails'
gem "select2-rails"
gem 'kaminari', :git => 'git://github.com/amatsuda/kaminari.git' gem 'kaminari', :git => 'git://github.com/amatsuda/kaminari.git'
# gem "memcached", "~> 1.4.3" # gem "memcached", "~> 1.4.3"

View File

@ -141,6 +141,7 @@ GEM
jquery-rails jquery-rails
railties (>= 3.1.0) railties (>= 3.1.0)
json (1.7.7) json (1.7.7)
libv8 (3.11.8.13)
mail (2.4.4) mail (2.4.4)
i18n (>= 0.4.0) i18n (>= 0.4.0)
mime-types (~> 1.16) mime-types (~> 1.16)
@ -224,6 +225,7 @@ GEM
rdoc (~> 3.4) rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0) thor (>= 0.14.6, < 2.0)
rake (10.0.3) rake (10.0.3)
rb-readline (0.4.2)
rdoc (3.12.1) rdoc (3.12.1)
json (~> 1.4) json (~> 1.4)
redis (3.0.2) redis (3.0.2)
@ -233,6 +235,7 @@ GEM
chinese_pinyin (>= 0.3.0) chinese_pinyin (>= 0.3.0)
redis (>= 2.1.1) redis (>= 2.1.1)
redis-namespace (>= 1.0.2) redis-namespace (>= 1.0.2)
ref (1.0.2)
resque (1.23.0) resque (1.23.0)
multi_json (~> 1.0) multi_json (~> 1.0)
redis-namespace (~> 1.0) redis-namespace (~> 1.0)
@ -275,6 +278,9 @@ GEM
railties (~> 3.2.0) railties (~> 3.2.0)
sass (>= 3.1.10) sass (>= 3.1.10)
tilt (~> 1.3) tilt (~> 1.3)
select2-rails (3.3.0)
sass-rails (~> 3.2)
thor (~> 0.14)
selenium-webdriver (2.30.0) selenium-webdriver (2.30.0)
childprocess (>= 0.2.5) childprocess (>= 0.2.5)
multi_json (~> 1.0) multi_json (~> 1.0)
@ -313,6 +319,9 @@ GEM
sunspot (= 1.3.3) sunspot (= 1.3.3)
sunspot_solr (1.3.3) sunspot_solr (1.3.3)
terminal-table (1.4.5) terminal-table (1.4.5)
therubyracer (0.11.4)
libv8 (~> 3.11.8.12)
ref
thor (0.17.0) thor (0.17.0)
tilt (1.3.3) tilt (1.3.3)
tinymce-rails (3.5.8) tinymce-rails (3.5.8)
@ -357,6 +366,7 @@ DEPENDENCIES
jquery-rails (= 2.1.4) jquery-rails (= 2.1.4)
jquery-ui-rails jquery-ui-rails
kaminari! kaminari!
libv8 (~> 3.11.8)
mime-types mime-types
mini_magick mini_magick
mongo_session_store-rails3 (= 3.0.6) mongo_session_store-rails3 (= 3.0.6)
@ -373,6 +383,7 @@ DEPENDENCIES
radius radius
rails (~> 3.2.9) rails (~> 3.2.9)
rake rake
rb-readline
redis (>= 2.1.1) redis (>= 2.1.1)
redis-namespace redis-namespace
redis-search redis-search
@ -384,6 +395,7 @@ DEPENDENCIES
rspec-rails (~> 2.0) rspec-rails (~> 2.0)
rubyzip rubyzip
sass-rails sass-rails
select2-rails
shoulda-matchers shoulda-matchers
simplecov simplecov
sinatra sinatra
@ -393,6 +405,7 @@ DEPENDENCIES
sunspot-rails-tester sunspot-rails-tester
sunspot_mongo sunspot_mongo
sunspot_solr sunspot_solr
therubyracer
tinymce-rails tinymce-rails
uglifier uglifier
watchr watchr

View File

@ -16,4 +16,4 @@
//= require orbitdesktop //= require orbitdesktop
//= require jquery.gridster //= require jquery.gridster
//= require desktop/books_pages //= require desktop/books_pages
//= require jquery.tokeninput //= require select2

View File

@ -15,4 +15,5 @@
*= require desktop/desktop-media *= require desktop/desktop-media
*= require desktop/desktop-timeline *= require desktop/desktop-timeline
*= require orbit-bar *= require orbit-bar
*/ *= require select2
*/

View File

@ -1,116 +1,230 @@
orbitDesktop.prototype.initializeConferencePapers = function(target,url,cache){ // this init conference papers orbitDesktop.prototype.initializeConferencePapers = function(target,url,cache){ // this init conference papers
this.initializeConferencePapers.formCallback = function(data){ this.initializeConferencePapers.formCallback = function(data){
if(data.success){ if(data.success){
o.notify(data.msg,"success"); o.notify(data.msg,"success");
o.sub_menu_item($("div[content-type=menu] a").eq(0)); o.sub_menu_item($("div[content-type=menu] a").eq(0));
}else{ }else{
o.notify(data.msg,"alert"); 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 bindSecondaryHandlers = function(){
var conferenceData; $("#conference_p div#paper_list a.icon-check-empty").click(function(){
var bindHandlers = function(){ // to bind handlers for list page if($(this).hasClass("icon-check-empty")){
o.simple_drop_down(); $(this).switchClass("icon-check-empty","icon-check",0);
} } else if($(this) .hasClass("icon-check")) {
$(this).switchClass("icon-check","icon-check-empty",0);
var bindSecondaryHandlers = function(){ } else if($(this).hasClass("icon-star")){
$("#conference_p div#paper_list a.icon-check-empty").click(function(){ $(this).removeClass("icon-star").addClass("icon-star-empty");
if($(this).hasClass("icon-check-empty")){ } else if($(this).hasClass("icon-star-empty")){
$(this).switchClass("icon-check-empty","icon-check",0); $(this).removeClass("icon-star-empty").addClass("icon-star");
} 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");
} }
return false;
})
} }
}
this.initializeConferencePapers.editpaper = function(){ this.initializeConferencePapers.paperDelete = function(data,dom){
o.highlight_sub_menu_item(1) 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 this.initializeConferencePapers.cancelpaper = function(){
var bindHandlers = function(){ // to bind handlers for add page o.highlight_sub_menu_item(0);
o.simple_drop_down(); }
$('#add_plugin_file a.add').click(function(){
var new_id = $(this).prev().attr('value'); this.initializeConferencePapers.editpaper = function(){
var old_id = new RegExp("new_writing_conference_files", "g"); o.highlight_sub_menu_item(1);
$(this).prev().attr('value', parseInt(new_id) + 1); var uploadFiles = function(){
var x = get_html(old_id,new_id); $('#add_plugin_file a.add').click(function(){
var newfield = $(x); var new_id = $(this).prev().attr('value');
$(this).parents('table').append(newfield); var old_id = new RegExp("new_writing_conference_files", "g");
newfield.find('.action a.delete').click(function(){ $(this).prev().attr('value', parseInt(new_id) + 1);
newfield.remove(); var x = get_html(old_id,new_id);
}); var newfield = $(x);
return false; $(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); $('.action a.remove_existing_record').click(function(){
$("tr#add_plugin_file_" + $(this).prev().attr('value')).hide(); $(this).next('.should_destroy').attr('value', 1);
}); $("tr#add_plugin_file_" + $(this).prev().attr('value')).hide();
} });
bindHandlers();
} }
this.initializeConferencePapers.conference = function(){ // to open add pages in conference papers page var tokesplits = function(){
var bindHandlers = function(){ // to bind handlers for add page $("#writing_conference_author_tokens").select2({
o.simple_drop_down(); multiple: true,
} minimumInputLength: 1,
bindHandlers(); 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){ var preData = function(){
if(data.success){ $("#writing_conference_author_tokens").select2('data', JSON.parse($("#writing_conference_author_tokens").attr('data-pre')));
o.notify(data.msg,"success"); }
o.sub_menu_item($("div[content-type=menu] a").eq(3));
}else{ uploadFiles();
o.notify(data.msg,"alert"); 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(); bindHandlers();
} }
this.initializeConferencePapers.coauthorRelationForm = function(data){ this.initializeConferencePapers.coauthorRelationForm = function(data){
if(data.success){ if(data.success){
o.notify(data.msg,"success"); o.notify(data.msg,"success");
$("#co_author_relation_table").html(data.newvalue); $("#co_author_relation_table").html(data.newvalue);
}else{ }else{
o.notify(data.msg,"alert"); o.notify(data.msg,"alert");
} }
} }
this.initializeConferencePapers.coauthorRelationEditForm = function(data){ this.initializeConferencePapers.coauthorRelationEditForm = function(data){
if(data.success){ if(data.success){
o.notify(data.msg,"success"); o.notify(data.msg,"success");
$("#co_author_relation_table").html(data.newvalue); $("#co_author_relation_table").html(data.newvalue);
}else{ }else{
o.notify(data.msg,"alert"); o.notify(data.msg,"alert");
} }
} }
this.initializeConferencePapers.allnone = function(d,o){ this.initializeConferencePapers.allnone = function(d,o){
switch(o.attr("href")){ switch(o.attr("href")){
case "all": case "all":
$("div.overview a.icon-check-empty").removeClass("icon-check-empty").addClass("icon-check"); $("div.overview a.icon-check-empty").removeClass("icon-check-empty").addClass("icon-check");
break; break;
case "none": case "none":
$("div.overview a.icon-check").removeClass("icon-check").addClass("icon-check-empty"); $("div.overview a.icon-check").removeClass("icon-check").addClass("icon-check-empty");
break; break;
} }
} }
}; };

View File

@ -28,7 +28,7 @@ class Panel::PersonalConference::Desktop::ConferenceCoAuthorRelationsController
if @conference_co_author_relation.save if @conference_co_author_relation.save
newv = render_to_string partial: "show_form", object: @conference_co_author_relations 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 else
error_msg = @conference_co_author_relation.errors.full_messages.join("<br />") error_msg = @conference_co_author_relation.errors.full_messages.join("<br />")
render json: {success: false, msg: error_msg}.to_json 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]) if @conference_co_author_relation.update_attributes(params[:conference_co_author_relation])
@conference_co_author_relations = ConferenceCoAuthorRelation.all @conference_co_author_relations = ConferenceCoAuthorRelation.all
newv = render_to_string partial: "show_form", object: @conference_co_author_relations 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 else
error_msg = @conference_co_author.errors.full_messages.join("<br />") error_msg = @conference_co_author.errors.full_messages.join("<br />")
render json: {success: false, msg: error_msg}.to_json render json: {success: false, msg: error_msg}.to_json

View File

@ -32,19 +32,20 @@ class Panel::PersonalConference::Desktop::ConferencePagesController < Applicatio
WritingConference.where(create_user_id: current_user.id).map{|j|j.conference_title}.uniq 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]) 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 else
@user = [] @user = []
end end
@co_authors = ConferenceCoAuthor.where(name_id: current_user.id, :co_author => /#{params[:q]}/) @co_authors = ConferenceCoAuthor.where(name_id: current_user.id, :co_author => /#{params[:q]}/).asc(:co_author)
@co_authors = [{ :id => params[:q], :name => params[:q] }] + # search string # search string + self account name + match pattern
@user + # self account name @co_authors = [{ :id => params[:q], :text => params[:q], :email => "#{t("add")} #{t("author")}" }] +
@co_authors.map{|m| { :id => m.id, :name => m.co_author } } # match pattern @user +
@co_authors.map{|m| { :id => m.id, :text => m.co_author, :email => m.email } }
respond_to do |format| respond_to do |format|
format.html { render :layout => false} format.html { render :layout => false}
format.json { render :json => @co_authors.to_json } format.json { render :json => {:results => @co_authors}.to_json }
end end
end end

View File

@ -83,12 +83,13 @@ module Panel::PersonalConference::Desktop::ConferencePagesHelper
def generate_authors_name ids def generate_authors_name ids
author_name = ids.map{|m| author_name = ids.map{|m|
if m == "0" 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 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 end
} }
author_name.to_json author_name.to_json
end end
end end

View File

@ -42,6 +42,7 @@ class WritingConference
validates :paper_title, :at_least_one => true validates :paper_title, :at_least_one => true
before_validation :add_http before_validation :add_http
after_save :save_writing_conference_files 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?} 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 attr_reader :author_tokens
@ -49,10 +50,10 @@ class WritingConference
def author_tokens=(ids) def author_tokens=(ids)
authors_ids = ids.split(",").map{|id| authors_ids = ids.split(",").map{|id|
begin begin
ConferenceCoAuthor.find(m).id ConferenceCoAuthor.find(id).id
rescue rescue
if id != "0" 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.save
new_co_author.id new_co_author.id
else else
@ -63,6 +64,19 @@ class WritingConference
self.conference_co_author_ids = authors_ids self.conference_co_author_ids = authors_ids
end 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 ) def self.search( category_id = nil )
if category_id.to_s.size > 0 if category_id.to_s.size > 0
find(:all, :conditions => {writing_conference_category_id: category_id}).desc( :is_top, :title ) find(:all, :conditions => {writing_conference_category_id: category_id}).desc( :is_top, :title )

View File

@ -1,9 +1,8 @@
<div class="toolbar hh1"> <div class="toolbar hh1">
<div class="fn_g hp"> <div class="fn_g hp">
<%= f.submit t("save"), name: "commit", value: "Save", class: "fn_btn ini_input hp hh1 thmc2 thmtxt" %> <%= f.submit t("save"), name: "commit", class: "fn_btn ini_input hp hh1 thmc2 thmtxt" %>
<!-- class: bt-cancle can't be remove -->
<% if not @writing_conference.new_record? %> <% if not @writing_conference.new_record? %>
<%= submit_tag t("cancel"), :type => "button", "ajax-remote" => "get", :href => panel_personal_conference_desktop_conference_pages_path, class: "bt-cancel ini_input hp hh1 thmadm thmtxt" %> <%= submit_tag t("cancel"), :type => "button", "callback-method"=>"cancelpaper", "ajax-remote" => "get", :href => panel_personal_conference_desktop_conference_pages_path, class: "ini_input hp hh1 thmadm thmtxt" %>
<% end %> <% end %>
</div> </div>
<div class="hh1 hp sdm"> <div class="hh1 hp sdm">
@ -26,8 +25,7 @@
<div class="scrollbar sb_h vp"> <div class="scrollbar sb_h vp">
<div class="track"> <div class="track">
<div class="thumb thmc2"> <div class="thumb thmc2">
<div class="end"> <div class="end"></div>
</div>
</div> </div>
</div> </div>
</div> </div>
@ -100,14 +98,12 @@
<li class="s_grid_row"> <li class="s_grid_row">
<%= label_tag("", t("personal_conference.url"), class: "s_grid_2 s_grid") %><%= f.text_field :url, size: "20", placeholder: "www.sample.com", class: "s_grid_4 s_grid"%> <%= label_tag("", t("personal_conference.url"), class: "s_grid_2 s_grid") %><%= f.text_field :url, size: "20", placeholder: "www.sample.com", class: "s_grid_4 s_grid"%>
</li> </li>
</ul> </ul>
</div> </div>
<div column="true"> <div column="true">
<div class="s_form"> <div class="s_form">
<ul> <ul>
<li class="s_grid_row"> <li class="s_grid_row">
<%= f.label :author_tokens, t("personal_conference.authors") %><br />
<%= f.text_area :author_tokens, <%= f.text_area :author_tokens,
class: "s_grid_6 s_grid", class: "s_grid_6 s_grid",
size: "20x2", size: "20x2",
@ -209,25 +205,6 @@
<!-- </div> <!-- </div>
</div> --> </div> -->
<%= stylesheet_link_tag "token-input-facebook" %>
<%= javascript_include_tag :defaults, "jquery.tokeninput" %>
<script>
$(document).ready(function(){
$(function() {
$("#writing_conference_author_tokens").tokenInput("/panel/personal_conference/desktop/conference_pages/new.json", {
crossDomain: false,
prePopulate: $("#writing_conference_author_tokens").data("pre"),
theme: "facebook",
hintText: "<%=t("hintText")%>",
noResultsText: "<%=t("noResultsText")%>",
searchingText: "<%=t("searchingText")%>"
});
});
});
</script>
<script type="text/javascript"> <script type="text/javascript">
orbitDesktop.prototype.initializeJournalPapers.conference_title_autocomplete_list = <%= @conference_candidate.to_json.html_safe %>; orbitDesktop.prototype.initializeJournalPapers.conference_title_autocomplete_list = <%= @conference_candidate.to_json.html_safe %>;
// orbitDesktop.prototype.initializeJournalPapers.coauthor_autocomplete_list = <%= @co_author_candidate.to_json.html_safe %>; // orbitDesktop.prototype.initializeJournalPapers.coauthor_autocomplete_list = <%= @co_author_candidate.to_json.html_safe %>;

View File

@ -1,4 +1,4 @@
<%= form_for @writing_conference, html: { multipart: true, "form-type"=>"ajax_form", "callback-method"=>"coAuthorformCallback"}, url: panel_personal_conference_desktop_conference_page_path(@writing_conference) do |f| %> <%= form_for @writing_conference, html: { multipart: true, "form-type"=>"ajax_form", "callback-method"=>"formCallback"}, url: panel_personal_conference_desktop_conference_page_path(@writing_conference) do |f| %>
<%= render partial: 'form', locals: {:f => f} %> <%= render partial: 'form', locals: {:f => f} %>
<%end%> <%end%>

View File

@ -1,4 +1,4 @@
<%= form_for @writing_conference, html: { multipart: true, "form-type"=>"ajax_form", "callback-method"=>"coAuthorformCallback"}, url: panel_personal_conference_desktop_conference_pages_path do |f| %> <%= form_for @writing_conference, html: { multipart: true, "form-type"=>"ajax_form", "callback-method"=>"formCallback"}, url: panel_personal_conference_desktop_conference_pages_path do |f| %>
<%= render partial: 'form', locals: {:f => f} %> <%= render partial: 'form', locals: {:f => f} %>
<%end%> <%end%>

View File

@ -26,8 +26,8 @@ FactoryGirl.define do
"#{data_json[n]["year"]}" "#{data_json[n]["year"]}"
end end
f.sequence(:authors) do |n| f.sequence(:author_tokens) do |n|
"#{data_json[n]["author"].map{|m| m.split(",").reverse.join(" ")}.join(",")}" "#{data_json[n]["author"].map{|m| m.split(",").reverse.map(&:strip).join(" ")}.join(",")}"
end end
#f.sequence(:form_to_start) do |n| #f.sequence(:form_to_start) do |n|

View File

@ -1,117 +1,231 @@
orbitDesktop.prototype.initializeJournalPapers = function(target,url,cache){ // this init journal papers orbitDesktop.prototype.initializeJournalPapers = function(target,url,cache){ // this init journal papers
this.initializeJournalPapers.formCallback = function(data){ this.initializeJournalPapers.formCallback = function(data){
if(data.success){ if(data.success){
o.notify(data.msg,"success"); o.notify(data.msg,"success");
o.sub_menu_item($("div[content-type=menu] a").eq(0)); o.sub_menu_item($("div[content-type=menu] a").eq(0));
}else{ }else{
o.notify(data.msg,"alert"); o.notify(data.msg,"alert");
} }
}
this.initializeJournalPapers.list = function(){ // to open list part in journal papers page
var journalData;
var bindHandlers = function(){ // to bind handlers for list page
o.simple_drop_down();
} }
this.initializeJournalPapers.list = function(){ // to open list part in journal papers page var bindSecondaryHandlers = function(){
var journalData; $("#journal_p div#paper_list a.icon-check-empty").click(function(){
var bindHandlers = function(){ // to bind handlers for list page if($(this).hasClass("icon-check-empty")){
o.simple_drop_down(); $(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.initializeJournalPapers.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(){ this.initializeJournalPapers.cancelpaper = function(){
$("#journal_p div#paper_list a.icon-check-empty").click(function(){ o.highlight_sub_menu_item(0);
if($(this).hasClass("icon-check-empty")){ }
$(this).switchClass("icon-check-empty","icon-check",0);
} else if($(this) .hasClass("icon-check")) { this.initializeJournalPapers.editpaper = function(){
$(this).switchClass("icon-check","icon-check-empty",0); o.highlight_sub_menu_item(1);
} else if($(this).hasClass("icon-star")){ var uploadFiles = function(){
$(this).removeClass("icon-star").addClass("icon-star-empty"); $('#add_plugin_file a.add').click(function(){
} else if($(this).hasClass("icon-star-empty")){ var new_id = $(this).prev().attr('value');
$(this).removeClass("icon-star-empty").addClass("icon-star"); var old_id = new RegExp("new_writing_journal_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();
});
}
var tokesplits = function(){
$("#writing_journal_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 false; return markup;
}) },
} ajax: {
} url: "/panel/personal_journal/desktop/journal_pages/new.json",
this.initializeJournalPapers.paperDelete = function(data,dom){ dataType: 'json',
var parent = dom.parent().parent(); quietMillis: 100,
if(data.success){ tokenSeparators: [","],
parent.hide("slide",function(){parent.remove();}); data: function (search, page) {
o.notify(data.msg,"success"); return {q: search};
} },
results: function (data, page) {
return {results: data.results};
}
},
});
$("#writing_journal_author_tokens").select2("container").find("ul.select2-choices").sortable({
containment: 'parent',
start: function() { $("#writing_journal_author_tokens").select2("onSortStart"); },
update: function() { $("#writing_journal_author_tokens").select2("onSortEnd"); }
});
} }
this.initializeJournalPapers.editpaper = function(){ var preData = function(){
o.highlight_sub_menu_item(1) $("#writing_journal_author_tokens").select2('data', JSON.parse($("#writing_journal_author_tokens").attr('data-pre')));
} }
this.initializeJournalPapers.addpaper = function(){ // to open add pages in journal papers page uploadFiles();
var bindHandlers = function(){ // to bind handlers for add page tokesplits();
o.simple_drop_down(); preData();
$('#add_plugin_file a.add').click(function(){ }
var new_id = $(this).prev().attr('value');
var old_id = new RegExp("new_writing_journal_files", "g"); this.initializeJournalPapers.addpaper = function(){ // to open add pages in journal papers page
$(this).prev().attr('value', parseInt(new_id) + 1); var uploadFiles = function(){
var x = get_html(old_id,new_id); $('#add_plugin_file a.add').click(function(){
var newfield = $(x); var new_id = $(this).prev().attr('value');
$(this).parents('table').append(newfield); var old_id = new RegExp("new_writing_journal_files", "g");
newfield.find('.action a.delete').click(function(){ $(this).prev().attr('value', parseInt(new_id) + 1);
newfield.remove(); var x = get_html(old_id,new_id);
}); var newfield = $(x);
return false; $(this).parents('table').append(newfield);
newfield.find('.action a.delete').click(function(){
newfield.remove();
}); });
return false;
});
$('.action a.remove_existing_record').click(function(){ $('.action a.remove_existing_record').click(function(){
$(this).next('.should_destroy').attr('value', 1); $(this).next('.should_destroy').attr('value', 1);
$("tr#add_plugin_file_" + $(this).prev().attr('value')).hide(); $("tr#add_plugin_file_" + $(this).prev().attr('value')).hide();
}); });
}
bindHandlers();
} }
this.initializeJournalPapers.journal = function(){ // to open add pages in journal papers page console.log("hi");
var bindHandlers = function(){ // to bind handlers for add page var bindHandlers = function(){
o.simple_drop_down(); o.simple_drop_down();
}
bindHandlers();
} }
this.initializeJournalPapers.coAuthorformCallback = function(data){ var tokesplits = function(){
if(data.success){ $("#writing_journal_author_tokens").select2({
o.notify(data.msg,"success"); multiple: true,
o.sub_menu_item($("div[content-type=menu] a").eq(3)); minimumInputLength: 1,
}else{ width: "300px;",
o.notify(data.msg,"alert"); formatResult: function movieFormatResult(coAuthor, container, query, escapeMarkup) {
} 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_journal/desktop/journal_pages/new.json",
dataType: 'json',
quietMillis: 100,
tokenSeparators: [","],
data: function (search, page) {
return {q: search};
},
results: function (data, page) {
return {results: data.results};
}
},
});
$("#writing_journal_author_tokens").select2("container").find("ul.select2-choices").sortable({
containment: 'parent',
start: function() { $("#writing_journal_author_tokens").select2("onSortStart"); },
update: function() { $("#writing_journal_author_tokens").select2("onSortEnd"); }
});
}
bindHandlers();
uploadFiles();
tokesplits();
}
this.initializeJournalPapers.journal = function(){ // to open add pages in journal papers page
var bindHandlers = function(){ // to bind handlers for add page
o.simple_drop_down();
}
bindHandlers();
}
this.initializeJournalPapers.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.initializeJournalPapers.coauthor = function(){ // to open add pages in coauthor page
var bindHandlers = function(){ // to bind handlers for add page
o.simple_drop_down();
} }
this.initializeJournalPapers.coauthor = function(){ // to open add pages in coauthor page
var bindHandlers = function(){ // to bind handlers for add page
o.simple_drop_down();
}
bindHandlers(); bindHandlers();
} }
this.initializeJournalPapers.coauthorRelationForm = function(data){ this.initializeJournalPapers.coauthorRelationForm = function(data){
if(data.success){ if(data.success){
o.notify(data.msg,"success"); o.notify(data.msg,"success");
$("#co_author_relation_table").html(data.newvalue); $("#co_author_relation_table").html(data.newvalue);
}else{ }else{
o.notify(data.msg,"alert"); o.notify(data.msg,"alert");
} }
} }
this.initializeJournalPapers.coauthorRelationEditForm = function(data){ this.initializeJournalPapers.coauthorRelationEditForm = function(data){
if(data.success){ if(data.success){
o.notify(data.msg,"success"); o.notify(data.msg,"success");
$("#co_author_relation_table").html(data.newvalue); $("#co_author_relation_table").html(data.newvalue);
}else{ }else{
o.notify(data.msg,"alert"); o.notify(data.msg,"alert");
} }
} }
this.initializeJournalPapers.allnone = function(d,o){ this.initializeJournalPapers.allnone = function(d,o){
switch(o.attr("href")){ switch(o.attr("href")){
case "all": case "all":
$("div.overview a.icon-check-empty").removeClass("icon-check-empty").addClass("icon-check"); $("div.overview a.icon-check-empty").removeClass("icon-check-empty").addClass("icon-check");
break; break;
case "none": case "none":
$("div.overview a.icon-check").removeClass("icon-check").addClass("icon-check-empty"); $("div.overview a.icon-check").removeClass("icon-check").addClass("icon-check-empty");
break; break;
} }
} }
}; };

View File

@ -28,7 +28,7 @@ class Panel::PersonalJournal::Desktop::JournalCoAuthorRelationsController < Appl
if @journal_co_author_relation.save if @journal_co_author_relation.save
newv = render_to_string partial: "show_form", object: @journal_co_author_relations newv = render_to_string partial: "show_form", object: @journal_co_author_relations
render json: {success: true, msg: "create_success", newvalue: newv}.to_json render json: {success: true, msg: t("create_success"), newvalue: newv}.to_json
else else
error_msg = @journal_co_author_relation.errors.full_messages.join("<br />") error_msg = @journal_co_author_relation.errors.full_messages.join("<br />")
render json: {success: false, msg: error_msg}.to_json render json: {success: false, msg: error_msg}.to_json
@ -40,7 +40,7 @@ class Panel::PersonalJournal::Desktop::JournalCoAuthorRelationsController < Appl
if @journal_co_author_relation.update_attributes(params[:journal_co_author_relation]) if @journal_co_author_relation.update_attributes(params[:journal_co_author_relation])
@journal_co_author_relations = JournalCoAuthorRelation.all @journal_co_author_relations = JournalCoAuthorRelation.all
newv = render_to_string partial: "show_form", object: @journal_co_author_relations newv = render_to_string partial: "show_form", object: @journal_co_author_relations
render json: {success: true, msg: "update_success", newvalue: newv}.to_json render json: {success: true, msg: t("update_success"), newvalue: newv}.to_json
else else
error_msg = @journal_co_author.errors.full_messages.join("<br />") error_msg = @journal_co_author.errors.full_messages.join("<br />")
render json: {success: false, msg: error_msg}.to_json render json: {success: false, msg: error_msg}.to_json

View File

@ -26,24 +26,26 @@ class Panel::PersonalJournal::Desktop::JournalPagesController < ApplicationContr
@level_types = JournalLevelType.all @level_types = JournalLevelType.all
@author_types = JournalAuthorType.all @author_types = JournalAuthorType.all
@paper_types= JournalPaperType.all @paper_types= JournalPaperType.all
#@journal_co_author_candidate =
# JournalCoAuthor.where(name_id: current_user.id).map{|c|c.co_author}
@journal_candidate = @journal_candidate =
WritingJournal.where(create_user_id: current_user.id).map{|j|j.journal_title}.uniq WritingJournal.where(create_user_id: current_user.id).map{|j|j.journal_title}.uniq
if (not params[:q].nil?) and (current_user.name.include?params[:q]) 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 else
@user = [] @user = []
end end
@co_authors = JournalCoAuthor.where(name_id: current_user.id, :co_author => /#{params[:q]}/) @co_authors = JournalCoAuthor.where(name_id: current_user.id, :co_author => /#{params[:q]}/).asc(:co_author)
@co_authors = [{ :id => params[:q], :name => params[:q] }] + # search string
@user + # self account name # search string + self account name + match pattern
@co_authors.map{|m| { :id => m.id, :name => m.co_author } } # 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| respond_to do |format|
format.html { render :layout => false} format.html { render :layout => false}
format.json { render :json => @co_authors.to_json } format.json { render :json => {:results => @co_authors}.to_json }
end end
end end

View File

@ -84,9 +84,11 @@ module Panel::PersonalJournal::Desktop::JournalPagesHelper
def generate_authors_name ids def generate_authors_name ids
author_name = ids.map{|m| author_name = ids.map{|m|
if m == "0" 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 else
{:id => m, :name => ConferenceCoAuthor.find(m).co_author} #{:id => m, :text => JournalCoAuthor.find(m).co_author, :email => JournalCoAuthor.find(m).email}
{:id => m, :text => JournalCoAuthor.find(m).co_author}
end end
} }

View File

@ -37,18 +37,24 @@ class WritingJournal
after_save :save_writing_journal_files after_save :save_writing_journal_files
before_validation :add_http before_validation :add_http
#before_save :save_co_author #before_save :save_co_author
before_save :update_co_author
validates :paper_title, :at_least_one => true validates :paper_title, :at_least_one => true
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?} 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 attr_reader :author_tokens
def author_tokens=(ids) def author_tokens=(ids)
if new_record?
current_user = create_user_id
else
current_user = update_user_id
end
authors_ids = ids.split(",").map{|id| authors_ids = ids.split(",").map{|id|
begin begin
JournalCoAuthor.find(m).id JournalCoAuthor.find(id).id
rescue rescue
if id != "0" if id != "0"
new_co_author = JournalCoAuthor.new(:co_author => id, :name_id => create_user_id) new_co_author = JournalCoAuthor.new(:co_author => id)
new_co_author.save new_co_author.save
new_co_author.id new_co_author.id
else else
@ -58,6 +64,19 @@ class WritingJournal
} }
self.journal_co_author_ids = authors_ids self.journal_co_author_ids = authors_ids
end end
def update_co_author
if new_record?
current_user = self.create_user_id
else
current_user = self.update_user_id
end
self.journal_co_author_ids.each do |id|
co_author = JournalCoAuthor.find(id)
co_author.update_attribute(:name_id, current_user)
end
end
# old method # old method
#def save_co_author #def save_co_author
# authors_list = authors.split(",").map{|n| n.strip.gsub(/\s+/," ")}.reject{|n| n.empty? } # authors_list = authors.split(",").map{|n| n.strip.gsub(/\s+/," ")}.reject{|n| n.empty? }

View File

@ -7,5 +7,5 @@
--> -->
<%= f.submit t("save"), class: "ini_input hp hh1 thmtxt thmc2", style: "margin-left: 10px;" %> <%= f.submit t("save"), class: "ini_input hp hh1 thmtxt thmc2", style: "margin-left: 10px;" %>
<% if not @journal_co_author_relation.new_record? %> <% if not @journal_co_author_relation.new_record? %>
<%= submit_tag t("back"), :type => "button", class: "bt-cancel-type ini_input hp hh1 thmtxt" %> <%= submit_tag t("cancel"), :type => "button", class: "bt-cancel-type ini_input hp hh1 thmtxt" %>
<% end %> <% end %>

View File

@ -3,7 +3,7 @@
<%= f.submit t("save"), name: "commit", class: "fn_btn ini_input hp hh1 thmc2 thmtxt" %> <%= f.submit t("save"), name: "commit", class: "fn_btn ini_input hp hh1 thmc2 thmtxt" %>
<% if not @writing_journal.new_record? %> <% if not @writing_journal.new_record? %>
<%= submit_tag t("cancel"), :type => "button", "ajax-remote" => "get", :href => panel_personal_journal_desktop_journal_pages_path, class: "ini_input hp hh1 thmadm thmtxt" %> <%= submit_tag t("cancel"), :type => "button", "callback-method"=>"cancelpaper", "ajax-remote" => "get", :href => panel_personal_journal_desktop_journal_pages_path, class: "ini_input hp hh1 thmadm thmtxt" %>
<% end %> <% end %>
</div> </div>
@ -99,7 +99,6 @@
<div class="s_form"> <div class="s_form">
<ul> <ul>
<li class="s_grid_row"> <li class="s_grid_row">
<%= f.label :author_tokens, t("personal_journal.authors") %><br />
<%= f.text_area :author_tokens, <%= f.text_area :author_tokens,
class: "s_grid_6 s_grid", class: "s_grid_6 s_grid",
size: "20x2", size: "20x2",
@ -230,19 +229,6 @@
<!-- </div> <!-- </div>
</div> </div>
--> -->
<script>
$(document).ready(function(){
$("#writing_conference_author_tokens").tokenInput("/panel/personal_conference/desktop/conference_pages/new.json", {
crossDomain: false,
prePopulate: $("#writing_conference_author_tokens").data("pre"),
theme: "facebook",
hintText: "<%=t("hintText")%>",
noResultsText: "<%=t("noResultsText")%>",
searchingText: "<%=t("searchingText")%>"
});
});
</script>
<script type="text/javascript"> <script type="text/javascript">
orbitDesktop.prototype.initializeJournalPapers.journal_title_autocomplete_list = <%= @journal_candidate.to_json.html_safe %>; orbitDesktop.prototype.initializeJournalPapers.journal_title_autocomplete_list = <%= @journal_candidate.to_json.html_safe %>;
// orbitDesktop.prototype.initializeJournalPapers.coauthor_autocomplete_list = <%= @co_author_candidate.to_json.html_safe %>; // orbitDesktop.prototype.initializeJournalPapers.coauthor_autocomplete_list = <%= @co_author_candidate.to_json.html_safe %>;

View File

@ -1,3 +1,3 @@
<%= form_for @writing_journal, html: { multipart: true, "form-type"=>"ajax_form", "callback-method"=>"addpaper"}, url: panel_personal_journal_desktop_journal_page_path(@writing_journal) do |f| %> <%= form_for @writing_journal, html: { multipart: true, "form-type"=>"ajax_form", "callback-method"=>"formCallback"}, url: panel_personal_journal_desktop_journal_page_path(@writing_journal) do |f| %>
<%= render partial: 'form', locals: {:f => f} %> <%= render partial: 'form', locals: {:f => f} %>
<%end%> <%end%>

View File

@ -13,7 +13,6 @@
<div class="sdm_t hh1"><span class="icon-question-sign"></span></div> <div class="sdm_t hh1"><span class="icon-question-sign"></span></div>
</div> </div>
</div> </div>
<div class="overview" content-layout="datalist" base-width="300" per-column="5"> <div class="overview" content-layout="datalist" base-width="300" per-column="5">
<% @journal_lists.each_with_index do |journal_list,i| %> <% @journal_lists.each_with_index do |journal_list,i| %>
<div class="g_col"> <div class="g_col">

View File

@ -30,8 +30,8 @@ FactoryGirl.define do
"#{data_json[n]["year"]}" "#{data_json[n]["year"]}"
end end
f.sequence(:authors) do |n| f.sequence(:author_tokens) do |n|
"#{data_json[n]["author"].map{|m| m.split(",").reverse.join(" ")}.join(",")}" "#{data_json[n]["author"].map{|m| m.split(",").reverse.map(&:strip).join(" ")}.join(",")}"
end end
f.sequence(:form_to_start) do |n| f.sequence(:form_to_start) do |n|