From 996a69f5954ece9540d640f31178cc2b143c065b Mon Sep 17 00:00:00 2001 From: Rueshyna Date: Fri, 23 Nov 2012 10:44:48 +0800 Subject: [PATCH 1/4] add co-author json --- .../desktop/co_authors_controller.rb | 14 +++++++++++ .../desktop/journal_pages/_form.html.erb | 25 ++++++++++--------- config/routes.rb | 1 + 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/app/controllers/desktop/co_authors_controller.rb b/app/controllers/desktop/co_authors_controller.rb index 1c74314e..ccda3786 100644 --- a/app/controllers/desktop/co_authors_controller.rb +++ b/app/controllers/desktop/co_authors_controller.rb @@ -62,4 +62,18 @@ class Desktop::CoAuthorsController < ApplicationController format.json { head :no_content } end end + + def get_co_authors_json + @co_authors = CoAuthor.where(name_id: current_user.id) + data = Array.new + + @co_authors.each do |co_author| + data << { + author: co_author.co_author, + email: co_author.email, + type: co_author.type + } + end + render json: JSON.pretty_generate(data) + end end diff --git a/app/views/desktop/journal_pages/_form.html.erb b/app/views/desktop/journal_pages/_form.html.erb index 223bea04..b6320c6a 100644 --- a/app/views/desktop/journal_pages/_form.html.erb +++ b/app/views/desktop/journal_pages/_form.html.erb @@ -1,7 +1,8 @@
<%= f.submit "Save", name: "commit", value: "Save", class: "fn_btn hh2 thmc2 thmtxt" %> - +
Entry Year
@@ -48,10 +49,10 @@
  • - <%= f.text_area :paper_title, size: "20x2", value: @writing_journal.paper_title ||= "Paper Title", class: "s_grid_6 s_grid"%> + <%= f.text_area :paper_title, size: "20x2", placeholder: "Paper 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"%> + <%= f.text_field :journal_title, size: "20", placeholder: "Journal Title", class: "s_grid_6 s_grid"%>
  • @@ -85,34 +86,34 @@
  • - <%= 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("", "ISSN(ISBN)", class: "s_grid_2 s_grid") %><%= f.text_field :isbn, size: "20", placeholder: "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("", "Volume No.", class: "s_grid_2 s_grid") %><%= f.text_field :vol_no, size: "20", placeholder: "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("", "Issue No.", class: "s_grid_2 s_grid") %><%= f.text_field :issue_no, size: "20", placeholder:"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: @writing_journal.total_pages ||= "20", class: "s_grid_4 s_grid"%> + <%= label_tag("", "Total Pages", class: "s_grid_2 s_grid") %><%= f.text_field :total_pages, size: "20", placeholder:"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: @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("", "Pages", class: "s_grid_2 s_grid") %><%= label_tag("", "from", class: "s_grid_1 s_grid") %><%= f.text_field :form_to_start, size: "10", placeholder: "1", class: "s_grid_1 s_grid"%><%= label_tag("", "to", class: "s_grid_1 s_grid") %><%= f.text_field :form_to_end, size: "10", placeholder: "20", class: "s_grid_1 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"%> + <%= label_tag("", "Reference URL", class: "s_grid_2 s_grid") %><%= f.text_field :url, size: "20", placeholder: "www.sample.com", class: "s_grid_4 s_grid"%>
  • - <%= f.text_area :authors, size: "20x2", value: @writing_journal.authors ||= "Authors", class: "s_grid_6 s_grid"%> + <%= f.text_area :authors, size: "20x2", placeholder: "Authors", class: "s_grid_6 s_grid"%>
  • @@ -184,14 +185,14 @@ -->
  • - <%= f.text_area :note, size: "20x2", value: @writing_journal.note ||= "Note", class: "s_grid_6 s_grid"%> + <%= f.text_area :note, size: "20x2", plcaeholder: "Note", class: "s_grid_6 s_grid"%>
  • - <%= f.text_area :abstract, size: "20x26", value: @writing_journal.abstract ||= "Abstract", class: "s_grid_6 s_grid"%> + <%= f.text_area :abstract, size: "20x26", placeholder: "Abstract", class: "s_grid_6 s_grid"%>
diff --git a/config/routes.rb b/config/routes.rb index 45dae242..6b328019 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -151,6 +151,7 @@ Orbit::Application.routes.draw do namespace :desktop do match "desktop" => "desktop#desktop" match '/journal_pages/get_journals_json' => 'journal_pages#get_journals_json' + match '/co_authors/get_co_authors_json' => 'co_authors#get_co_authors_json' match '/desktop'=>'desktop#desktop' match '/app_manager'=>'desktop#app_manager' match '/sections'=>'desktop#sections' From f38f32ac8b04a21c267ea8e510561caaae7a7dcc Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Fri, 23 Nov 2012 10:46:42 +0800 Subject: [PATCH 2/4] delete update --- .../javascripts/desktop/journal_pages.js.erb | 30 +++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/desktop/journal_pages.js.erb b/app/assets/javascripts/desktop/journal_pages.js.erb index cd04499e..74438aa0 100644 --- a/app/assets/javascripts/desktop/journal_pages.js.erb +++ b/app/assets/javascripts/desktop/journal_pages.js.erb @@ -64,6 +64,26 @@ orbitDesktop.prototype.initializeJournalPapers = function(target,url,cache){ // }) return false; }) + $("div[container=true]").unbind("click").on("click",".journal_paper_delete",function(){ + var delurl = $(this).attr("href"); + var parent = $(this).parent(); + o.confirm({ + buttons : ["Yes","No"], + highlighted : 2, + message : "Are you sure, you want to delete this paper?" + },function(value){ + if(value){ + $.ajax({ + url : delurl, + type : "DELETE", + success : function(){ + parent.slideOut(); + } + }) + } + }) + return false; + }) } @@ -89,7 +109,7 @@ orbitDesktop.prototype.initializeJournalPapers = function(target,url,cache){ // li; $.each(journalData,function(i,journal){ $.each(journal.papers,function(j,paper){ - li = $('
  • '+journal.title+'
    '+paper.title+'
    Edit
  • '); + li = $('
  • '+journal.title+'
    '+paper.title+'
    Edit Delete
  • '); column.find("ul").append(li); if(counter%5==0){ $("#journal_p div#paper_list div.overview").append(column); @@ -118,7 +138,7 @@ orbitDesktop.prototype.initializeJournalPapers = function(target,url,cache){ // var img = $(''); li.append(img); }) - li.append('Edit'); + li.append('Edit Delete'); column.find("ul").append(li); if(counter%5==0){ $("#journal_p div#paper_list div.overview").append(column); @@ -137,7 +157,7 @@ orbitDesktop.prototype.initializeJournalPapers = function(target,url,cache){ // li; $.each(journalData,function(i,journal){ $.each(journal.papers,function(j,paper){ - li = $('
  • '+paper.title+'
    '+paper.keywords+'
    Edit
  • '); + li = $('
  • '+paper.title+'
    '+paper.keywords+'
    Edit Delete
  • '); column.find("ul").append(li); if(counter%5==0){ $("#journal_p div#paper_list div.overview").append(column); @@ -157,7 +177,7 @@ orbitDesktop.prototype.initializeJournalPapers = function(target,url,cache){ // li; $.each(journalData,function(i,journal){ $.each(journal.papers,function(j,paper){ - li = $('
  • '+paper.title+'
    Edit
  • '); + li = $('
  • '+paper.title+'
    Edit Delete
  • '); column.find("ul").append(li); if(counter%5==0){ $("#journal_p div#paper_list div.overview").append(column); @@ -176,7 +196,7 @@ orbitDesktop.prototype.initializeJournalPapers = function(target,url,cache){ // li; $.each(journalData,function(i,journal){ $.each(journal.papers,function(j,paper){ - li = $('
  • '+paper.title+'
    '+paper.abstract+'
    Edit
  • '); + li = $('
  • '+paper.title+'
    '+paper.abstract+'
    Edit Delete
  • '); column.find("ul").append(li); $("#journal_p div#paper_list div.overview").append(column); column = $('
      '); From 8009c6aa3450ee065dc0de488d14fbde225e1383 Mon Sep 17 00:00:00 2001 From: Rueshyna Date: Fri, 23 Nov 2012 12:28:36 +0800 Subject: [PATCH 3/4] fixed delete function --- app/controllers/desktop/co_authors_controller.rb | 8 ++++---- app/controllers/desktop/journal_pages_controller.rb | 5 +++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/controllers/desktop/co_authors_controller.rb b/app/controllers/desktop/co_authors_controller.rb index ccda3786..2ea928bc 100644 --- a/app/controllers/desktop/co_authors_controller.rb +++ b/app/controllers/desktop/co_authors_controller.rb @@ -57,10 +57,10 @@ class Desktop::CoAuthorsController < ApplicationController @co_author = CoAuthor.find(params[:id]) @co_author.destroy - respond_to do |format| - format.html { redirect_to desktop_co_authors_url, :layout => false } - format.json { head :no_content } - end + #respond_to do |format| + # format.html { redirect_to desktop_co_authors_url, :layout => false } + # format.json { head :no_content } + #end end def get_co_authors_json diff --git a/app/controllers/desktop/journal_pages_controller.rb b/app/controllers/desktop/journal_pages_controller.rb index 6aa8c7fd..dfd37471 100644 --- a/app/controllers/desktop/journal_pages_controller.rb +++ b/app/controllers/desktop/journal_pages_controller.rb @@ -80,6 +80,11 @@ class Desktop::JournalPagesController < ApplicationController end end + def destroy + @writing_journal = WritingJournal.find(params[:id]) + @writing_journal.destroy + end + def get_journals_json publications = WritingJournal.where(create_user_id: current_user.id) From 3933c048b076eaa8d99898120e6e1ea84df768a8 Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Fri, 23 Nov 2012 13:22:01 +0800 Subject: [PATCH 4/4] delete fixed --- app/assets/javascripts/desktop/journal_pages.js.erb | 11 +++++++---- app/controllers/desktop/journal_pages_controller.rb | 1 + 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/desktop/journal_pages.js.erb b/app/assets/javascripts/desktop/journal_pages.js.erb index 74438aa0..9b7c0a03 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]").unbind("click").on("click",".journal_paper_edit",function(){ + $("div[container=true]").unbind(".edit").on("click.edit",".journal_paper_edit",function(){ $.ajax({ url : $(this).attr("href"), type : "get", @@ -64,7 +64,7 @@ orbitDesktop.prototype.initializeJournalPapers = function(target,url,cache){ // }) return false; }) - $("div[container=true]").unbind("click").on("click",".journal_paper_delete",function(){ + $("div[container=true]").unbind(".delete").on("click.delete",".journal_paper_delete",function(){ var delurl = $(this).attr("href"); var parent = $(this).parent(); o.confirm({ @@ -76,8 +76,11 @@ orbitDesktop.prototype.initializeJournalPapers = function(target,url,cache){ // $.ajax({ url : delurl, type : "DELETE", - success : function(){ - parent.slideOut(); + success : function(data){ + if(data.success){ + parent.hide("slide",function(){parent.remove();}); + o.notify(data.msg,"success"); + } } }) } diff --git a/app/controllers/desktop/journal_pages_controller.rb b/app/controllers/desktop/journal_pages_controller.rb index dfd37471..cebe3b6c 100644 --- a/app/controllers/desktop/journal_pages_controller.rb +++ b/app/controllers/desktop/journal_pages_controller.rb @@ -83,6 +83,7 @@ class Desktop::JournalPagesController < ApplicationController def destroy @writing_journal = WritingJournal.find(params[:id]) @writing_journal.destroy + render :json => {success: true,msg: "Paper deleted successfully!"} end def get_journals_json