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? %> -