diff --git a/app/assets/javascripts/desktop/journal_pages.js.erb b/app/assets/javascripts/desktop/journal_pages.js.erb
index cd04499e..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,6 +64,29 @@ orbitDesktop.prototype.initializeJournalPapers = function(target,url,cache){ //
})
return false;
})
+ $("div[container=true]").unbind(".delete").on("click.delete",".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(data){
+ if(data.success){
+ parent.hide("slide",function(){parent.remove();});
+ o.notify(data.msg,"success");
+ }
+ }
+ })
+ }
+ })
+ return false;
+ })
}
@@ -89,7 +112,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 +141,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 +160,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 +180,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 +199,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 = $('');
diff --git a/app/controllers/desktop/co_authors_controller.rb b/app/controllers/desktop/co_authors_controller.rb
index 1c74314e..2ea928bc 100644
--- a/app/controllers/desktop/co_authors_controller.rb
+++ b/app/controllers/desktop/co_authors_controller.rb
@@ -57,9 +57,23 @@ 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 }
+ #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
+ @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/controllers/desktop/journal_pages_controller.rb b/app/controllers/desktop/journal_pages_controller.rb
index 6aa8c7fd..cebe3b6c 100644
--- a/app/controllers/desktop/journal_pages_controller.rb
+++ b/app/controllers/desktop/journal_pages_controller.rb
@@ -80,6 +80,12 @@ class Desktop::JournalPagesController < ApplicationController
end
end
+ def destroy
+ @writing_journal = WritingJournal.find(params[:id])
+ @writing_journal.destroy
+ render :json => {success: true,msg: "Paper deleted successfully!"}
+ end
+
def get_journals_json
publications = WritingJournal.where(create_user_id: current_user.id)
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 @@