Revision 1284:3ce07a57ce68
| plugins/redmine_bibliography/app/helpers/publications_helper.rb | ||
|---|---|---|
| 21 | 21 |
s |
| 22 | 22 |
end |
| 23 | 23 |
|
| 24 |
def choose_author_link(object_name, items) |
|
| 25 |
# called by autocomplete_for_author (publications' action/view) |
|
| 26 |
# creates the select list based on the results array |
|
| 27 |
# results is an array with both Users and Authorships objects |
|
| 28 | 24 |
|
| 29 |
@author_options = [] |
|
| 30 |
@results.each do |result| |
|
| 31 |
email_bit = result.mail.partition('@')[2]
|
|
| 32 |
if email_bit != "" |
|
| 33 |
email_bit = "(@#{email_bit})"
|
|
| 34 |
end |
|
| 35 |
@author_options << ["#{result.name} #{email_bit}", "#{result.class.to_s}_#{result.id.to_s}"]
|
|
| 36 |
end |
|
| 37 | 25 |
|
| 38 |
if @results.size > 0 |
|
| 39 |
s = select_tag( form_tag_name(object_name, :author_search_results), options_for_select(@author_options), { :id => form_tag_id(object_name, :author_search_results), :size => 3} )
|
|
| 40 |
else |
|
| 41 |
s = "<em>No Authors found that match your search… sorry!</em>" |
|
| 42 |
end |
|
| 43 |
end |
|
| 44 | 26 |
|
| 45 | 27 |
def link_to_remove_fields(name, f) |
| 46 | 28 |
f.hidden_field(:_destroy) + link_to_function(name, "remove_fields(this)", :class => 'icon icon-del') |
| ... | ... | |
| 77 | 59 |
str.to_sym |
| 78 | 60 |
end |
| 79 | 61 |
|
| 62 |
####### |
|
| 63 |
### DELETE ME |
|
| 64 |
|
|
| 65 |
def choose_author_link(object_name, items) |
|
| 66 |
# called by autocomplete_for_author (publications' action/view) |
|
| 67 |
# creates the select list based on the results array |
|
| 68 |
# results is an array with both Users and Authorships objects |
|
| 69 |
|
|
| 70 |
@author_options = [] |
|
| 71 |
@results.each do |result| |
|
| 72 |
email_bit = result.mail.partition('@')[2]
|
|
| 73 |
if email_bit != "" |
|
| 74 |
email_bit = "(@#{email_bit})"
|
|
| 75 |
end |
|
| 76 |
@author_options << ["#{result.name} #{email_bit}", "#{result.class.to_s}_#{result.id.to_s}"]
|
|
| 77 |
end |
|
| 78 |
|
|
| 79 |
if @results.size > 0 |
|
| 80 |
s = select_tag( form_tag_name(object_name, :author_search_results), options_for_select(@author_options), { :id => form_tag_id(object_name, :author_search_results), :size => 3} )
|
|
| 81 |
else |
|
| 82 |
s = "<em>No Authors found that match your search… sorry!</em>" |
|
| 83 |
end |
|
| 84 |
end |
|
| 85 |
|
|
| 86 |
|
|
| 87 |
|
|
| 80 | 88 |
def render_authorships_list(publication) |
| 81 | 89 |
s = '<p>' |
| 82 | 90 |
|
| plugins/redmine_bibliography/app/views/publications/autocomplete_for_author.html.erb | ||
|---|---|---|
| 2 | 2 |
'id' => result.id, |
| 3 | 3 |
'label' => "#{result.name} (#{result.mail.partition('@')[2]})",
|
| 4 | 4 |
'value' => result.name, |
| 5 |
'type' => result.class, |
|
| 5 |
'type' => result.class.name, |
|
| 6 |
'institution' => result.institution, |
|
| 7 |
'email' => result.mail, |
|
| 6 | 8 |
} |
| 7 | 9 |
}.to_json |
| 8 |
%> |
|
| 10 |
%> |
|
| plugins/redmine_bibliography/assets/javascripts/authors.js | ||
|---|---|---|
| 15 | 15 |
} |
| 16 | 16 |
|
| 17 | 17 |
$(".author_search").live('keyup.autocomplete', function(){
|
| 18 |
$(this).autocomplete({
|
|
| 18 |
$this = $(this); |
|
| 19 |
|
|
| 20 |
$this.autocomplete({
|
|
| 19 | 21 |
source: '/publications/autocomplete_for_author', |
| 20 | 22 |
minLength: 2, |
| 21 | 23 |
select: function(event, ui){
|
| 22 |
alert("gOtChA " + ui.item.id + " " + ui.item.type);
|
|
| 24 |
$this.closest('div').next().find("input[id$='name_on_paper']").val(ui.item.value);
|
|
| 25 |
$this.closest('div').next().find("input[id$='institution']").val(ui.item.institution);
|
|
| 26 |
$this.closest('div').next().find("input[id$='email']").val(ui.item.email);
|
|
| 23 | 27 |
} |
| 24 | 28 |
}); |
| 25 | 29 |
}); |
| 26 | 30 |
|
| 31 |
|
|
| 32 |
|
|
| 33 |
|
|
| 27 | 34 |
function identify_author_status(status, object_id) {
|
| 28 | 35 |
$('publication_authorships_attributes_' + object_id + '_edit_author_info').select('input').each(function(s) {
|
| 29 |
if(status == "no"){
|
|
| 30 |
s.value = ""; |
|
| 31 |
s.readOnly = false; |
|
| 32 |
}; |
|
| 33 | 36 |
|
| 34 |
if(status == "correct"){s.readOnly = false;};
|
|
| 35 |
if(status == "yes"){s.readOnly = true;};
|
|
| 37 |
if(status == "no"){
|
|
| 38 |
s.value = ""; |
|
| 39 |
s.readOnly = false; |
|
| 40 |
} |
|
| 41 |
|
|
| 42 |
if(status == "correct"){
|
|
| 43 |
s.readOnly = false; |
|
| 44 |
} |
|
| 45 |
if(status == "yes"){
|
|
| 46 |
s.readOnly = true; |
|
| 47 |
} |
|
| 36 | 48 |
}); |
| 37 | 49 |
} |
| 38 | 50 |
|
| 39 | 51 |
function toggle_div(div_id){
|
| 40 |
Effect.toggle(div_id, "appear", {duration:0.3});
|
|
| 52 |
$("#" + div_id).toggle(0.3);
|
|
| 41 | 53 |
} |
| 42 | 54 |
|
| 43 | 55 |
function toggle_input_field(field){
|
| 44 |
if (field.classNames().inspect().include("readonly") == false){
|
|
| 56 |
if (field.classNames().inspect().include("readonly") === false){
|
|
| 45 | 57 |
field.readOnly = true; |
| 46 | 58 |
field.addClassName('readonly');
|
| 47 | 59 |
} else {
|
| 48 | 60 |
field.readOnly = false; |
| 49 | 61 |
field.removeClassName('readonly');
|
| 50 |
};
|
|
| 62 |
} |
|
| 51 | 63 |
} |
| 52 | 64 |
|
| 53 | 65 |
function toggle_edit_save_button(object_id){
|
Also available in: Unified diff