This commit is contained in:
Rueshyna 2012-11-21 14:52:26 +08:00 committed by chris
parent d502f561ef
commit b47be52309
5 changed files with 21 additions and 25 deletions

View File

@ -1034,7 +1034,16 @@ var orbitDesktop = function(dom){
} }
bindHandlers(); bindHandlers();
} }
this.initializeJournalPapers.coAuthorformCallback = function(ruse){
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{
o.notify(data.msg,"alert");
}
}
}
this.initializeJournalPapers.coauthor = function(){ // to open add pages in journal papers page this.initializeJournalPapers.coauthor = function(){ // to open add pages in journal papers page
var bindHandlers = function(){ // to bind handlers for add page var bindHandlers = function(){ // to bind handlers for add page
o.simple_drop_down(); o.simple_drop_down();

View File

@ -36,12 +36,10 @@ 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
respond_to do |format| if @writing_journal.save
if @co_author.save render :json => {success:true, msg: "Paper successfully saved!"}.to_json
format.html { redirect_to desktop_co_authors_path, :layout => false, notice: 'CoAuthor was successfully created.' }
else else
format.html { render action: "new", :layout => false} render :json => {success:false, msg: "Saving failed!"}
end
end end
end end

View File

@ -39,20 +39,14 @@ class Desktop::JournalPagesController < ApplicationController
params[:writing_journal][:create_user_id] = current_user.id params[:writing_journal][:create_user_id] = current_user.id
@writing_journal = WritingJournal.new(params[:writing_journal]) @writing_journal = WritingJournal.new(params[:writing_journal])
respond_to do |format|
if @writing_journal.save if @writing_journal.save
# respond_to do |format| format.json {render json: {success: true, msg: "Paper successfully saved!"}.to_json}
# format.html { redirect_to desktop_journal_pages_url, :layout => false, notice: 'User was successfully created.'}
# # format.json { render json: @writing_journal, status: :created, location: @writing_journal}
# # format.js
# end
render :json => {"success"=>true,"msg"=>"Paper successfully saved!"}.to_json
else else
render :json => {"success"=>false,"msg"=>"Saving failed!"} format.json {render json: {success: false, msg: "Saving failed!"}.to_json }
end
end end
end end
render :json => {"success"=>true,"msg"=>"Paper successfully saved!"}.to_json
end end
def update def update
@ -60,11 +54,6 @@ class Desktop::JournalPagesController < ApplicationController
@writing_journal= WritingJournal.find(params[:id]) @writing_journal= WritingJournal.find(params[:id])
end end
if not params[:writing_journal][:publication_date].nil?
params[:writing_journal][:publication_date] = \
Date.new *(params[:writing_journal][:publication_date].split("/").map{|s| s.to_i})
end
respond_to do |format| respond_to do |format|
if @writing_journal.update_attributes(params[:writing_journal]) if @writing_journal.update_attributes(params[:writing_journal])
format.html { redirect_to desktop_journal_pages_url, :layout => false, notice: 'User was successfully updated.'} format.html { redirect_to desktop_journal_pages_url, :layout => false, notice: 'User was successfully updated.'}

View File

@ -1,3 +1,3 @@
<%= form_for @co_author, url: desktop_co_authors_path do |f| %> <%= form_for @co_author, html: { multipart: true ,: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,3 +1,3 @@
<%= form_for @writing_journal , url: desktop_journal_pages_path do |f| %> <%= form_for @writing_journal, html: { multipart: true, :type=>"ajax_form", "callback-method"=>"formCallback"} , url: desktop_journal_pages_path do |f| %>
<%= render partial: 'desktop/journal_pages/form', locals: {:f => f} %> <%= render partial: 'desktop/journal_pages/form', locals: {:f => f} %>
<%end%> <%end%>