Revision 1274:5ea1a213c7a5 plugins
| plugins/redmine_bibliography/app/controllers/publications_controller.rb | ||
|---|---|---|
| 5 | 5 |
unloadable |
| 6 | 6 |
|
| 7 | 7 |
model_object Publication |
| 8 |
before_filter :find_model_object, :except => [:new, :create, :index, :get_bibtex_required_fields, :autocomplete_for_project, :add_author, :sort_author_order, :autocomplete_for_author, :get_user_info ] |
|
| 8 |
# before_filter :find_model_object, :except => [:new, :create, :index, :show_bibtex_fields, :autocomplete_for_project, :add_author, :sort_author_order, :autocomplete_for_author, :get_user_info ] |
|
| 9 |
|
|
| 9 | 10 |
before_filter :find_project_by_project_id, :authorize, :only => [ :edit, :new, :update, :create ] |
| 10 | 11 |
|
| 11 | 12 |
def new |
| ... | ... | |
| 60 | 61 |
end |
| 61 | 62 |
end |
| 62 | 63 |
|
| 63 |
def get_bibtex_required_fields |
|
| 64 |
def show_bibtex_fields |
|
| 65 |
@fields = [] |
|
| 64 | 66 |
|
| 65 | 67 |
unless params[:value].empty? |
| 66 |
fields = BibtexEntryType.fields(params[:value]) |
|
| 68 |
@fields = BibtexEntryType.fields(params[:value])
|
|
| 67 | 69 |
end |
| 68 | 70 |
|
| 69 | 71 |
respond_to do |format| |
| 70 | 72 |
format.js {
|
| 71 |
render(:update) {|page|
|
|
| 72 |
if params[:value].empty? |
|
| 73 |
page << "hideOnLoad();" |
|
| 74 |
else |
|
| 75 |
page << "show_required_bibtex_fields(#{fields.to_json()});"
|
|
| 76 |
end |
|
| 77 |
} |
|
| 73 |
render :show_bibtex_fields |
|
| 78 | 74 |
} |
| 79 |
|
|
| 80 | 75 |
end |
| 81 | 76 |
end |
| 82 | 77 |
|
| plugins/redmine_bibliography/app/views/publications/_authorship_fields.html.erb | ||
|---|---|---|
| 7 | 7 |
<div id="<%= form_tag_id( f.object_name, :search_author ) %>" style=<%= "display:none;" unless params[:action] == "new" %> > |
| 8 | 8 |
<p> |
| 9 | 9 |
<%= f.text_field :search_name, :size => 25 %> |
| 10 |
<%= observe_field( form_tag_id(f.object_name, :search_name), :frequency => 0.5, :update => form_tag_id( f.object_name, :search_results), :url => { :controller => 'publications', :action => 'autocomplete_for_author', :object_name => form_object_id(f.object_name) }, :with => 'q' ) %>
|
|
| 11 |
</p> |
|
| 12 |
<%# link_to_function l(:label_author_is_me), "update_author_info(this," + User.current.get_author_info.to_json + ")", :id => "add_me_as_author" %> |
|
| 13 |
|
|
| 14 |
<p> |
|
| 15 |
<%= f.select :search_results, options_for_select(@author_options), {}, {:size => 5,
|
|
| 16 |
:onChange => remote_function( :url => { :controller => :publications, :action => :get_user_info, :object_id => form_object_id(f.object_name) }, :with => "'value=' +
|
|
| 17 |
value" )} %> |
|
| 18 |
</p> |
|
| 10 |
<p> |
|
| 11 |
<%= f.select :search_results, options_for_select(@author_options) %> |
|
| 12 |
</p> |
|
| 19 | 13 |
|
| 20 | 14 |
<p style="margin-bottom: -2.5em; padding-bottom; 0"><label><%= l(:identify_author_question) %></label></p> |
| 21 | 15 |
<p class="author_identify"> |
| 22 | 16 |
<label class='inline'><%= radio_button_tag(:identify_author, "yes", false, :name => form_tag_name(f.object_name,:identify_author ), :id => form_tag_id( f.object_name, :identify_author_yes ), :onchange => "identify_author_status($(this).value, #{form_object_id(f.object_name) });") %> <%= l(:identify_author_yes) %> </label><br />
|
| 23 |
|
|
| 17 |
|
|
| 24 | 18 |
<label class='inline'><%= radio_button_tag(:identify_author, "correct", false, :name => form_tag_name(f.object_name,:identify_author ), :id => form_tag_id( f.object_name, :identify_author_corrections ), :onchange => "identify_author_status($(this).value, #{form_object_id(f.object_name) });") %> <%= l(:identify_author_correct) %> </label><br />
|
| 25 |
|
|
| 19 |
|
|
| 26 | 20 |
<label class='inline'><%= radio_button_tag(:identify_author, "no", true, :name => form_tag_name(f.object_name,:identify_author ), :id => form_tag_id( f.object_name, :identify_author_no ), :onchange => "identify_author_status($(this).value, #{form_object_id(f.object_name) });") %> <%= l(:identify_author_no) %> </label><br />
|
| 27 | 21 |
</p> |
| 28 |
</div>
|
|
| 29 |
|
|
| 22 |
</div> |
|
| 23 |
|
|
| 30 | 24 |
<div class='author_edit' id="<%= form_tag_id( f.object_name, :edit_author_info ) %>"> |
| 31 | 25 |
<p> |
| 32 | 26 |
<%= f.text_field :name_on_paper, {:class => ("readonly" unless params[:action] == "new") } %></p>
|
| ... | ... | |
| 37 | 31 |
<p class='description' style=<%= "display:none;" unless params[:action] == "new" %>><%= h l("text_author_email") %></p>
|
| 38 | 32 |
</p> |
| 39 | 33 |
</div> |
| 40 |
|
|
| 34 |
|
|
| 41 | 35 |
|
| 42 | 36 |
<div class="box" id="<%= form_tag_id( f.object_name, :show_author_info ) %>" style="display: none"> |
| 43 |
|
|
| 37 |
|
|
| 44 | 38 |
</div> |
| 45 | 39 |
|
| 46 | 40 |
<p> |
| plugins/redmine_bibliography/app/views/publications/_bibtex_fields.html.erb | ||
|---|---|---|
| 1 | 1 |
<p> |
| 2 | 2 |
<label for="bibtex_entry_type"><%=l("field_entry_type")%> <span class="required">*</span></label>
|
| 3 |
<%= f.collection_select :entry_type, |
|
| 4 |
BibtexEntryType.find(:all).reject { |x| x.redundant? },
|
|
| 5 |
:id, |
|
| 6 |
:label, |
|
| 7 |
{ :selected => @selected_bibtex_entry_type_id, :prompt => true },
|
|
| 8 |
:onChange => remote_function( :url => { :controller => :publications, :action => :get_bibtex_required_fields}, :with => "'value=' + value" )
|
|
| 9 |
%> |
|
| 3 |
<%= f.collection_select :entry_type, |
|
| 4 |
BibtexEntryType.find(:all).reject { |x| x.redundant? },
|
|
| 5 |
:id, |
|
| 6 |
:label, |
|
| 7 |
{ :selected => @selected_bibtex_entry_type_id, :prompt => true } %>
|
|
| 10 | 8 |
</p> |
| 11 | 9 |
|
| 12 |
<p class="bibtex hol">
|
|
| 13 |
<%= f.text_field :year, :size => 4 %>
|
|
| 10 |
<p class="bibtex hol"> |
|
| 11 |
<%= f.text_field :year, :size => 4 %> |
|
| 14 | 12 |
</p> |
| 15 |
<p class="bibtex hol">
|
|
| 16 |
<%= f.text_field :month, :size => 4%>
|
|
| 13 |
<p class="bibtex hol"> |
|
| 14 |
<%= f.text_field :month, :size => 4%> |
|
| 17 | 15 |
</p> |
| 18 |
<p class="bibtex hol"> |
|
| 19 |
<%= f.text_field :chapter, :size => 15%> |
|
| 20 |
</p> |
|
| 21 |
<p class="bibtex hol"> |
|
| 22 |
<%= f.text_field :editor, :size => 33 %> |
|
| 23 |
</p> |
|
| 24 |
<p class="bibtex hol"> |
|
| 25 |
<%= f.text_field :booktitle, :size => 33 %> |
|
| 26 |
</p> |
|
| 27 |
<p class="bibtex hol"> |
|
| 28 |
<%= f.text_field :publisher,:size => 33 %> |
|
| 29 |
</p> |
|
| 30 |
<p class="bibtex hol"> |
|
| 31 |
<%= f.text_field :pages, :size => 12 %> |
|
| 16 |
<p class="bibtex hol"> |
|
| 17 |
<%= f.text_field :chapter, :size => 15%> |
|
| 32 | 18 |
</p> |
| 33 |
<p class="bibtex hol"> |
|
| 19 |
<p class="bibtex hol"> |
|
| 20 |
<%= f.text_field :editor, :size => 33 %> |
|
| 21 |
</p> |
|
| 22 |
<p class="bibtex hol"> |
|
| 23 |
<%= f.text_field :booktitle, :size => 33 %> |
|
| 24 |
</p> |
|
| 25 |
<p class="bibtex hol"> |
|
| 26 |
<%= f.text_field :publisher,:size => 33 %> |
|
| 27 |
</p> |
|
| 28 |
<p class="bibtex hol"> |
|
| 29 |
<%= f.text_field :pages, :size => 12 %> |
|
| 30 |
</p> |
|
| 31 |
<p class="bibtex hol"> |
|
| 34 | 32 |
<%= f.text_field :address %> |
| 35 | 33 |
</p> |
| 36 |
<p class="bibtex hol">
|
|
| 34 |
<p class="bibtex hol"> |
|
| 37 | 35 |
<%= f.text_field :annote %> |
| 38 | 36 |
</p> |
| 39 |
<p class="bibtex hol">
|
|
| 37 |
<p class="bibtex hol"> |
|
| 40 | 38 |
<%= f.text_field :crossref %> |
| 41 | 39 |
</p> |
| 42 |
<p class="bibtex hol">
|
|
| 40 |
<p class="bibtex hol"> |
|
| 43 | 41 |
<%= f.text_field :edition %> |
| 44 | 42 |
</p> |
| 45 |
<p class="bibtex hol">
|
|
| 43 |
<p class="bibtex hol"> |
|
| 46 | 44 |
<%= f.text_field :eprint %> |
| 47 | 45 |
</p> |
| 48 |
<p class="bibtex hol">
|
|
| 46 |
<p class="bibtex hol"> |
|
| 49 | 47 |
<%= f.text_field :howpublished %> |
| 50 | 48 |
</p> |
| 51 |
<p class="bibtex hol">
|
|
| 49 |
<p class="bibtex hol"> |
|
| 52 | 50 |
<%= f.text_field :journal %> |
| 53 | 51 |
</p> |
| 54 |
<p class="bibtex hol">
|
|
| 52 |
<p class="bibtex hol"> |
|
| 55 | 53 |
<%= f.text_field :key %> |
| 56 | 54 |
</p> |
| 57 |
<p class="bibtex hol">
|
|
| 55 |
<p class="bibtex hol"> |
|
| 58 | 56 |
<%= f.text_field :note %> |
| 59 | 57 |
</p> |
| 60 |
<p class="bibtex hol">
|
|
| 58 |
<p class="bibtex hol"> |
|
| 61 | 59 |
<%= f.text_field :number %> |
| 62 | 60 |
</p> |
| 63 |
<p class="bibtex hol">
|
|
| 61 |
<p class="bibtex hol"> |
|
| 64 | 62 |
<%= f.text_field :organization %> |
| 65 | 63 |
</p> |
| 66 |
<p class="bibtex hol">
|
|
| 64 |
<p class="bibtex hol"> |
|
| 67 | 65 |
<%= f.text_field :school %> |
| 68 | 66 |
</p> |
| 69 |
<p class="bibtex hol">
|
|
| 67 |
<p class="bibtex hol"> |
|
| 70 | 68 |
<%= f.text_field :series %> |
| 71 | 69 |
</p> |
| 72 |
<p class="bibtex hol">
|
|
| 70 |
<p class="bibtex hol"> |
|
| 73 | 71 |
<%= f.text_field :type %> |
| 74 | 72 |
</p> |
| 75 |
<p class="bibtex hol">
|
|
| 73 |
<p class="bibtex hol"> |
|
| 76 | 74 |
<%= f.text_field :url %> |
| 77 | 75 |
</p> |
| 78 |
<p class="bibtex hol">
|
|
| 76 |
<p class="bibtex hol"> |
|
| 79 | 77 |
<%= f.text_field :volume %> |
| 80 | 78 |
</p> |
| plugins/redmine_bibliography/app/views/publications/_form.html.erb | ||
|---|---|---|
| 5 | 5 |
<div class="splitcontentleft"> |
| 6 | 6 |
<h3><%= l(:label_publication_other_details) %></h3> |
| 7 | 7 |
<div class="box tabular"> |
| 8 |
<% f.fields_for :bibtex_entry do |builder| -%> |
|
| 8 |
<%= f.fields_for :bibtex_entry do |builder| -%>
|
|
| 9 | 9 |
<%= render :partial => 'bibtex_fields', :locals => { :f => builder} %>
|
| 10 | 10 |
<%- end -%> |
| 11 | 11 |
|
| ... | ... | |
| 26 | 26 |
<div class="splitcontentright"> |
| 27 | 27 |
<h3><%= l(:authors) %></h3> |
| 28 | 28 |
<div class="box tabular"> |
| 29 |
<% f.fields_for :authorships do |builder| -%> |
|
| 29 |
<%= f.fields_for :authorships do |builder| -%>
|
|
| 30 | 30 |
<%= render "authorship_fields", :f => builder %> |
| 31 | 31 |
<%- end -%> |
| 32 | 32 |
<%= link_to_add_author_fields l(:label_add_an_author), f, :authorships, params[:action] %> |
| plugins/redmine_bibliography/app/views/publications/new.html.erb | ||
|---|---|---|
| 1 | 1 |
<% content_for :header_tags do %> |
| 2 | 2 |
<%= javascript_include_tag 'authors', :plugin => 'redmine_bibliography' %> |
| 3 |
<%= javascript_include_tag 'bibliography', :plugin => 'redmine_bibliography' %> |
|
| 3 | 4 |
<%= stylesheet_link_tag 'bibliography', :plugin => 'redmine_bibliography' %> |
| 4 | 5 |
<% end %> |
| 5 | 6 |
|
| 6 | 7 |
<h2><%=l(:label_publication_new)%></h2> |
| 7 | 8 |
|
| 8 |
<% labelled_form_for @publication, :url => { :project_id => @project, :action => :create } do |f| -%>
|
|
| 9 |
<%= render :partial => 'form', :locals => { :f => f } %>
|
|
| 10 |
<div style="clear:both"></div> |
|
| 11 |
<%= f.submit %> |
|
| 9 |
<%= labelled_form_for @publication, :url => { :project_id => @project, :action => :create } do |f| -%>
|
|
| 10 |
<%= render :partial => 'form', :locals => { :f => f } %>
|
|
| 11 |
<div style="clear:both"></div>
|
|
| 12 |
<%= f.submit %>
|
|
| 12 | 13 |
<% end %> |
| plugins/redmine_bibliography/app/views/publications/show_bibtex_fields.js.erb | ||
|---|---|---|
| 1 |
fields = <%= @fields.to_json.html_safe -%>; |
|
| 2 |
|
|
| 3 |
$.each($(".bibtex"), function( key, value ) {
|
|
| 4 |
$this = $(this); |
|
| 5 |
|
|
| 6 |
input_id = $this.children('input').attr('id');
|
|
| 7 |
name = input_id.split('_')[4];
|
|
| 8 |
|
|
| 9 |
if ($.inArray(name, fields)){
|
|
| 10 |
$this.show(); |
|
| 11 |
} |
|
| 12 |
}); |
|
| plugins/redmine_bibliography/assets/javascripts/bibliography.js | ||
|---|---|---|
| 1 |
$("#publication_bibtex_entry_attributes_entry_type").live("change", function() {
|
|
| 2 |
console.log("AJAX RULEZ");
|
|
| 3 |
|
|
| 4 |
$.ajax({
|
|
| 5 |
type: "POST", |
|
| 6 |
url: "/publications/show_bibtex_fields", |
|
| 7 |
data: "value=" + $("#publication_bibtex_entry_attributes_entry_type").val(),
|
|
| 8 |
dataType: "script" |
|
| 9 |
}); |
|
| 10 |
|
|
| 11 |
return false; |
|
| 12 |
}); |
|
| 13 |
|
|
| plugins/redmine_bibliography/assets/javascripts/bibtex.js | ||
|---|---|---|
| 1 | 1 |
function toggleBibtex(el) {
|
| 2 |
var dd = Element.up(el).next('dd')
|
|
| 2 |
var dd = Element.up(el).next('dd');
|
|
| 3 | 3 |
|
| 4 | 4 |
dd.toggleClassName('collapsed');
|
| 5 | 5 |
Effect.toggle(dd, 'slide', {duration:0.2});
|
| plugins/redmine_bibliography/config/routes.rb | ||
|---|---|---|
| 1 | 1 |
RedmineApp::Application.routes.draw do |
| 2 | 2 |
resources :publications |
| 3 |
|
|
| 4 |
match "publications/show_bibtex_fields", :to => 'publications#show_bibtex_fields' |
|
| 5 |
|
|
| 6 |
|
|
| 3 | 7 |
end |
Also available in: Unified diff