add coauthor and coauthor relation function

This commit is contained in:
Rueshyna 2013-02-21 02:33:53 +08:00 committed by chris
parent 13c757e8a9
commit 4ee85a8c09
15 changed files with 257 additions and 3 deletions

View File

@ -0,0 +1,63 @@
class Panel::PersonalConference::Desktop::ConferenceCoAuthorRelationsController < ApplicationController
def index
@conference_co_author_relations = ConferenceCoAuthorRelation.all
new
respond_to do |format|
format.html {render layout: false }
end
end
def edit
@conference_co_author_relation = ConferenceCoAuthorRelation.find(params[:id])
respond_to do |format|
format.html { render :layout => false}
end
end
def new
@conference_co_author_relation = ConferenceCoAuthorRelation.new
end
def create
@conference_co_author_relation = ConferenceCoAuthorRelation.new(params[:conference_co_author_relation])
@conference_co_author_relations = ConferenceCoAuthorRelation.all
if @conference_co_author_relation.save
newv = render_to_string partial: "show_form", object: @conference_co_author_relations
render json: {success: true, msg: "New Relation successfully saved!", newvalue: newv}.to_json
else
error_msg = @conference_co_author_relation.errors.full_messages.join("<br />")
render json: {success: false, msg: error_msg}.to_json
end
end
def update
@conference_co_author_relation = ConferenceCoAuthorRelation.find(params[:id])
if @conference_co_author_relation.update_attributes(params[:conference_co_author_relation])
@conference_co_author_relations = ConferenceCoAuthorRelation.all
newv = render_to_string partial: "show_form", object: @conference_co_author_relations
render json: {success: true, msg: "New Relation successfully updated!", newvalue: newv}.to_json
else
error_msg = @conference_co_author.errors.full_messages.join("<br />")
render json: {success: false, msg: error_msg}.to_json
end
end
def destroy
@conference_co_author_relation = ConferenceCoAuthorRelation.find(params[:id])
@conference_co_author_relation.destroy
reset_co_author_relation
render :json => {success: true, msg: "deleted successfully!"}
end
private
def reset_co_author_relation
co_author = ConferenceCoAuthor.where(co_author_relations_id: @co_author_relation.id)
co_author.map do |c|
c.update_attributes(co_author_relations_id: nil)
end
end
end

View File

@ -0,0 +1,59 @@
class Panel::PersonalConference::Desktop::ConferenceCoAuthorsController < ApplicationController
def index
nils, not_nils = ConferenceCoAuthor.where(name_id: current_user.id)\
.asc(:co_author).partition{|p| p.email.nil?}
@conference_co_authors = not_nils + nils
@conference_co_author_relations = ConferenceCoAuthorRelation.all
respond_to do |format|
format.html { render :layout => false}
end
end
def new
@conference_co_author = ConferenceCoAuthor.new
@conference_co_author_relations = ConferenceCoAuthorRelation.all
respond_to do |format|
format.html { render :layout => false}
end
end
def edit
@conference_co_author = ConferenceCoAuthor.find(params[:id])
@conference_co_author_relations = ConferenceCoAuthorRelation.all
respond_to do |format|
format.html { render :layout => false}
end
end
def create
@conference_co_author = ConferenceCoAuthor.new(params[:conference_co_author])
@conference_co_author.name_id= current_user.id
if @conference_co_author.save
render json: {success:true, msg: t('create.sucess.co_author')}.to_json
else
error_msg = @conference_co_author.errors.full_messages.join("<br />")
render json: {success: false, msg: error_msg}.to_json
end
end
def update
@conference_co_author = ConferenceCoAuthor.find(params[:id])
if @conference_co_author.update_attributes(params[:co_author])
render json: {success:true, msg: t('update.sucess.co_author')}.to_json
else
error_msg = @conference_co_author.errors.full_messages.join("<br />")
render json: {success: false, msg: error_msg}.to_json
end
end
def destroy
@conference_co_author = ConferenceCoAuthor.find(params[:id])
@conference_co_author.destroy
render :json => {success: true, msg: "Co-author deleted successfully!"}
end
end

View File

@ -0,0 +1,11 @@
<%= f.text_field :relation %>
<!--
<#%= f.fields_for :relation_translations do |f| %>
<#%= f.text_field locale,
value: (@conference_co_author_relation.relation_translations[locale] rescue nil) %>
<#% end %>
-->
<%= f.submit "Save", class: "ini_input hp hh2 thmtxt thmc2", style: "margin-left: 10px;" %>
<% if not @conference_co_author_relation.new_record? %>
<%= submit_tag "Cancel", :type => "button", class: "bt-cancel-type ini_input hp hh2 thmtxt" %>
<% end %>

View File

@ -0,0 +1,3 @@
<%= form_for(@conference_co_author_relation, url: panel_personal_conference_desktop_conference_co_author_relations_path, html:{"form-type"=>"ajax_form", "callback-method"=>"coauthorRelationForm"} ) do |f| %>
<%= render partial: 'form' , locals: {:f => f}%>
<% end %>

View File

@ -0,0 +1,17 @@
<% @conference_co_author_relations.each_with_index do |conference_co_author_relation,i| %>
<% if ( i % 6 ) == 0 %>
<div class="s_grid_con s_form">
<ul>
<% end %>
<li class="s_grid_row">
<div class="form_space" id="form_space_<%= i.to_s %>"><%= conference_co_author_relation.relation %></div>
<div class="list_item_function">
<%= link_to 'Edit', edit_panel_personal_conference_desktop_conference_co_author_relation_path(conference_co_author_relation), :class => "bt-edit-type admbg2 admtxt", "content-holder"=>"#form_space_"+i.to_s, "ajax-remote"=>"get" %>
<%= link_to 'Destroy', panel_personal_conference_desktop_conference_co_author_relation_path(conference_co_author_relation), "confirm-message"=>'Are you sure?', "ajax-remote"=>"delete", :class=>"bt-delete admbg2 admtxt" %>
</div>
</li>
<% if ( i % 6 ) == 5 %>
</ul>
</div>
<% end %>
<% end %>

View File

@ -0,0 +1,3 @@
<%= form_for(@conference_co_author_relation, url: panel_personal_conference_desktop_conference_co_author_relation_path(@conference_co_author_relation), html:{"form-type"=>"ajax_form", "callback-method"=>"coauthorRelationEditForm"} ) do |f| %>
<%= render partial: 'form' , locals: {:f => f}%>
<% end %>

View File

@ -0,0 +1,22 @@
<div class="toolbar hh2">
<div class="fn_g hp">
<div class="hh2 sdm">
<div class="sdm_t hp hh2 thmc2 thmtxt">Create</div>
<div class="admbg sdm_o">
<ul>
<li class="vp hp s_form" style="width:282px;"><%= render 'new' %></li>
</ul>
</div>
</div>
<%= submit_tag "Back", :type => "button", class: "bt-cancel fn_btn ini_input hp hh2 thmtxt" %>
</div>
</div>
<div id="co_author_relation_table" class="tinycanvas vp">
<div class="scrollbar sb_h vp"><div class="track"><div class="thumb thmc2"><div class="end"></div></div></div></div>
<div class="viewport">
<div class="overview">
<%= render :partial => 'show_form'%>
</div>
</div>
</div>

View File

@ -0,0 +1,35 @@
<div class="toolbar hh2">
<div class="fn_g hp">
<%= f.submit "Save", name: "commit", value: "Save", class: "fn_btn ini_input hp hh2 thmc2 thmtxt" %>
<%= submit_tag "Cancel", :type => "button", class: "bt-cancel fn_btn ini_input hp hh2 thmtxt" %>
</div>
</div>
<div id="new_co_author" class="s_grid_con s_form vp">
<ul>
<li class="s_grid_row">
<%= f.label :co_author, class: "s_grid s_grid_2" %>
<%= f.text_field :co_author, class: "s_grid_4 s_grid"%>
<!--
<%#= f.fields_for :co_author_translations do |f| %>
<%#= f.text_field locale,
class: "s_grid_4 s_grid",
value: (@conference_co_author.co_author_translations[locale] rescue nil) %>
<%# end %>
-->
</li>
<li class="s_grid_row">
<%= f.label :email, class: "s_grid s_grid_2"%>
<%= f.text_field :email, class: "s_grid s_grid_4" %>
</li>
<li class="s_grid_row">
<%= f.label :type, class: "s_grid s_grid_2"%>
<select name="conference_co_author[co_author_relations_id]" id="" class="s_grid s_grid_4">
<%= options_for_select(
@conference_co_author_relations.map do |relation|
[relation.relation, relation.id]
end
)%>
</select>
</li>
</ul>
</div>

View File

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

View File

@ -0,0 +1,34 @@
<div class="toolbar hh2">
<div class="fn_g hp">
<%= link_to "New Co-Author", new_panel_personal_conference_desktop_conference_co_author_path, :class=>"bt-co-author fn_btn hp hh2 thmc2 thmtxt", "ajax-remote"=>"get" %>
<%= link_to "New Type", panel_personal_conference_desktop_conference_co_author_relations_path, :class=>"bt-new-type fn_btn hp hh2 thmc2 thmtxt", "ajax-remote"=>"get" %>
</div>
</div>
<div id="co_author" class="tinycanvas vp">
<div class="scrollbar sb_h vp"><div class="track"><div class="thumb thmc2"><div class="end"></div></div></div></div>
<div class="viewport">
<div class="overview">
<% @conference_co_authors.each_with_index do |co_author,i| %>
<% if ( i % 4 ) == 0 %>
<div class="g_col">
<ul>
<% end %>
<li class="list_t_item">
<ul class="info">
<li><div class="name"><%= co_author.co_author %></div></li>
<li><div class="email"><i class="icon-envelope"></i> <%= co_author.email %></div></li>
<li><div class="relations"><i class="icon-user"></i> <%= @conference_co_author_relations.find(co_author.conference_co_author_relations_id).relation unless co_author.conference_co_author_relations_id.nil?%></div></li>
</ul>
<div class="list_item_function">
<%= link_to 'Edit', edit_panel_personal_conference_desktop_conference_co_author_path(co_author), :class => "bt-edit admbg2 admtxt", "ajax-remote"=>"get" %>
<%= link_to 'Destroy', panel_personal_conference_desktop_conference_co_author_path(co_author), "ajax-remote"=>"delete", "confirm-message"=>'Are you sure?', "callback-method"=>"paperDelete", :class=>"bt-delete admbg2 admtxt" %>
</div>
</li>
<% if ( i % 4 ) == 3 %>
</ul>
</div>
<% end %>
<% end %>
</div>
</div>
</div>

View File

@ -0,0 +1,3 @@
<%= form_for @conference_co_author, html: { multipart: true ,"form-type"=>"ajax_form", "callback-method"=>"conferenceCoAuthorformCallback"} , url: panel_personal_conference_desktop_conference_co_authors_path do |f| %>
<%= render partial: 'form', locals: {:f => f} %>
<% end %>

View File

@ -16,7 +16,7 @@
<li><a href="<%= panel_personal_conference_desktop_conference_pages_path %>" load="true" callback-method="list" class="hh2 w2 hp active thmc1 thmtxt" onclick='return false;'>List</a></li>
<li><a href="<%= new_panel_personal_conference_desktop_conference_page_path %>" callback-method="addconference" custom-load="add" class="admtxt hh2 w2 hp" onclick='return false;'>Add/Edit</a></li>
<li><a href="<%= panel_personal_conference_desktop_conference_type_path %>" callback-method="conference" class="admtxt hh2 w2 hp" onclick='return false;'>Conference</a></li>
<li><a href="" callback-method="coauthor" class="admtxt hh2 w2 hp" onclick='return false;'>Co-Authors</a></li>
<li><a href="<%= panel_personal_conference_desktop_conference_co_authors_path %>" callback-method="coauthor" class="admtxt hh2 w2 hp" onclick='return false;'>Co-Authors</a></li>
<li><a href="" class="admtxt hh2 w2 hp" onclick='return false;'>Tags &amp; Keywords</a></li>
<li><a href="" class="admtxt hh2 w2 hp" onclick='return false;'>Analysis</a></li>
<li><a href="" class="admtxt hh2 w2 hp" onclick='return false;'>Import</a></li>

View File

@ -5,7 +5,9 @@ Rails.application.routes.draw do
namespace :desktop do
match 'conference_window' => 'conference_windows#conference_window'
match 'conference_type' => 'conference_pages#conference_type'
resources :conference_pages
resources :conference_pages, except: :show
resources :conference_co_authors, except: :show
resources :conference_co_author_relations, except: :show
end
namespace :back_end do
match 'writing_conference_setting' => "writing_conferences#writing_conference_setting" ,:as => :writing_conference_setting

View File

@ -22,7 +22,6 @@ class Panel::PersonalJournal::Desktop::JournalCoAuthorRelationsController < Appl
def create
@journal_co_author_relation = JournalCoAuthorRelation.new(params[:journal_co_author_relation])
@journal_co_author_relations = JournalCoAuthorRelation.all
binding.pry
if @journal_co_author_relation.save
newv = render_to_string partial: "show_form", object: @journal_co_author_relations