Merge branch 'publication' of https://github.com/Rulingcom/orbit into publication

* 'publication' of https://github.com/Rulingcom/orbit:
  edit coauthor relation done
This commit is contained in:
Rueshyna 2012-12-06 02:12:25 +08:00
commit 9db3b382b8
5 changed files with 33 additions and 9 deletions

View File

@ -280,6 +280,21 @@ orbitDesktop.prototype.initializeJournalPapers = function(target,url,cache){ //
}) })
return false; return false;
}) })
$("div[container=true]").unbind(".editype").on("click.edittype", "a.bt-edit-type", function(){
var parent = $(this).parent().parent();
$.ajax({
url : $(this).attr("href"),
type : "get",
success : function(data){
var prev_data = parent.find("td.form_space").html();
parent.find("td.form_space").html(data);
$(".bt-cancel-type").click(function(){
parent.find("td.form_space").html(prev_data);
})
}
})
return false;
})
$("div[container=true]").unbind(".delete").on("click.delete","a.bt-delete",function(){ $("div[container=true]").unbind(".delete").on("click.delete","a.bt-delete",function(){
var delurl = $(this).attr("href"); var delurl = $(this).attr("href");
@ -351,4 +366,12 @@ orbitDesktop.prototype.initializeJournalPapers = function(target,url,cache){ //
o.notify(data.msg,"alert"); o.notify(data.msg,"alert");
} }
} }
this.initializeJournalPapers.coauthorRelationEditForm = function(data){
if(data.success){
o.notify(data.msg,"success");
$("#co_author_relation_table tbody").html(data.newvalue);
}else{
o.notify(data.msg,"alert");
}
}
}; };

View File

@ -25,7 +25,7 @@ class Desktop::CoAuthorRelationsController < ApplicationController
if @co_author_relation.save if @co_author_relation.save
newv = render_to_string partial: "show_form", object: @co_author_relations newv = render_to_string partial: "show_form", object: @co_author_relations
render json: {success: true, msg: "New Relation successfully saved!", newvalue: newv}.to_json render json: {success: true, msg: "New Relation successfully saved!", newvalue: newvm}.to_json
else else
error_msg = @co_author_relation.errors.full_messages.join("<br />") error_msg = @co_author_relation.errors.full_messages.join("<br />")
render json: {success: false, msg: error_msg}.to_json render json: {success: false, msg: error_msg}.to_json
@ -34,9 +34,10 @@ class Desktop::CoAuthorRelationsController < ApplicationController
def update def update
@co_author_relation = CoAuthorRelation.find(params[:id]) @co_author_relation = CoAuthorRelation.find(params[:id])
if @co_author_relation.update_attributes(params[:co_author_relation]) if @co_author_relation.update_attributes(params[:co_author_relation])
render json: {success:true, msg: t('update.sucess.co_author')}.to_json @co_author_relations = CoAuthorRelation.all
newv = render_to_string partial: "show_form", object: @co_author_relations
render json: {success: true, msg: "New Relation successfully updated!", newvalue: newv}.to_json
else else
error_msg = @co_author.errors.full_messages.join("<br />") error_msg = @co_author.errors.full_messages.join("<br />")
render json: {success: false, msg: error_msg}.to_json render json: {success: false, msg: error_msg}.to_json

View File

@ -1,5 +1,5 @@
<% if not @co_author_relation.new_record? %>
<%= submit_tag "Cancel", :type => "button", class: "bt-cancel ini_input hp hh2 thmadm thmtxt" %>
<% end %>
<%= f.text_field :relation %> <%= f.text_field :relation %>
<%= f.submit "Save" %> <%= f.submit "Save" %>
<% if not @co_author_relation.new_record? %>
<%= submit_tag "Cancel", :type => "button", class: "bt-cancel-type" %>
<% end %>

View File

@ -1,7 +1,7 @@
<% @co_author_relations.each do |co_author_relation| %> <% @co_author_relations.each do |co_author_relation| %>
<tr> <tr>
<td><%= co_author_relation.relation %></td> <td class="form_space"><%= co_author_relation.relation %></td>
<td><%= link_to 'Edit', edit_desktop_co_author_relation_path(co_author_relation), :class => "bt-edit" %></td> <td><%= link_to 'Edit', edit_desktop_co_author_relation_path(co_author_relation), :class => "bt-edit-type" %></td>
<td><%= link_to 'Destroy', desktop_co_author_relation_path(co_author_relation), confirm: 'Are you sure?', method: :delete, :class=>"bt-delete" %></td> <td><%= link_to 'Destroy', desktop_co_author_relation_path(co_author_relation), confirm: 'Are you sure?', method: :delete, :class=>"bt-delete" %></td>
</tr> </tr>
<% end %> <% end %>

View File

@ -1,3 +1,3 @@
<%= form_for(@co_author_relation, url: desktop_co_author_relation_path(@co_author_relation), html:{"form-type"=>"ajax_form", "callback-method"=>"coauthorRelationForm"} ) do |f| %> <%= form_for(@co_author_relation, url: desktop_co_author_relation_path(@co_author_relation), html:{"form-type"=>"ajax_form", "callback-method"=>"coauthorRelationEditForm"} ) do |f| %>
<%= render partial: 'desktop/co_author_relations/form' , locals: {:f => f}%> <%= render partial: 'desktop/co_author_relations/form' , locals: {:f => f}%>
<% end %> <% end %>