«
Previous
|
Next
»
Revision 252572a7
Added by Marc Dequènes over 13 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")
|
Also available in: Unified diff
[evol] added a simple search feature for artworks (with count)