From 0125010a0592a27b9c221750e7cdd9a7b5d00609 Mon Sep 17 00:00:00 2001 From: Rueshyna Date: Mon, 26 Nov 2012 15:45:51 +0800 Subject: [PATCH] modified error msgs and cancle button, but those two have bug... --- .../desktop/co_authors_controller.rb | 6 ++++-- .../desktop/journal_pages_controller.rb | 20 ++++--------------- .../desktop/journal_pages/_form.html.erb | 4 ++-- 3 files changed, 10 insertions(+), 20 deletions(-) diff --git a/app/controllers/desktop/co_authors_controller.rb b/app/controllers/desktop/co_authors_controller.rb index 2ea928bc..d41e2348 100644 --- a/app/controllers/desktop/co_authors_controller.rb +++ b/app/controllers/desktop/co_authors_controller.rb @@ -39,7 +39,8 @@ class Desktop::CoAuthorsController < ApplicationController if @co_author.save render json: {success:true, msg: "Co-author successfully saved!"}.to_json else - render json: {success: false, msg: @co_author.errors.full_messages}.to_json + error_msg = @co_author.errors.full_messages.join("
") + render json: {success: false, msg: error_msg}.to_json end end @@ -49,7 +50,8 @@ class Desktop::CoAuthorsController < ApplicationController 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 + error_msg = @co_author.errors.full_messages.join("
") + render json: {success: false, msg: error_msg}.to_json end end diff --git a/app/controllers/desktop/journal_pages_controller.rb b/app/controllers/desktop/journal_pages_controller.rb index 66c613ef..69334a5b 100644 --- a/app/controllers/desktop/journal_pages_controller.rb +++ b/app/controllers/desktop/journal_pages_controller.rb @@ -23,7 +23,6 @@ class Desktop::JournalPagesController < ApplicationController @journal_candidate = WritingJournal.where(create_user_id: current_user.id).map{|j|j.journal_title}.uniq - respond_to do |format| format.html { render :layout => false} end @@ -47,7 +46,8 @@ class Desktop::JournalPagesController < ApplicationController 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 + error_msg = @writing_journal.errors.full_messages.join("
") + render json: {success: false, msg: error_msg}.to_json end end @@ -58,7 +58,8 @@ 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: @writing_journal.errors.full_messages}.to_json + error_msg = @writing_journal.errors.full_messages.join("
") + render json: {success: false, msg: error_msg}.to_json end end end @@ -66,19 +67,6 @@ class Desktop::JournalPagesController < ApplicationController def check_file_type file if not file.nil? file_type = MIME::Types.type_for(file).first.to_s.split("/")[1] - - # case file_type - # when "jpg", "jpeg" - # type = "jpg" - # when "text", "txt" - # type = "txt" - # when "pdf" - # type = "pdf" - # when "png" - # type = "png" - # else "readme" - # end - file_type = "/assets/ft-icons/#{file_type}/#{file_type}-48_32.png" else file_type = "" diff --git a/app/views/desktop/journal_pages/_form.html.erb b/app/views/desktop/journal_pages/_form.html.erb index b2328dc4..5f88322e 100644 --- a/app/views/desktop/journal_pages/_form.html.erb +++ b/app/views/desktop/journal_pages/_form.html.erb @@ -1,8 +1,8 @@
<%= f.submit "Save", name: "commit", value: "Save", class: "fn_btn hh2 thmc2 thmtxt" %> - + + <%= submit_tag "Cancel", :type => "button", class: "bt-cancel fn_btn hh2 thmc2 thmtxt" %>
Entry Year