From dc1ce37c9066419c74ddeb3c448d523230df4b43 Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Mon, 3 Dec 2012 15:44:26 +0800 Subject: [PATCH] new type fixed --- app/assets/javascripts/desktop/journal_pages.js.erb | 3 ++- .../desktop/co_author_relations_controller.rb | 3 ++- .../desktop/co_author_relations/_show_form.html.erb | 8 ++++---- app/views/desktop/co_author_relations/index.html.erb | 10 ++++++---- app/views/desktop/co_authors/index.html.erb | 5 ++++- 5 files changed, 18 insertions(+), 11 deletions(-) diff --git a/app/assets/javascripts/desktop/journal_pages.js.erb b/app/assets/javascripts/desktop/journal_pages.js.erb index 56aed19d..4b7f0e00 100644 --- a/app/assets/javascripts/desktop/journal_pages.js.erb +++ b/app/assets/javascripts/desktop/journal_pages.js.erb @@ -281,7 +281,7 @@ orbitDesktop.prototype.initializeJournalPapers = function(target,url,cache){ // }) return false; }) - $("a.bt-delete").click(function(){ + $("div[container=true]").unbind(".delete").on("click.delete","a.bt-delete",function(){ var delurl = $(this).attr("href"); var parent = $(this).parent().parent(); o.confirm({ @@ -346,6 +346,7 @@ orbitDesktop.prototype.initializeJournalPapers = function(target,url,cache){ // this.initializeJournalPapers.coauthorRelationForm = function(data){ if(data.success){ o.notify(data.msg,"success"); + $("#co_author_relation_table tbody").prepend(data.newvalue); }else{ o.notify(data.msg,"alert"); } diff --git a/app/controllers/desktop/co_author_relations_controller.rb b/app/controllers/desktop/co_author_relations_controller.rb index 02d15bc1..f35391dd 100644 --- a/app/controllers/desktop/co_author_relations_controller.rb +++ b/app/controllers/desktop/co_author_relations_controller.rb @@ -16,7 +16,8 @@ class Desktop::CoAuthorRelationsController < ApplicationController @new_relation = CoAuthorRelation.new(params[:co_author_relation]) if @new_relation.save - render json: {success:true, msg: "New Relation successfully saved!"}.to_json + newv = render_to_string :partial=>"show_form", :object=>@new_relation + render json: {success:true, msg: "New Relation successfully saved!","newvalue"=>newv}.to_json else error_msg = @new_relation.errors.full_messages.join("
") render json: {success: false, msg: error_msg}.to_json diff --git a/app/views/desktop/co_author_relations/_show_form.html.erb b/app/views/desktop/co_author_relations/_show_form.html.erb index 2cad8363..28ded992 100644 --- a/app/views/desktop/co_author_relations/_show_form.html.erb +++ b/app/views/desktop/co_author_relations/_show_form.html.erb @@ -1,6 +1,6 @@ -<% @co_author_relations.each do |co_author_relation| %> +<%# @co_author_relations.each do |co_author_relation| %> - <%= co_author_relation.relation %> - <%= link_to 'Destroy', desktop_co_author_relation_path(co_author_relation), confirm: 'Are you sure?', method: :delete %> + <%= show_form.relation %> + <%= link_to 'Destroy', desktop_co_author_relation_path(show_form), confirm: 'Are you sure?', method: :delete, :class=>"bt-delete" %> -<% end %> +<%# end %> diff --git a/app/views/desktop/co_author_relations/index.html.erb b/app/views/desktop/co_author_relations/index.html.erb index 3ce95f0d..3d4a30e7 100644 --- a/app/views/desktop/co_author_relations/index.html.erb +++ b/app/views/desktop/co_author_relations/index.html.erb @@ -2,13 +2,15 @@ <%= render 'form' %> - +
+ - -<%= render 'show_form'%> - + + + <%= render :partial => 'show_form', :collection => @co_author_relations %> +
Relation
diff --git a/app/views/desktop/co_authors/index.html.erb b/app/views/desktop/co_authors/index.html.erb index faf789c6..e8e424d2 100644 --- a/app/views/desktop/co_authors/index.html.erb +++ b/app/views/desktop/co_authors/index.html.erb @@ -2,6 +2,7 @@ <%= link_to "New Co-Author", new_desktop_co_author_path, :class=>"bt-co-author" %> <%= link_to "New Type", desktop_co_author_relations_path, :class=>"bt-new-type" %> + @@ -10,7 +11,8 @@ - + + <% @co_authors.each do |co_author| %> @@ -20,5 +22,6 @@ <% end %> +
Name EMail
<%= co_author.co_author %><%= link_to 'Destroy', desktop_co_author_path(co_author), method: :delete, confirm: 'Are you sure?', :class=>"bt-delete" %>