From bb69a059e89f158c365ca7e5b688c7188acc9f24 Mon Sep 17 00:00:00 2001 From: Rueshyna Date: Thu, 22 Nov 2012 02:37:56 +0800 Subject: [PATCH 1/6] hidden file field, and fixed updated function --- .../javascripts/desktop/journal_pages.js.erb | 2 +- .../desktop/journal_pages_controller.rb | 33 ++++++++------- .../desktop/journal_pages/_form.html.erb | 41 ++++++++++++------- app/views/desktop/journal_pages/edit.html.erb | 2 +- app/views/desktop/journal_pages/new.html.erb | 2 +- 5 files changed, 45 insertions(+), 35 deletions(-) diff --git a/app/assets/javascripts/desktop/journal_pages.js.erb b/app/assets/javascripts/desktop/journal_pages.js.erb index 0bb9063d..2c6821da 100644 --- a/app/assets/javascripts/desktop/journal_pages.js.erb +++ b/app/assets/javascripts/desktop/journal_pages.js.erb @@ -228,4 +228,4 @@ orbitDesktop.prototype.initializeJournalPapers = function(target,url,cache){ // } - }; \ No newline at end of file + }; diff --git a/app/controllers/desktop/journal_pages_controller.rb b/app/controllers/desktop/journal_pages_controller.rb index 14397814..b389dca6 100644 --- a/app/controllers/desktop/journal_pages_controller.rb +++ b/app/controllers/desktop/journal_pages_controller.rb @@ -35,32 +35,24 @@ class Desktop::JournalPagesController < ApplicationController end def create - params[:writing_journal][:create_user_id] = current_user.id - @writing_journal = WritingJournal.new(params[:writing_journal]) - respond_to do |format| - if @writing_journal.save - format.json {render json: {success: true, msg: "Paper successfully saved!"}.to_json} - else - format.json {render json: {success: false, msg: "Saving failed!"}.to_json } - end + + if @writing_journal.save + render json: {success: true, msg: "Paper successfully saved!"}.to_json + else + render json: {success: false, msg: "Saving failed!"}.to_json end - end def update - if params[:commit].eql?"Save" - @writing_journal= WritingJournal.find(params[:id]) - end - + params[:writing_journal][:update_user_id] = current_user.id + @writing_journal= WritingJournal.find(params[:id]) respond_to do |format| if @writing_journal.update_attributes(params[:writing_journal]) - format.html { redirect_to desktop_journal_pages_url, :layout => false, notice: 'User was successfully updated.'} - format.json { head :no_content } + render json: {success: true, msg: "Paper successfully saved!"}.to_json else - format.html { render action: "edit" } - format.json { render json: @user.errors, status: :unprocessable_entity } + render json: {success: false, msg: "Saving failed!"}.to_json end end end @@ -117,4 +109,11 @@ class Desktop::JournalPagesController < ApplicationController render json: JSON.pretty_generate(data) end + + private + + def check_for_cancel + if params[:commit] == "Cancel" + end + end end diff --git a/app/views/desktop/journal_pages/_form.html.erb b/app/views/desktop/journal_pages/_form.html.erb index 6acea10d..3d44ec8f 100644 --- a/app/views/desktop/journal_pages/_form.html.erb +++ b/app/views/desktop/journal_pages/_form.html.erb @@ -1,8 +1,17 @@ +<% if @writing_journal.errors.any? %> +
+

<%= pluralize(@writing_journal.errors.count, "error") %> prohibited this user from being saved:

+ +
+<% end %>
<%= f.submit "Save", name: "commit", value: "Save", class: "fn_btn hh2 thmc2 thmtxt" %> - <%#= button_tag "Cancel", name: "cancel", value: "Cancel", class: "fn_btn hh2 thmc2 thmtxt" %> - <%= content_tag(:button, "Cancel", :class=>"fn_btn hh2 bt-cancel thmc2 thmtxt") %> +
Entry Year
@@ -49,10 +58,10 @@
  • - <%= f.text_area :paper_title, size: "20x2", value: "Paper Title", class: "s_grid_6 s_grid"%> + <%= f.text_area :paper_title, size: "20x2", value: @writing_journal.paper_title ||= "Paper Title", class: "s_grid_6 s_grid"%>
  • - <%= f.text_field :journal_title, size: "20" ,value: "Journal Title", class: "s_grid_6 s_grid"%> + <%= f.text_field :journal_title, size: "20" ,value: @writing_journal.journal_title ||= "Journal Title", class: "s_grid_6 s_grid"%>
  • @@ -86,34 +95,34 @@
  • - <%= label_tag("", "ISSN(ISBN)", class: "s_grid_2 s_grid") %><%= f.text_field :isbn, size: "20" ,value: "829872987", class: "s_grid_4 s_grid"%> + <%= label_tag("", "ISSN(ISBN)", class: "s_grid_2 s_grid") %><%= f.text_field :isbn, size: "20" ,value: @writing_journal.isbn ||= "829872987", class: "s_grid_4 s_grid"%>
  • - <%= label_tag("", "Volume No.", class: "s_grid_2 s_grid") %><%= f.text_field :vol_no, size: "20" ,value: "829872987", class: "s_grid_4 s_grid"%> + <%= label_tag("", "Volume No.", class: "s_grid_2 s_grid") %><%= f.text_field :vol_no, size: "20" ,value: @writing_journal.vol_no ||= "829872987", class: "s_grid_4 s_grid"%>
  • - <%= label_tag("", "Issue No.", class: "s_grid_2 s_grid") %><%= f.text_field :issue_no, size: "20" ,value: "829872987", class: "s_grid_4 s_grid"%> + <%= label_tag("", "Issue No.", class: "s_grid_2 s_grid") %><%= f.text_field :issue_no, size: "20" ,value: @writing_journal.issue_no ||= "829872987", class: "s_grid_4 s_grid"%>
  • - <%= label_tag("", "Total Pages", class: "s_grid_2 s_grid") %><%= f.text_field :total_pages, size: "20" ,value: "20", class: "s_grid_4 s_grid"%> + <%= label_tag("", "Total Pages", class: "s_grid_2 s_grid") %><%= f.text_field :total_pages, size: "20" ,value: @writing_journal.total_pages ||= "20", class: "s_grid_4 s_grid"%>
  • - <%= label_tag("", "Pages", class: "s_grid_2 s_grid") %><%= label_tag("", "from", class: "s_grid_1 s_grid") %><%= f.text_field :form_to_start, size: "10" ,value: "1", class: "s_grid_1 s_grid"%><%= label_tag("", "to", class: "s_grid_1 s_grid") %><%= f.text_field :form_to_end, size: "10" ,value: "20", class: "s_grid_1 s_grid"%> + <%= label_tag("", "Pages", class: "s_grid_2 s_grid") %><%= label_tag("", "from", class: "s_grid_1 s_grid") %><%= f.text_field :form_to_start, size: "10" ,value: @writing_journal.form_to_start ||= "1", class: "s_grid_1 s_grid"%><%= label_tag("", "to", class: "s_grid_1 s_grid") %><%= f.text_field :form_to_end, size: "10" ,value: @writing_journal.form_to_end ||= "20", class: "s_grid_1 s_grid"%>
  • - <%= label_tag("", "Reference URL", class: "s_grid_2 s_grid") %><%= f.text_field :url, size: "20" ,value: "www.sample.com", class: "s_grid_4 s_grid"%> + <%= label_tag("", "Reference URL", class: "s_grid_2 s_grid") %><%= f.text_field :url, size: "20" ,value: @writing_journal.url ||= "www.sample.com", class: "s_grid_4 s_grid"%>
  • - <%= f.text_area :authors, size: "20x2", value: "Authors", class: "s_grid_6 s_grid"%> + <%= f.text_area :authors, size: "20x2", value: @writing_journal.authors ||= "Authors", class: "s_grid_6 s_grid"%>
  • @@ -148,7 +157,7 @@
  • - <%= f.text_field :keyword, size: "20", value: "Keywords", class: "s_grid_6 s_grid"%> + <%= f.text_field :keywords, size: "20", value: @writing_journal.keywords ||= "Keywords", class: "s_grid_6 s_grid"%>
  • @@ -178,19 +187,21 @@
    • <%= label_tag("", "Full Text", class: "s_grid_2 s_grid") %>
      - <%= f.fields_for :writing_journal_files,@writing_journal do |wjf| %> +
    • - <%= f.text_area :note, size: "20x2", value: "Note", class: "s_grid_6 s_grid"%> + <%= f.text_area :note, size: "20x2", value: @writing_journal.note ||= "Note", class: "s_grid_6 s_grid"%>
  • - <%= f.text_area :abstract, size: "20x26", value: "Abstract", class: "s_grid_6 s_grid"%> + <%= f.text_area :abstract, size: "20x26", value: @writing_journal.abstract ||= "Abstract", class: "s_grid_6 s_grid"%>
diff --git a/app/views/desktop/journal_pages/edit.html.erb b/app/views/desktop/journal_pages/edit.html.erb index 1377af92..80d8ae2e 100644 --- a/app/views/desktop/journal_pages/edit.html.erb +++ b/app/views/desktop/journal_pages/edit.html.erb @@ -1,3 +1,3 @@ -<%= form_for @writing_journal, url: desktop_journal_page_path(@writing_journal),html: { multipart: true ,"form-type"=>"ajax_form", "callback-method"=>"formCallback"} do |f| %> +<%= form_for @writing_journal, html: { multipart: true, "form-type"=>"ajax_form", "callback-method"=>"formCallback"}, url: desktop_journal_page_path(@writing_journal) do |f| %> <%= render partial: 'desktop/journal_pages/form', locals: {:f => f} %> <%end%> diff --git a/app/views/desktop/journal_pages/new.html.erb b/app/views/desktop/journal_pages/new.html.erb index d5f5557b..c872e7cf 100644 --- a/app/views/desktop/journal_pages/new.html.erb +++ b/app/views/desktop/journal_pages/new.html.erb @@ -1,3 +1,3 @@ -<%= form_for @writing_journal, html: { multipart: true, "form-type"=>"ajax_form", "callback-method"=>"formCallback"} , url: desktop_journal_pages_path do |f| %> +<%= form_for @writing_journal, html: { multipart: true, "form-type"=>"ajax_form", "callback-method"=>"formCallback"}, url: desktop_journal_pages_path do |f| %> <%= render partial: 'desktop/journal_pages/form', locals: {:f => f} %> <%end%> From 9e400e6e6a581e4e95b6d03daf09c558b5258b97 Mon Sep 17 00:00:00 2001 From: Rueshyna Date: Thu, 22 Nov 2012 10:49:54 +0800 Subject: [PATCH 2/6] fixed add journal and co-author curd problem, but have redirect problem... --- .../javascripts/desktop/journal_pages.js.erb | 1 - .../desktop/co_authors_controller.rb | 18 +++++++----------- .../desktop/journal_pages_controller.rb | 17 +++++++++-------- app/views/desktop/co_authors/_form.html.erb | 15 ++------------- app/views/desktop/co_authors/edit.html.erb | 2 +- app/views/desktop/co_authors/new.html.erb | 2 +- app/views/desktop/journal_pages/_form.html.erb | 10 ---------- 7 files changed, 20 insertions(+), 45 deletions(-) diff --git a/app/assets/javascripts/desktop/journal_pages.js.erb b/app/assets/javascripts/desktop/journal_pages.js.erb index 2c6821da..139f94fc 100644 --- a/app/assets/javascripts/desktop/journal_pages.js.erb +++ b/app/assets/javascripts/desktop/journal_pages.js.erb @@ -1,6 +1,5 @@ orbitDesktop.prototype.initializeJournalPapers = function(target,url,cache){ // this init journal papers this.initializeJournalPapers.formCallback = function(data){ - if(data.success){ o.notify(data.msg,"success"); o.sub_menu_item($("div[content-type=menu] a").eq(0)); }else{ diff --git a/app/controllers/desktop/co_authors_controller.rb b/app/controllers/desktop/co_authors_controller.rb index 9b0d3bd1..1c74314e 100644 --- a/app/controllers/desktop/co_authors_controller.rb +++ b/app/controllers/desktop/co_authors_controller.rb @@ -36,24 +36,20 @@ class Desktop::CoAuthorsController < ApplicationController @co_author = CoAuthor.new(params[:co_author]) @co_author.name_id= current_user.id - if @writing_journal.save - render :json => {success:true, msg: "Paper successfully saved!"}.to_json + if @co_author.save + render json: {success:true, msg: "Co-author successfully saved!"}.to_json else - render :json => {success:false, msg: "Saving failed!"} + render json: {success: false, msg: @co_author.errors.full_messages}.to_json end end def update @co_author = CoAuthor.find(params[:id]) - respond_to do |format| - if @co_author.update_attributes(params[:co_author]) - format.html { redirect_to desktop_co_authors_url, notice: 'CoAuthor was successfully updated.' } - format.json { head :no_content } - else - format.html { render action: "edit" } - format.json { render json: @co_author.errors, status: :unprocessable_entity } - end + if @co_author.update_attributes(params[:co_author]) + render json: {success:true, msg: "Co-author successfully update!"}.to_json + else + render json: {success: false, msg: @co_author.errors.full_messages}.to_json end end diff --git a/app/controllers/desktop/journal_pages_controller.rb b/app/controllers/desktop/journal_pages_controller.rb index b389dca6..b6acd5d4 100644 --- a/app/controllers/desktop/journal_pages_controller.rb +++ b/app/controllers/desktop/journal_pages_controller.rb @@ -1,4 +1,5 @@ class Desktop::JournalPagesController < ApplicationController + #before_filter :check_for_cancel, :only => [:create, :update] def index @writing_journal = WritingJournal.where(create_user_id: current_user.id) @@ -35,14 +36,14 @@ class Desktop::JournalPagesController < ApplicationController end def create - params[:writing_journal][:create_user_id] = current_user.id - @writing_journal = WritingJournal.new(params[:writing_journal]) + params[:writing_journal][:create_user_id] = current_user.id + @writing_journal = WritingJournal.new(params[:writing_journal]) - if @writing_journal.save - render json: {success: true, msg: "Paper successfully saved!"}.to_json - else - render json: {success: false, msg: "Saving failed!"}.to_json - end + if @writing_journal.save + render json: {success: true, msg: "Paper successfully saved!"}.to_json + else + render json: {success: false, msg: @writing_journal.errors.full_messages}.to_json + end end def update @@ -52,7 +53,7 @@ class Desktop::JournalPagesController < ApplicationController if @writing_journal.update_attributes(params[:writing_journal]) render json: {success: true, msg: "Paper successfully saved!"}.to_json else - render json: {success: false, msg: "Saving failed!"}.to_json + render json: {success: false, msg: @writing_journal.errors.full_messages}.to_json end end end diff --git a/app/views/desktop/co_authors/_form.html.erb b/app/views/desktop/co_authors/_form.html.erb index 22b8433e..e5d9e8ff 100644 --- a/app/views/desktop/co_authors/_form.html.erb +++ b/app/views/desktop/co_authors/_form.html.erb @@ -1,17 +1,6 @@ -<% if @co_author.errors.any? %> -
-

<%= pluralize(@co_author.errors.count, "error") %> prohibited this user from being saved:

-
    - <% @co_author.errors.full_messages.each do |msg| %> -
  • <%= msg %>
  • - <% end %> -
-
-<% end %>
- - <%= button_tag "Save", name: "commit", value: "Save", class: "fn_btn hh2 thmc2 thmtxt" %> - <%= button_tag "Cancel", name: "commit", value: "Cancel", class: "fn_btn hh2 thmc2 thmtxt" %> + <%= f.submit "Save", name: "commit", value: "Save", class: "fn_btn hh2 thmc2 thmtxt" %> +
diff --git a/app/views/desktop/co_authors/edit.html.erb b/app/views/desktop/co_authors/edit.html.erb index 2f48f4c5..015f6321 100644 --- a/app/views/desktop/co_authors/edit.html.erb +++ b/app/views/desktop/co_authors/edit.html.erb @@ -1,3 +1,3 @@ -<%= form_for @co_author, url: desktop_co_author_path(@co_author) do |f| %> +<%= form_for @co_author, html: { multipart: true ,"form-type"=>"ajax_form", "callback-method"=>"coAuthorformCallback"} , url: desktop_co_author_path(@co_author) do |f| %> <%= render partial: 'desktop/co_authors/form', locals: {:f => f} %> <% end %> diff --git a/app/views/desktop/co_authors/new.html.erb b/app/views/desktop/co_authors/new.html.erb index c794f218..1a4ec2d5 100644 --- a/app/views/desktop/co_authors/new.html.erb +++ b/app/views/desktop/co_authors/new.html.erb @@ -1,3 +1,3 @@ -<%= form_for @co_author, html: { multipart: true ,:type=>"ajax_form", "callback-method"=>"coAuthorformCallback"} , url: desktop_co_authors_path do |f| %> +<%= form_for @co_author, html: { multipart: true ,"form-type"=>"ajax_form", "callback-method"=>"coAuthorformCallback"} , url: desktop_co_authors_path do |f| %> <%= render partial: 'desktop/co_authors/form', locals: {:f => f} %> <% end %> diff --git a/app/views/desktop/journal_pages/_form.html.erb b/app/views/desktop/journal_pages/_form.html.erb index 3d44ec8f..223bea04 100644 --- a/app/views/desktop/journal_pages/_form.html.erb +++ b/app/views/desktop/journal_pages/_form.html.erb @@ -1,13 +1,3 @@ -<% if @writing_journal.errors.any? %> -
-

<%= pluralize(@writing_journal.errors.count, "error") %> prohibited this user from being saved:

-
    - <% @writing_journal.errors.full_messages.each do |msg| %> -
  • <%= msg %>
  • - <% end %> -
-
-<% end %>
<%= f.submit "Save", name: "commit", value: "Save", class: "fn_btn hh2 thmc2 thmtxt" %> From e453cfce9cb91803d1e034fc2aef871cb97c24bc Mon Sep 17 00:00:00 2001 From: Rueshyna Date: Thu, 22 Nov 2012 15:21:43 +0800 Subject: [PATCH 3/6] add delete link --- app/controllers/desktop/journal_pages_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/desktop/journal_pages_controller.rb b/app/controllers/desktop/journal_pages_controller.rb index b6acd5d4..6aa8c7fd 100644 --- a/app/controllers/desktop/journal_pages_controller.rb +++ b/app/controllers/desktop/journal_pages_controller.rb @@ -94,10 +94,10 @@ class Desktop::JournalPagesController < ApplicationController { title: publication.paper_title, keywords: publication.keywords, abstract: publication.abstract, - level: publication.journal_paper_type_id, coauthors: publication.authors, year: publication.year, url_edit: edit_desktop_journal_page_path(publication), + url_delete: desktop_journal_page_path(publication), files: publication.writing_journal_files.collect{|file| {title: file.title, url: file.file.url, icon: check_file_type(file.file.url)} } From 90fd9de5a8f47b94fe2e1a07dc68f0614a216f55 Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Thu, 22 Nov 2012 16:31:37 +0800 Subject: [PATCH 4/6] fix for json and some other bugs --- .../javascripts/desktop/journal_pages.js.erb | 1 + app/assets/javascripts/orbitdesktop.js | 57 +++++++++++-------- config/mongoid.yml | 2 +- 3 files changed, 36 insertions(+), 24 deletions(-) diff --git a/app/assets/javascripts/desktop/journal_pages.js.erb b/app/assets/javascripts/desktop/journal_pages.js.erb index 139f94fc..2c6821da 100644 --- a/app/assets/javascripts/desktop/journal_pages.js.erb +++ b/app/assets/javascripts/desktop/journal_pages.js.erb @@ -1,5 +1,6 @@ orbitDesktop.prototype.initializeJournalPapers = function(target,url,cache){ // this init journal papers this.initializeJournalPapers.formCallback = function(data){ + if(data.success){ o.notify(data.msg,"success"); o.sub_menu_item($("div[content-type=menu] a").eq(0)); }else{ diff --git a/app/assets/javascripts/orbitdesktop.js b/app/assets/javascripts/orbitdesktop.js index bf5e35fe..dc183d3d 100755 --- a/app/assets/javascripts/orbitdesktop.js +++ b/app/assets/javascripts/orbitdesktop.js @@ -2,8 +2,10 @@ //harry //Inititialize function will initialize desktop -//callback-method will be called after desktop controlled ajax call; +//callback-method will be called after desktop controlled ajax call //container=true is the area where the view will be loaded +//load = true is used to load the list element by default +//response-type = "json"|"script"|"xml|html" default is json $.extend($.expr[':'], { @@ -88,30 +90,30 @@ var orbitDesktop = function(dom){ o.data_method = $(this).attr("callback-method"); if(o.currenthtml!=target){ if(o.desktopData[o.currentface] == "undefined") - o.desktopData[o.currentface] = ""; - o.desktopData[o.currentface] = $(o.contentHolder).html(); - $("#content").hide("drop",o.transitionTime,function(){ - o.currenthtml = target; - o.currentface = target; - var cache = false; - if(!o.desktopData[o.currentface]){ - $(o.contentHolder).empty().load(url,function(){ - if(typeof o.data_method != "undefined"){ - if(o.data_method != "") - window.o[o.data_method](target,url,cache); + o.desktopData[o.currentface] = ""; + o.desktopData[o.currentface] = $(o.contentHolder).html(); + $("#content").hide("drop",o.transitionTime,function(){ + o.currenthtml = target; + o.currentface = target; + var cache = false; + if(!o.desktopData[o.currentface]){ + $(o.contentHolder).empty().load(url,function(){ + if(typeof o.data_method != "undefined"){ + if(o.data_method != "") + window.o[o.data_method](target,url,cache); + } + o.sub_menu_item($(o.contentHolder).find("*[content-type=menu] a[load=true]")); + }) + }else{ + $(o.contentHolder).html(o.desktopData[o.currentface]); + o.sub_menu_item($(o.contentHolder).find("*[content-type=menu] a[load=true]")); + cache = true; + if(typeof o.data_method != "undefined"){ + if(o.data_method != "") + window.o[o.data_method](target,url,cache); + } } - o.sub_menu_item($(o.contentHolder).find("*[content-type=menu] a[load=true]")); }); - }else{ - $(o.contentHolder).html(o.desktopData[o.currentface]); - o.sub_menu_item($(o.contentHolder).find("*[content-type=menu] a[load=true]").trigger("click")); - cache = true; - if(typeof o.data_method != "undefined"){ - if(o.data_method != "") - window.o[o.data_method](target,url,cache); - } - } - }); } return false; }) @@ -135,13 +137,22 @@ var orbitDesktop = function(dom){ $("body").on("submit","form[form-type=ajax_form]",function(){ var callback_method = $(this).attr("callback-method"); + var dt = null; + dt = $(this).attr("response-type"); + if(dt == null){ + dt = "json"; + } var options = { + dataType : dt, success:function(responseText, statusText, xhr, $form){ if(typeof callback_method != "undefined"){ if(callback_method != ""){ window.o[o.data_method][callback_method](responseText,statusText,xhr,$form); } } + }, + error:function(){ + o.notify("Please try again later!","imp"); } } $(this).ajaxSubmit(options); diff --git a/config/mongoid.yml b/config/mongoid.yml index 75c5ef80..a809bc06 100644 --- a/config/mongoid.yml +++ b/config/mongoid.yml @@ -2,7 +2,7 @@ defaults: &defaults host: localhost # slaves: # - host: slave1.local - port: 37017 + port: 27017 # - host: slave2.local # port: 27019 From 645f25d44667494dfa9ab6afdfb9dfe3ced5af25 Mon Sep 17 00:00:00 2001 From: Rueshyna Date: Thu, 22 Nov 2012 16:34:20 +0800 Subject: [PATCH 5/6] make fake data --- Gemfile | 3 ++- .../javascripts/desktop/journal_pages.js.erb | 1 + config/mongoid.yml | 2 +- db/seeds.rb | 19 +++++++++++++++++++ 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index 30dd9e67..c893a899 100644 --- a/Gemfile +++ b/Gemfile @@ -76,7 +76,8 @@ group :test, :development do gem 'pry-remote' gem 'pry-stack_explorer' gem 'pry-debugger' - + gem 'faker' + gem "sunspot-rails-tester" gem 'spork' gem 'database_cleaner' #Strategies for cleaning databases. Can be used to ensure a clean state for testing. diff --git a/app/assets/javascripts/desktop/journal_pages.js.erb b/app/assets/javascripts/desktop/journal_pages.js.erb index 139f94fc..2c6821da 100644 --- a/app/assets/javascripts/desktop/journal_pages.js.erb +++ b/app/assets/javascripts/desktop/journal_pages.js.erb @@ -1,5 +1,6 @@ orbitDesktop.prototype.initializeJournalPapers = function(target,url,cache){ // this init journal papers this.initializeJournalPapers.formCallback = function(data){ + if(data.success){ o.notify(data.msg,"success"); o.sub_menu_item($("div[content-type=menu] a").eq(0)); }else{ diff --git a/config/mongoid.yml b/config/mongoid.yml index 75c5ef80..a809bc06 100644 --- a/config/mongoid.yml +++ b/config/mongoid.yml @@ -2,7 +2,7 @@ defaults: &defaults host: localhost # slaves: # - host: slave1.local - port: 37017 + port: 27017 # - host: slave2.local # port: 27019 diff --git a/db/seeds.rb b/db/seeds.rb index b53fb7b7..1a909bed 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -32,3 +32,22 @@ end FactoryGirl.create(:custom_record, journal_title_translations: {zh_tw: "tw_test A", en: "en_test A"}) FactoryGirl.create(:custom_record, journal_title_translations: {zh_tw: "tw_test B", en: "en_test B"}) +abstract_file = "./icml2011_abstract" +abstracts = File.open(file).readlines + +bibtex_file = "./icml2011.bibtex" +bibtex = File.open(file).readlines + + +FactoryGirl.define do + factory :paper_record, class: "WritingJournal" do |f| + f.sequence(:paper_title_translations) {|n|{zh_tw: "[tw]_test #{n}", en: "en_test #{n}" }} + f.sequence(:journal_title_translations) {|n| {zh_tw: "tw_test #{n}", en: "en_test #{n}"}} + f.sequence(:keywords) {|n| "keywords #{n}"} + f.sequence(:abstract) {|n| "abstract #{n}"} + f.sequence(:isbn) {|n| "0714312#{n}#{n}#{n}"} + f.sequence(:year) {|n| "201#{n}"} + f.create_user_id BSON::ObjectId('4f45f3b9e9d02c5db9000067') #user_id, this is Chris' account + f.update_user_id BSON::ObjectId('4f45f3b9e9d02c5db9000067') #user_id, this is Chris' account + end +end From 9189ebffeed73a552325434fdaddfa4c3e8c0f9a Mon Sep 17 00:00:00 2001 From: Rueshyna Date: Thu, 22 Nov 2012 18:15:07 +0800 Subject: [PATCH 6/6] correct 'edit' button of journal list --- .../javascripts/desktop/journal_pages.js.erb | 2 +- db/seeds.rb | 19 ------------------- 2 files changed, 1 insertion(+), 20 deletions(-) diff --git a/app/assets/javascripts/desktop/journal_pages.js.erb b/app/assets/javascripts/desktop/journal_pages.js.erb index 2c6821da..cd04499e 100644 --- a/app/assets/javascripts/desktop/journal_pages.js.erb +++ b/app/assets/javascripts/desktop/journal_pages.js.erb @@ -50,7 +50,7 @@ orbitDesktop.prototype.initializeJournalPapers = function(target,url,cache){ // return false; }) - $("div[container=true]").on("click",".journal_paper_edit",function(){ + $("div[container=true]").unbind("click").on("click",".journal_paper_edit",function(){ $.ajax({ url : $(this).attr("href"), type : "get", diff --git a/db/seeds.rb b/db/seeds.rb index 1a909bed..b53fb7b7 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -32,22 +32,3 @@ end FactoryGirl.create(:custom_record, journal_title_translations: {zh_tw: "tw_test A", en: "en_test A"}) FactoryGirl.create(:custom_record, journal_title_translations: {zh_tw: "tw_test B", en: "en_test B"}) -abstract_file = "./icml2011_abstract" -abstracts = File.open(file).readlines - -bibtex_file = "./icml2011.bibtex" -bibtex = File.open(file).readlines - - -FactoryGirl.define do - factory :paper_record, class: "WritingJournal" do |f| - f.sequence(:paper_title_translations) {|n|{zh_tw: "[tw]_test #{n}", en: "en_test #{n}" }} - f.sequence(:journal_title_translations) {|n| {zh_tw: "tw_test #{n}", en: "en_test #{n}"}} - f.sequence(:keywords) {|n| "keywords #{n}"} - f.sequence(:abstract) {|n| "abstract #{n}"} - f.sequence(:isbn) {|n| "0714312#{n}#{n}#{n}"} - f.sequence(:year) {|n| "201#{n}"} - f.create_user_id BSON::ObjectId('4f45f3b9e9d02c5db9000067') #user_id, this is Chris' account - f.update_user_id BSON::ObjectId('4f45f3b9e9d02c5db9000067') #user_id, this is Chris' account - end -end