From c53581c999a6fe2ec5041be0f66539f79913f9eb Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Wed, 21 Nov 2012 17:11:18 +0800 Subject: [PATCH] small fix for journal_pages desktop --- .../javascripts/desktop/journal_pages.js.erb | 4 +--- app/assets/javascripts/orbitdesktop.js | 2 +- .../desktop/journal_pages_controller.rb | 14 +++++++------- app/views/desktop/journal_pages/edit.html.erb | 2 +- app/views/desktop/journal_pages/new.html.erb | 2 +- 5 files changed, 11 insertions(+), 13 deletions(-) diff --git a/app/assets/javascripts/desktop/journal_pages.js.erb b/app/assets/javascripts/desktop/journal_pages.js.erb index 4720686c..0bb9063d 100644 --- a/app/assets/javascripts/desktop/journal_pages.js.erb +++ b/app/assets/javascripts/desktop/journal_pages.js.erb @@ -207,15 +207,13 @@ orbitDesktop.prototype.initializeJournalPapers = function(target,url,cache){ // } bindHandlers(); } - this.initializeJournalPapers.coAuthorformCallback = function(ruse){ - this.initializeJournalPapers.formCallback = function(data){ + this.initializeJournalPapers.coAuthorformCallback = 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 var bindHandlers = function(){ // to bind handlers for add page diff --git a/app/assets/javascripts/orbitdesktop.js b/app/assets/javascripts/orbitdesktop.js index bebaa016..7bcaa92c 100755 --- a/app/assets/javascripts/orbitdesktop.js +++ b/app/assets/javascripts/orbitdesktop.js @@ -133,7 +133,7 @@ var orbitDesktop = function(dom){ } },'*[content-type=menu] a'); - $("body").on("submit","form[type=ajax_form]",function(){ + $("body").on("submit","form[form-type=ajax_form]",function(){ var callback_method = $(this).attr("callback-method"); var options = { success:function(responseText, statusText, xhr, $form){ diff --git a/app/controllers/desktop/journal_pages_controller.rb b/app/controllers/desktop/journal_pages_controller.rb index 72bb54af..14397814 100644 --- a/app/controllers/desktop/journal_pages_controller.rb +++ b/app/controllers/desktop/journal_pages_controller.rb @@ -35,18 +35,18 @@ class Desktop::JournalPagesController < ApplicationController end def create - if params[:commit].eql?"Save" + 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 } + 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 end - end - end + end def update diff --git a/app/views/desktop/journal_pages/edit.html.erb b/app/views/desktop/journal_pages/edit.html.erb index e0f0837c..1377af92 100644 --- a/app/views/desktop/journal_pages/edit.html.erb +++ b/app/views/desktop/journal_pages/edit.html.erb @@ -1,3 +1,3 @@ -<%= form_for @writing_journal, url: desktop_journal_page_path(@writing_journal),html: { multipart: true ,:type=>"ajax_form", "callback-method"=>"formCallback"} do |f| %> +<%= form_for @writing_journal, url: desktop_journal_page_path(@writing_journal),html: { multipart: true ,"form-type"=>"ajax_form", "callback-method"=>"formCallback"} do |f| %> <%= render partial: 'desktop/journal_pages/form', locals: {:f => f} %> <%end%> diff --git a/app/views/desktop/journal_pages/new.html.erb b/app/views/desktop/journal_pages/new.html.erb index 5b889e6a..d5f5557b 100644 --- a/app/views/desktop/journal_pages/new.html.erb +++ b/app/views/desktop/journal_pages/new.html.erb @@ -1,3 +1,3 @@ -<%= form_for @writing_journal, html: { multipart: true, :type=>"ajax_form", "callback-method"=>"formCallback"} , url: desktop_journal_pages_path do |f| %> +<%= form_for @writing_journal, html: { multipart: true, "form-type"=>"ajax_form", "callback-method"=>"formCallback"} , url: desktop_journal_pages_path do |f| %> <%= render partial: 'desktop/journal_pages/form', locals: {:f => f} %> <%end%>