«
Previous
|
Next
»
Revision 252572a7
Added by Marc Dequènes over 14 years ago
- ID 252572a7aece016a792e64af529c64daecc5b809
app/controllers/admin/artworks_controller.rb | ||
---|---|---|
simple_rest_support
|
||
|
||
before_filter :load_form_data, :only => [:new, :create, :edit, :update]
|
||
before_filter :load_data, :only => [:index]
|
||
|
||
SELECTION_ACTION_LIST = [[_('Associate with Tag'), 'associate_with_tag'], [_('Delete'), 'delete']]
|
||
|
||
def index
|
||
@selection_action_list = SELECTION_ACTION_LIST
|
||
end
|
||
|
||
def artworks_selection
|
||
if Hash[SELECTION_ACTION_LIST].values.include? params['artworks_selection_action']
|
||
@action = "selection_" + params['artworks_selection_action']
|
||
... | ... | |
redirect_to :action => "index"
|
||
end
|
||
|
||
def search
|
||
find_model(true)
|
||
|
||
if params[:action] == "search" and not params[:search_pattern].blank?
|
||
load_data([ "title LIKE ?", "%#{params[:search_pattern]}%"])
|
||
flash[:notice] = _("Nothing found") if @artworks.empty?
|
||
else
|
||
flash[:warning] = _("Empty search pattern !")
|
||
load_data
|
||
end
|
||
render :action => 'index'
|
||
end
|
||
|
||
protected
|
||
|
||
private
|
||
|
||
def load_data(conditions = [])
|
||
# work around 'sortable-list' plugin not enforcing default sort
|
||
params[:sort] ||= "title ASC"
|
||
|
||
@artworks = resource_model.paginate(:all, :conditions => conditions, :include => [:artwork_set, :artwork_group], :order => params[:sort], :page => params[:page])
|
||
@selection_action_list = SELECTION_ACTION_LIST
|
||
end
|
||
|
||
def load_form_data
|
||
@artwork_sets = ArtworkSet.find(:all, :order => "name ASC")
|
||
@artwork_materials = ArtworkMaterial.find(:all, :order => "name ASC")
|
app/helpers/application_helper.rb | ||
---|---|---|
link_to text, resource_path(obj)
|
||
end
|
||
|
||
def link_to_resource_index(text)
|
||
link_to(display_icon_tag('actions/document-open', :medium, :title => text) +
|
||
" <span class=\"middle\">" + text + "</span>", resource_index_path)
|
||
def link_to_resource_index(text, with_icon = true)
|
||
txt = (with_icon) ?
|
||
display_icon_tag('actions/document-open', :medium, :title => text) + " <span class=\"middle\">" + text + "</span>" :
|
||
text
|
||
link_to(txt, resource_index_path)
|
||
end
|
||
|
||
def display_alert(text)
|
app/views/admin/artworks/index.rhtml | ||
---|---|---|
<% use_proto_menu -%>
|
||
<h2><%= _("List of Artworks") %></h2>
|
||
<h2><%= link_to_resource_index _("List of Artworks"), false %> <sub>(<%= @artworks.size %>)</sub></h2>
|
||
|
||
<p>
|
||
<%
|
||
# work around 'sortable-list' plugin not enforcing default sort
|
||
params[:sort] ||= "title ASC"
|
||
%>
|
||
<% @artworks = resource_model.paginate(:all, :include => [:artwork_set, :artwork_group], :order => params[:sort], :page => params[:page]) %>
|
||
<div class="right_inset">
|
||
<% form_tag(:action => 'search') do -%>
|
||
<%= text_field_tag 'search_pattern', params['search_pattern'], :size => 16, :maxlength => 32 %>
|
||
<%= submit_tag 'Search' %>
|
||
<% end -%>
|
||
</div>
|
||
<%= display_new_action %>
|
||
<%= will_paginate @artworks %>
|
||
<% unless @artworks.empty? -%>
|
||
<div style="clear: both;"><%= will_paginate @artworks %></div>
|
||
<% form_tag({ :action => 'artworks_selection' }, { :id => 'artworks_selection_form' }) do %>
|
||
<table id="artworks_selection_zone">
|
||
<tr>
|
||
... | ... | |
<% end %>
|
||
<%= will_paginate @artworks %>
|
||
<%= display_new_action %>
|
||
<% end -%>
|
||
</p>
|
public/stylesheets/default.css | ||
---|---|---|
margin: 0;
|
||
}
|
||
|
||
div.right_inset
|
||
{
|
||
float: right;
|
||
margin: 0px 10px 0px 10px;
|
||
}
|
||
|
||
div.inline
|
||
{
|
||
float: left;
|
Also available in: Unified diff
[evol] added a simple search feature for artworks (with count)