fixed add journal and co-author curd problem, but have redirect problem...

This commit is contained in:
Rueshyna 2012-11-22 10:49:54 +08:00 committed by chris
parent c281ae9447
commit 78500e0661
7 changed files with 20 additions and 45 deletions

View File

@ -1,6 +1,5 @@
orbitDesktop.prototype.initializeJournalPapers = function(target,url,cache){ // this init journal papers orbitDesktop.prototype.initializeJournalPapers = function(target,url,cache){ // this init journal papers
this.initializeJournalPapers.formCallback = function(data){ this.initializeJournalPapers.formCallback = function(data){
if(data.success){
o.notify(data.msg,"success"); o.notify(data.msg,"success");
o.sub_menu_item($("div[content-type=menu] a").eq(0)); o.sub_menu_item($("div[content-type=menu] a").eq(0));
}else{ }else{

View File

@ -36,24 +36,20 @@ class Desktop::CoAuthorsController < ApplicationController
@co_author = CoAuthor.new(params[:co_author]) @co_author = CoAuthor.new(params[:co_author])
@co_author.name_id= current_user.id @co_author.name_id= current_user.id
if @writing_journal.save if @co_author.save
render :json => {success:true, msg: "Paper successfully saved!"}.to_json render json: {success:true, msg: "Co-author successfully saved!"}.to_json
else else
render :json => {success:false, msg: "Saving failed!"} render json: {success: false, msg: @co_author.errors.full_messages}.to_json
end end
end end
def update def update
@co_author = CoAuthor.find(params[:id]) @co_author = CoAuthor.find(params[:id])
respond_to do |format|
if @co_author.update_attributes(params[:co_author]) if @co_author.update_attributes(params[:co_author])
format.html { redirect_to desktop_co_authors_url, notice: 'CoAuthor was successfully updated.' } render json: {success:true, msg: "Co-author successfully update!"}.to_json
format.json { head :no_content }
else else
format.html { render action: "edit" } render json: {success: false, msg: @co_author.errors.full_messages}.to_json
format.json { render json: @co_author.errors, status: :unprocessable_entity }
end
end end
end end

View File

@ -1,4 +1,5 @@
class Desktop::JournalPagesController < ApplicationController class Desktop::JournalPagesController < ApplicationController
#before_filter :check_for_cancel, :only => [:create, :update]
def index def index
@writing_journal = WritingJournal.where(create_user_id: current_user.id) @writing_journal = WritingJournal.where(create_user_id: current_user.id)
@ -41,7 +42,7 @@ class Desktop::JournalPagesController < ApplicationController
if @writing_journal.save if @writing_journal.save
render json: {success: true, msg: "Paper successfully saved!"}.to_json render json: {success: true, msg: "Paper successfully saved!"}.to_json
else 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 end
@ -52,7 +53,7 @@ class Desktop::JournalPagesController < ApplicationController
if @writing_journal.update_attributes(params[:writing_journal]) if @writing_journal.update_attributes(params[:writing_journal])
render json: {success: true, msg: "Paper successfully saved!"}.to_json render json: {success: true, msg: "Paper successfully saved!"}.to_json
else 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 end
end end

View File

@ -1,17 +1,6 @@
<% if @co_author.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@co_author.errors.count, "error") %> prohibited this user from being saved:</h2>
<ul>
<% @co_author.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="fn_g hp"> <div class="fn_g hp">
<%= f.submit "Save", name: "commit", value: "Save", class: "fn_btn hh2 thmc2 thmtxt" %>
<%= button_tag "Save", name: "commit", value: "Save", class: "fn_btn hh2 thmc2 thmtxt" %> <!-- <%= submit_tag "Cancel", :class=>"fn_btn hh2 bt-cancel thmc2 thmtxt" %>-->
<%= button_tag "Cancel", name: "commit", value: "Cancel", class: "fn_btn hh2 thmc2 thmtxt" %>
</div> </div>
<div></div> <div></div>

View File

@ -1,3 +1,3 @@
<%= form_for @co_author, url: desktop_co_author_path(@co_author) do |f| %> <%= form_for @co_author, html: { multipart: true ,"form-type"=>"ajax_form", "callback-method"=>"coAuthorformCallback"} , url: desktop_co_author_path(@co_author) do |f| %>
<%= render partial: 'desktop/co_authors/form', locals: {:f => f} %> <%= render partial: 'desktop/co_authors/form', locals: {:f => f} %>
<% end %> <% end %>

View File

@ -1,3 +1,3 @@
<%= form_for @co_author, html: { multipart: true ,:type=>"ajax_form", "callback-method"=>"coAuthorformCallback"} , url: desktop_co_authors_path do |f| %> <%= form_for @co_author, html: { multipart: true ,"form-type"=>"ajax_form", "callback-method"=>"coAuthorformCallback"} , url: desktop_co_authors_path do |f| %>
<%= render partial: 'desktop/co_authors/form', locals: {:f => f} %> <%= render partial: 'desktop/co_authors/form', locals: {:f => f} %>
<% end %> <% end %>

View File

@ -1,13 +1,3 @@
<% if @writing_journal.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@writing_journal.errors.count, "error") %> prohibited this user from being saved:</h2>
<ul>
<% @writing_journal.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="toolbar hh2"> <div class="toolbar hh2">
<div class="fn_g hp"> <div class="fn_g hp">
<%= f.submit "Save", name: "commit", value: "Save", class: "fn_btn hh2 thmc2 thmtxt" %> <%= f.submit "Save", name: "commit", value: "Save", class: "fn_btn hh2 thmc2 thmtxt" %>