Revision 69f8d207
Added by Ohad Levy almost 14 years ago
- ID 69f8d207a4cc304775263680d6454a871042ecc9
app/controllers/puppetclasses_controller.rb | ||
---|---|---|
class PuppetclassesController < ApplicationController
|
||
def index
|
||
@puppetclasses = Puppetclass.search(params[:search]).paginate :page => params[:page], :per_page => 15
|
||
@search = Puppetclass.search params[:search]
|
||
@puppetclasses = @search.paginate :page => params[:page], :include => [:environments, :hostgroups, :operatingsystems]
|
||
end
|
||
|
||
def new
|
app/models/puppetclass.rb | ||
---|---|---|
name
|
||
end
|
||
|
||
def self.search(search)
|
||
if search
|
||
find(:all, :conditions => ['name LIKE ?', "%#{search}%"])
|
||
else
|
||
find(:all)
|
||
end
|
||
end
|
||
|
||
# returns a hash containing modules and associated classes
|
||
def self.classes2hash classes
|
||
hash = {}
|
||
... | ... | |
klass <=> other.klass
|
||
end
|
||
|
||
def self.per_page
|
||
20
|
||
end
|
||
|
||
end
|
app/views/puppetclasses/_search_line.html.erb | ||
---|---|---|
<% form_for @search do |f|-%>
|
||
<span title="A substring match">
|
||
<%= f.label :name_like, "Class" %>
|
||
<%= f.text_field :name_like, :size => 10 %>
|
||
<%= f.label :environments_id_eq, "Environment" %>
|
||
<%= f.collection_select :environments_id_eq, Environment.all, :id, :name, :include_blank => true %>
|
||
</span>
|
||
<%= f.submit "Go" %> Save as tab: <%= text_field_tag :tab_name, "", :size => 10 %>
|
||
<% end %>
|
app/views/puppetclasses/index.html.erb | ||
---|---|---|
<% title "Puppet classes" %>
|
||
<% form_tag puppetclasses_path, :method => 'get', :class => 'simple_search' do %>
|
||
<%= text_field_tag :search, params[:search] %>
|
||
<%= submit_tag "Search", :name => nil %>
|
||
<%= link_to_unless params[:search].empty?, "Clear", puppetclasses_path %>
|
||
<% end %>
|
||
<table class="list">
|
||
<tr>
|
||
<th>Name</th>
|
||
<th>Operatingsystems</th>
|
||
<th>Environments</th>
|
||
<th>Host Groups</th>
|
||
<th><%= order @search, :by => :name %></th>
|
||
<th>Operating Systems</th>
|
||
<th><%= order @search, :by => :environments_name, :as => "Environments" %></th>
|
||
<th>Host Group</th>
|
||
<th></th>
|
||
</tr>
|
||
<% for puppetclass in @puppetclasses %>
|
||
... | ... | |
|
||
<%= page_entries_info @puppetclasses %>
|
||
<%= will_paginate @puppetclasses %>
|
||
<p><%= link_to "New Puppetclass", new_puppetclass_path %> |
|
||
<%= link_to "Import new puppet classes and environments", import_environments_puppetclasses_path %>
|
||
</p>
|
||
<span class=title_action>
|
||
<%= link_to "New Puppetclass", new_puppetclass_path %> |
|
||
<%= link_to "Import new puppet classes and environments", import_environments_puppetclasses_path %>
|
||
</span>
|
||
|
Also available in: Unified diff
fixes #277 - add search options to puppet classes page