Revision bf16d414
Added by Marc Dequènes almost 14 years ago
- ID bf16d41408b3309a93dcd0dd0723a4d478023818
app/controllers/admin/artworks_controller.rb | ||
---|---|---|
|
||
before_filter :load_form_data, :only => [:new, :create, :edit, :update]
|
||
|
||
SELECTION_ACTION_LIST = [[_('Associate with Tag'), 'associate_with_tag'], [_('Delete'), 'delete']]
|
||
|
||
def index
|
||
@selection_action_list = SELECTION_ACTION_LIST
|
||
end
|
||
|
||
def artworks_selection
|
||
item_list = params['artworks_selection_items'].collect {|x| x.to_i }
|
||
if Hash[SELECTION_ACTION_LIST].values.include? params['artworks_selection_action']
|
||
@action = "selection_" + params['artworks_selection_action']
|
||
|
||
case params['artworks_selection_action']
|
||
when 'to_tag'
|
||
render :text => "Action: assign Artworks to a tag<br/>List: " + item_list.join(", ")
|
||
when 'delete'
|
||
render :text => "Action: delete Artworks<br/>List: " + item_list.join(", ")
|
||
artworks_ids = params['artworks_selection_ids'].collect {|x| x.to_i }
|
||
@selection = Artwork.find(artworks_ids)
|
||
|
||
render :action => @action
|
||
else
|
||
render_404
|
||
end
|
||
end
|
||
|
||
def selection_associate_with_tag
|
||
artwork_list = params['artworks_selection_ids'].collect {|x| Artwork.find(x.to_i) }
|
||
tag_list = params['tags_selection_ids'].collect {|x| Tag.find(x.to_i) }
|
||
|
||
artwork_list.each do |artwork|
|
||
artwork.tags += tag_list
|
||
end
|
||
|
||
redirect_to :action => "index"
|
||
end
|
||
|
||
protected
|
||
|
||
private
|
||
|
||
def load_form_data
|
Also available in: Unified diff
[evol] artworks context menu: finished mechanism + checked for empty selection + implemented associate_with_tag action