Revision 1286:d0d6bbe9f2e0
| plugins/redmine_bibliography/app/models/authorship.rb | ||
|---|---|---|
| 9 | 9 |
|
| 10 | 10 |
validates_presence_of :name_on_paper |
| 11 | 11 |
|
| 12 |
attr_accessor :is_user, :author_user_id, :search_name, :identify_author, :search_results
|
|
| 12 |
attr_accessor :search_author_class, :search_author_id, :search_name, :search_results, :identify_author
|
|
| 13 | 13 |
before_save :associate_author_user |
| 14 | 14 |
|
| 15 | 15 |
# todo: review usage of scope --lf.20130108 |
| ... | ... | |
| 43 | 43 |
|
| 44 | 44 |
protected |
| 45 | 45 |
def associate_author_user |
| 46 |
case self.identify_author
|
|
| 47 |
when "no"
|
|
| 46 |
case self.search_author_class
|
|
| 47 |
when "User"
|
|
| 48 | 48 |
author = Author.new |
| 49 | 49 |
author.save |
| 50 | 50 |
self.author_id = author.id |
| 51 | 51 |
else |
| 52 | 52 |
selected = self.search_results |
| 53 |
selected_classname = Kernel.const_get(selected.split('_')[0])
|
|
| 54 |
selected_id = selected.split('_')[1]
|
|
| 53 |
selected_classname = Kernel.const_get(self.search_author_class)
|
|
| 54 |
selected_id = self.search_author_id
|
|
| 55 | 55 |
object = selected_classname.find(selected_id) |
| 56 | 56 |
|
| 57 | 57 |
if object.respond_to? :name_on_paper |
| plugins/redmine_bibliography/app/views/publications/_authorship_fields.html.erb | ||
|---|---|---|
| 27 | 27 |
<p><%= f.text_field :email, {:class => ("readonly" unless params[:action] == "new") } %></p>
|
| 28 | 28 |
<p class='description' style=<%= "display:none;" unless params[:action] == "new" %>><%= h l("text_author_email") %></p>
|
| 29 | 29 |
</p> |
| 30 |
<%= hidden_field_tag(:object_class, '', :name => form_tag_name(f.object_name,:object_class ), :id => form_tag_id( f.object_name, :object_class )) -%>
|
|
| 30 |
<%= hidden_field_tag(:search_author_class, '', :name => form_tag_name(f.object_name,:search_author_class ), :id => form_tag_id( f.object_name, :search_author_class )) -%>
|
|
| 31 | 31 |
|
| 32 |
<%= hidden_field_tag(:search_author_id, '', :name => form_tag_name(f.object_name,:search_author_id ), :id => form_tag_id( f.object_name, :search_author_id )) -%> |
|
| 32 | 33 |
</div> |
| 33 | 34 |
|
| 34 | 35 |
|
| plugins/redmine_bibliography/app/views/publications/autocomplete_for_author.html.erb | ||
|---|---|---|
| 1 | 1 |
<%= raw @results.map {|result| {
|
| 2 |
'id' => result.id, |
|
| 3 | 2 |
'label' => "#{result.name} (#{result.mail.partition('@')[2]})",
|
| 4 | 3 |
'value' => result.name, |
| 5 |
'object_class' => result.class.name, |
|
| 4 |
'search_author_class' => result.class.name, |
|
| 5 |
'search_author_id' => result.id, |
|
| 6 | 6 |
'institution' => result.institution, |
| 7 | 7 |
'email' => result.mail, |
| 8 | 8 |
} |
| plugins/redmine_bibliography/assets/javascripts/authors.js | ||
|---|---|---|
| 24 | 24 |
$this.closest('div').next().find("input[id$='name_on_paper']").val(ui.item.value);
|
| 25 | 25 |
$this.closest('div').next().find("input[id$='institution']").val(ui.item.institution);
|
| 26 | 26 |
$this.closest('div').next().find("input[id$='email']").val(ui.item.email);
|
| 27 |
$this.closest('div').next().find("input[id$='object_class']").val(ui.item.object_class);
|
|
| 27 |
$this.closest('div').next().find("input[id$='search_author_class']").val(ui.item.search_author_class);
|
|
| 28 |
$this.closest('div').next().find("input[id$='search_author_id']").val(ui.item.search_author_id);
|
|
| 28 | 29 |
} |
| 29 | 30 |
}); |
| 30 | 31 |
}); |
| ... | ... | |
| 66 | 67 |
function toggle_edit_save_button(object_id){
|
| 67 | 68 |
$button = $('publication_authorships_attributes_' + object_id + '_edit_save_button');
|
| 68 | 69 |
if ($button.value == "Edit author"){
|
| 69 |
$button.value = "Save author";
|
|
| 70 |
$button.value = "Save author";
|
|
| 70 | 71 |
} else {
|
| 71 |
$button.value = "Edit author";
|
|
| 72 |
};
|
|
| 72 |
$button.value = "Edit author";
|
|
| 73 |
} |
|
| 73 | 74 |
} |
| 74 | 75 |
|
| 75 | 76 |
function toggle_save_author(form_object_id, $this){
|
| plugins/redmine_bibliography/lib/bibliography/user_author_patch.rb | ||
|---|---|---|
| 22 | 22 |
return institution_name |
| 23 | 23 |
end |
| 24 | 24 |
|
| 25 |
def get_author_info |
|
| 26 |
# TODO: DELETE THIS METHOD?? |
|
| 27 |
info = {
|
|
| 28 |
:name_on_paper => self.name, |
|
| 29 |
:email => self.mail, |
|
| 30 |
:institution => "", |
|
| 31 |
:author_user_id => self.id, |
|
| 32 |
:is_user => "1" |
|
| 33 |
} |
|
| 34 |
|
|
| 35 |
if not self.ssamr_user_detail.nil? |
|
| 36 |
info[:institution] = self.ssamr_user_detail.institution_name |
|
| 37 |
end |
|
| 38 |
|
|
| 39 |
return info |
|
| 40 |
end |
|
| 41 |
|
|
| 42 | 25 |
end #InstanceMethods |
| 43 | 26 |
|
| 44 | 27 |
end #UserPublicationsPatch |
Also available in: Unified diff