Revision 461:841b2e40895d vendor/plugins

View differences:

vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb
180 180
    
181 181
  end
182 182

  
183
  def review_new_entries
183
  
184
  def add_project
185
    Rails.logger.debug { "ADD PROJECT" }
186
    
187
    @project = Project.find(params[:project_id])    
188
    @publication = Publication.find(params[:id])
189
    
190
    @publication.projects << @project
191
    
192
  end
184 193

  
194

  
195
  def autocomplete_for_project
196
    # TODO luisf - Should This Be HERE???
197
    @publication = Publication.find(params[:id])
198
    
199
    @projects = Project.active.like(params[:q]).find(:all, :limit => 100) - @publication.projects
200
    logger.debug "Query for \"#{params[:q]}\" returned \"#{@projects.size}\" results"
201
    render :layout => false
185 202
  end
186 203
  
187
  
188 204
  private
189 205
   
190 206
  # TODO: luisf. - only here for debugging purposes 
vendor/plugins/redmine_bibliography/app/views/publications/new.html.erb
1 1
<h1>New Publication</h1>
2 2

  
3
<%= render :partial => 'edit' %>
3

  
4

  
5
<div class="splitcontentleft">
6
  <%= render :partial => 'edit' %>
7
</div>
8

  
9

  
10
<% projects = Project.active.find(:all, :limit => 100, :order => 'name ASC') - @publication.projects %>
11

  
12
<div class="splitcontentright">
13

  
14
  <% form_remote_for(:project, @project, 
15
                     :url => {:controller => 'publication', :action => 'new', :id => @publication.id, :project_id => @project}, 
16
                     :method => :post,
17
									   :loading => "$('project-add-submit').disable()",
18
									   :complete => "$('project-add-submit').enable()") do |f| %>
19
      
20
      <fieldset><legend><%=l(:label_add_project_to_publication)%></legend>
21
    
22
	      <p><%= label_tag "project_search", l(:label_project_search) %><%= text_field_tag 'project_search', nil %></p>
23
	     
24
	      <%= observe_field(:project_search,
25
               :frequency => 0.5,
26
               :update => :projects,
27
               :url => { :controller => 'publications', :action => 'autocomplete_for_project', :id => @publication, :project_id => @project},
28
               :with => 'q')
29
                %>
30

  
31
        <p><%= submit_tag l(:button_add), :id => 'project-add-submit' %></p>
32
    
33
    
34
      </fieldset>
35
  <% end %>
36
    
37
</div>
vendor/plugins/redmine_bibliography/config/locales/en.yml
8 8
  remove: "Remove"
9 9
  
10 10
  label_publication_new: "Add Publication"
11
  label_add_project_to_publication: "Add Project to Publication"
12
  label_project_search: "Search by name: "
11 13
  
12 14
      
13 15
  # bibtex_entries strings
vendor/plugins/redmine_bibliography/lib/bibliography/project_publications_patch.rb
5 5
    def self.included(base)
6 6
          base.class_eval do
7 7
            has_and_belongs_to_many :publications
8
          
9
            named_scope :like, lambda {|q| 
10
              s = "%#{q.to_s.strip.downcase}%"
11
              {:conditions => ["LOWER(name) LIKE :s OR LOWER(description) LIKE :s OR LOWER(homepage) LIKE :s", {:s => s}],
12
               :order => 'name'
13
              }
14
            }
8 15
          end
9
        end
16
    end #self.included
17
        
18
    module ProjectMethods
19

  
20

  
21

  
22
    
23
    end #ProjectMethods
10 24
  end #ProjectPublicationsPatch
11 25
end #RedmineBibliography

Also available in: Unified diff