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