From 638ed73d21c6ffb410f339da7ccaca416c81f964 Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Thu, 26 Sep 2013 22:26:19 +0800 Subject: [PATCH] added sync for journal paper books and conference.. and also disabled the icons --- .../javascripts/desktop/orbitdesktop.js | 15 +- .../admin/import_data_controller.rb | 144 +++++++++++------- app/views/desktop/index.html.erb | 24 +-- .../personal_book/desktop/personal_books.js | 5 + .../desktop/personal_books_controller.rb | 2 +- .../desktop/personal_books/index.html.erb | 3 + .../desktop/conference_pages.js | 5 +- .../desktop/conference_pages_controller.rb | 2 +- .../desktop/conference_pages/index.html.erb | 3 + .../personal_journal/desktop/journal_pages.js | 4 + .../desktop/journal_pages_controller.rb | 2 +- .../desktop/journal_pages/index.html.erb | 3 + 12 files changed, 131 insertions(+), 81 deletions(-) diff --git a/app/assets/javascripts/desktop/orbitdesktop.js b/app/assets/javascripts/desktop/orbitdesktop.js index 0d6ed59fd..f45b8796f 100755 --- a/app/assets/javascripts/desktop/orbitdesktop.js +++ b/app/assets/javascripts/desktop/orbitdesktop.js @@ -226,7 +226,8 @@ var orbitDesktop = function(dom){ this.bindDesktopEvents = function(){ //this function will bind the global handlers to thd desktop, for example doc $(".docklist a").click(function(){ - o.menu_item($(this)); + if( !$( this ).hasClass( 'disable' ) ) + o.menu_item($(this)); return false; }); @@ -274,10 +275,11 @@ var orbitDesktop = function(dom){ }); $("body").on("click","*[ajax-remote]",function(){ - var $e = $(this); - var t = $e.attr("ajax-remote"); - var classes_to_toggle = $e.attr("toggle-onclick"); - var exe = $e.attr("callback-method"); // (typeof $e.attr("callback-method") == "function"? $e.attr("callback-method") : ""); + var $e = $(this), + t = $e.attr("ajax-remote"), + classes_to_toggle = $e.attr("toggle-onclick"), + responsetype = $e.attr('response-type') ? $e.attr('response-type') : "html", + exe = $e.attr("callback-method"); // (typeof $e.attr("callback-method") == "function"? $e.attr("callback-method") : ""); if(classes_to_toggle){ $e.toggleClass(classes_to_toggle); } @@ -289,9 +291,9 @@ var orbitDesktop = function(dom){ } var ca = $e.attr("content-holder"); var a = function(){ - $.ajax({ type : t, + dataType : responsetype, url : $e.attr("href"), success : function(data){ if(typeof data == "string"){ @@ -302,6 +304,7 @@ var orbitDesktop = function(dom){ // $("div[container=true]").html(data); } } + if(exe) window.o[o.data_method][exe](data,$e); if(t == "delete"){ diff --git a/app/controllers/admin/import_data_controller.rb b/app/controllers/admin/import_data_controller.rb index a66ab342a..7a754a03d 100644 --- a/app/controllers/admin/import_data_controller.rb +++ b/app/controllers/admin/import_data_controller.rb @@ -322,6 +322,12 @@ class Admin::ImportDataController < OrbitBackendController puts "No conference by Teacher" end end + respond_to do |format| + + format.html + format.json { render json: {"success"=>true}.to_json} + + end end @@ -331,64 +337,80 @@ class Admin::ImportDataController < OrbitBackendController @user = User.find("#{params[:user_id]}") # teachers.each do |hash| - if @user.sid.present? - ntu_seq = @user.sid - paper_xml = Nokogiri::XML( \ - #open("http://versatile.management.ntu.edu.tw/publication1/journal/#{ntuseq}.xml")) - open("http://ann.cc.ntu.edu.tw/Achv/xmlPaper.asp?Seq=#{ntu_seq}&type=J")) - @journal_papers = paper_xml.xpath("//Paper").map do |paper_node| - { - author: (paper_node>"Authors").text, - year: (paper_node>"PublishYear").text, - title: (paper_node>"PaperTitle").text, - journal: (paper_node>"PublishOn").text, - volume:(paper_node>"Volume").text, - volumeno:(paper_node>"VolumeNo").text, - beginpage:(paper_node>"BeginPage").text, - endpage:(paper_node>"EndPage").text, - subgroup:(paper_node>"subgroup").text, - remarks: (paper_node>"Remarks").text, - cate: ((paper_node>"subgroup")>"Group").text - } - end - if @journal_papers.present? - @journal_papers.each do |b| - @journal_paper = WritingJournal.new - I18n.locale = :zh_tw - @journal_paper.authors = b[:author] - if b[:title].blank? - @journal_paper.paper_title = "No Title Present" - else - @journal_paper.paper_title = b[:title] - end - @journal_paper.journal_title = b[:journal] - @journal_paper.note = b[:remarks] - I18n.locale = :en - @journal_paper.authors = b[:author] - if b[:title].blank? - @journal_paper.paper_title = "No Title Present" - else - @journal_paper.paper_title = b[:title] - end - @journal_paper.journal_title = b[:journal] - @journal_paper.note = b[:remarks] - @journal_paper.year = b[:year] - @journal_paper.vol_no = b[:volumeno] - @journal_paper.form_to_start = b[:beginpage] - @journal_paper.form_to_end = b[:endpage] - if !b[:cate].blank? - @level_type = JournalLevelType.where(:key => b[:cate]) - if @level_type.present? - @journal_paper.journal_level_type_ids = ["#{@level_type.first.id}"] - end - end + if @user.sid.present? + ntu_seq = @user.sid + paper_xml = Nokogiri::XML( \ + #open("http://versatile.management.ntu.edu.tw/publication1/journal/#{ntuseq}.xml")) + open("http://ann.cc.ntu.edu.tw/Achv/xmlPaper.asp?Seq=#{ntu_seq}&type=J")) + @journal_papers = paper_xml.xpath("//Paper").map do |paper_node| + { + author: (paper_node>"Authors").text, + year: (paper_node>"PublishYear").text, + title: (paper_node>"PaperTitle").text, + journal: (paper_node>"PublishOn").text, + volume:(paper_node>"Volume").text, + volumeno:(paper_node>"VolumeNo").text, + beginpage:(paper_node>"BeginPage").text, + endpage:(paper_node>"EndPage").text, + subgroup:(paper_node>"subgroup").text, + remarks: (paper_node>"Remarks").text, + cate: ((paper_node>"subgroup")>"Group").text + } + end + if @journal_papers.present? + @journal_papers.each do |b| + @journal_paper = WritingJournal.new + I18n.locale = :zh_tw + @journal_paper.authors = b[:author] - @journal_paper.create_user_id = @user.id - @journal_paper.save! - end - else - puts "No journal paper by Teacher" + if b[:title].blank? + @journal_paper.paper_title = "No Title Present" + else + @journal_paper.paper_title = b[:title] + end + + @journal_paper.journal_title = b[:journal] + @journal_paper.note = b[:remarks] + I18n.locale = :en + @journal_paper.authors = b[:author] + + if b[:title].blank? + @journal_paper.paper_title = "No Title Present" + else + @journal_paper.paper_title = b[:title] + end + + @journal_paper.journal_title = b[:journal] + @journal_paper.note = b[:remarks] + @journal_paper.year = b[:year] + @journal_paper.vol_no = b[:volumeno] + @journal_paper.form_to_start = b[:beginpage] + @journal_paper.form_to_end = b[:endpage] + + if !b[:cate].blank? + @level_type = JournalLevelType.where(:key => b[:cate]) + if @level_type.present? + @journal_paper.journal_level_type_ids = ["#{@level_type.first.id}"] + end + end + + @journal_paper.create_user_id = @user.id + @journal_paper.save! + respond_to do |format| + + format.html + format.json { render json: {"success"=>true}.to_json} + + end + end end + + end + respond_to do |format| + + format.html + format.json { render json: {"success"=>true}.to_json} + end end @@ -431,10 +453,14 @@ def sync_book_data @book.create_user_id = @user.id @book.save end - else - puts "No books by Teacher" - end + end end + respond_to do |format| + + format.html + format.json { render json: {"success"=>true}.to_json} + + end end diff --git a/app/views/desktop/index.html.erb b/app/views/desktop/index.html.erb index 9796ade73..cd3b6fcdb 100644 --- a/app/views/desktop/index.html.erb +++ b/app/views/desktop/index.html.erb @@ -32,32 +32,32 @@
  • Working
  • Education
  • Honors
  • -
  • Activities
  • -
  • Clubs
  • +
  • Activities
  • +
  • Clubs
  • Learning & Teaching
  • Personal
  • Orbit
  • -
  • AppStore
  • +
  • AppStore
  • diff --git a/vendor/built_in_modules/personal_book/app/assets/javascripts/personal_book/desktop/personal_books.js b/vendor/built_in_modules/personal_book/app/assets/javascripts/personal_book/desktop/personal_books.js index b744239ed..9a3f5174c 100644 --- a/vendor/built_in_modules/personal_book/app/assets/javascripts/personal_book/desktop/personal_books.js +++ b/vendor/built_in_modules/personal_book/app/assets/javascripts/personal_book/desktop/personal_books.js @@ -93,6 +93,11 @@ orbitDesktop.prototype.initializePersonalBook = function(target,url,cache){ // t }); } + this.initializePersonalBook.syncComplete = function(){ + o.notify("Sync Complete","success"); + o.sub_menu_item($("div[content-type=menu] a").eq(0)); + } + this.initializePersonalBook.coAuthorformCallback = function(data){ if(data.success){ o.notify(data.msg,"success"); diff --git a/vendor/built_in_modules/personal_book/app/controllers/panel/personal_book/desktop/personal_books_controller.rb b/vendor/built_in_modules/personal_book/app/controllers/panel/personal_book/desktop/personal_books_controller.rb index 803634845..fd54f35b1 100644 --- a/vendor/built_in_modules/personal_book/app/controllers/panel/personal_book/desktop/personal_books_controller.rb +++ b/vendor/built_in_modules/personal_book/app/controllers/panel/personal_book/desktop/personal_books_controller.rb @@ -7,7 +7,7 @@ class Panel::PersonalBook::Desktop::PersonalBooksController < ApplicationControl page ||= 1 @per_column = 5 - + @userid = current_user.id case @view_by when "abstract" @per_column = 1 diff --git a/vendor/built_in_modules/personal_book/app/views/panel/personal_book/desktop/personal_books/index.html.erb b/vendor/built_in_modules/personal_book/app/views/panel/personal_book/desktop/personal_books/index.html.erb index 9096e25f6..79c0244d4 100644 --- a/vendor/built_in_modules/personal_book/app/views/panel/personal_book/desktop/personal_books/index.html.erb +++ b/vendor/built_in_modules/personal_book/app/views/panel/personal_book/desktop/personal_books/index.html.erb @@ -57,6 +57,9 @@ +
    + +
    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 613a9dd20..ceb2cd8d3 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 @@ -42,7 +42,10 @@ orbitDesktop.prototype.initializeConferencePapers = function(target,url,cache){ this.initializeConferencePapers.cancelpaper = function(){ o.highlight_sub_menu_item(0); } - + this.initializeConferencePapers.syncComplete = function(){ + o.notify("Sync Complete","success"); + o.sub_menu_item($("div[content-type=menu] a").eq(0)); + } var uploadFiles = function(){ $('#add_plugin_file a.add').click(function(){ var new_id = $(this).prev().attr('value'); 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 7f3603aaf..5701b0ea1 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 @@ -4,7 +4,7 @@ class Panel::PersonalConference::Desktop::ConferencePagesController < Applicatio @writing_conferences = WritingConference.where(create_user_id: current_user.id) page = params[:page] page ||= 1 - + @userid = current_user.id if @view_by.nil? @writing_conferences = @writing_conferences.asc(:paper_title) else diff --git a/vendor/built_in_modules/personal_conference/app/views/panel/personal_conference/desktop/conference_pages/index.html.erb b/vendor/built_in_modules/personal_conference/app/views/panel/personal_conference/desktop/conference_pages/index.html.erb index d61d3bf3b..20f4714dc 100644 --- a/vendor/built_in_modules/personal_conference/app/views/panel/personal_conference/desktop/conference_pages/index.html.erb +++ b/vendor/built_in_modules/personal_conference/app/views/panel/personal_conference/desktop/conference_pages/index.html.erb @@ -58,6 +58,9 @@ +
    + +
    diff --git a/vendor/built_in_modules/personal_journal/app/assets/javascripts/personal_journal/desktop/journal_pages.js b/vendor/built_in_modules/personal_journal/app/assets/javascripts/personal_journal/desktop/journal_pages.js index 5da6a9dfc..3fee6f711 100644 --- a/vendor/built_in_modules/personal_journal/app/assets/javascripts/personal_journal/desktop/journal_pages.js +++ b/vendor/built_in_modules/personal_journal/app/assets/javascripts/personal_journal/desktop/journal_pages.js @@ -42,6 +42,10 @@ orbitDesktop.prototype.initializeJournalPapers = function(target,url,cache){ // this.initializeJournalPapers.cancelpaper = function(){ o.highlight_sub_menu_item(0); } + this.initializeJournalPapers.syncComplete = function(){ + o.notify("Sync Complete","success"); + o.sub_menu_item($("div[content-type=menu] a").eq(0)); + } var uploadFiles = function(){ $('#add_plugin_file a.add').click(function(){ diff --git a/vendor/built_in_modules/personal_journal/app/controllers/panel/personal_journal/desktop/journal_pages_controller.rb b/vendor/built_in_modules/personal_journal/app/controllers/panel/personal_journal/desktop/journal_pages_controller.rb index 59481481d..5a7c5e889 100644 --- a/vendor/built_in_modules/personal_journal/app/controllers/panel/personal_journal/desktop/journal_pages_controller.rb +++ b/vendor/built_in_modules/personal_journal/app/controllers/panel/personal_journal/desktop/journal_pages_controller.rb @@ -7,7 +7,7 @@ class Panel::PersonalJournal::Desktop::JournalPagesController < ApplicationContr page ||= 1 @per_column = 5 - + @userid = current_user.id case @view_by when "abstract" @per_column = 1 diff --git a/vendor/built_in_modules/personal_journal/app/views/panel/personal_journal/desktop/journal_pages/index.html.erb b/vendor/built_in_modules/personal_journal/app/views/panel/personal_journal/desktop/journal_pages/index.html.erb index 07007f472..89991eca5 100644 --- a/vendor/built_in_modules/personal_journal/app/views/panel/personal_journal/desktop/journal_pages/index.html.erb +++ b/vendor/built_in_modules/personal_journal/app/views/panel/personal_journal/desktop/journal_pages/index.html.erb @@ -58,6 +58,9 @@ +
    + +