Project

General

Profile

« Previous | Next » 

Revision bf16d414

Added by Marc Dequènes over 14 years ago

  • ID bf16d41408b3309a93dcd0dd0723a4d478023818

[evol] artworks context menu: finished mechanism + checked for empty selection + implemented associate_with_tag action

View differences:

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
app/helpers/application_helper.rb
zone_id = prefix_id + "_zone"
form_id = prefix_id + "_form"
action_id = prefix_id + "_action"
items_id = prefix_id + "_items"
items_id = prefix_id + "_ids[]"
empty_selection_msg = _("Empty selection")
menu_items = []
item_list.each do |item_data|
menu_items << {
:name => "'#{item_data[0]}'",
:callback => "function() {
document.getElementById('#{action_id}').value = '#{item_data[1]}';
document.getElementById('#{form_id}').submit();
/*alert('#{item_data[1]}');*/
items = $A(document.getElementsByName('#{items_id}'));
one_checkbox_set = false;
for (var i = 0; i < items.length; ++i)
{
if (items[i].checked)
{
one_checkbox_set = true;
break;
}
}
if (one_checkbox_set)
{
$('#{action_id}').value = '#{item_data[1]}';
$('#{form_id}').submit();
}
else
alert('#{empty_selection_msg}');
}
"
}
app/models/artwork.rb
return nil if self.artwork_step_images.empty?
self.artwork_step_images.last
end
def full_title
str = ""
str += self.artwork_set.name unless artwork_set.nil?
str += " :: " + self.artwork_group.name unless artwork_group.nil?
str += " :: " unless str == ""
str += self.title
end
end
app/views/admin/artworks/index.rhtml
<% @artworks = resource_model.paginate(:all, :include => [:artwork_set, :artwork_group], :order => params[:sort], :page => params[:page]) %>
<% @artworks.each do |artwork| %>
<tr>
<td><%= check_box_tag 'artworks_selection_items[]', artwork.id %></td>
<td><%= check_box_tag 'artworks_selection_ids[]', artwork.id, false, :id => "artworks_selection_id_#{artwork.id}" %></td>
<td><%= link_to_resource artwork, artwork.title %></td>
<td><%= artwork.artwork_set.name if artwork.artwork_set %></td>
<td><%= artwork.artwork_group.name if artwork.artwork_group %></td>
......
</table>
<%= hidden_field_tag 'artworks_selection_action' %>
<%
action_list = [[_('Affect to Tag'), 'to_tag'], [_('Delete'), 'delete']]
gen_action_proto_menu('artworks_selection', action_list)
gen_action_proto_menu('artworks_selection', @selection_action_list)
%>
<% end %>
<%= will_paginate @artworks %>
app/views/admin/artworks/selection_associate_with_tag.rhtml
<blockquote>
<%= _("You asked to associate this selection of Artworks:") %> <%= display_list(@selection.collect{|t| t.full_title}, true) %>
<%= _("with tags; pick your selection in the list of existing tags:") %>
<% form_tag( :action => @action ) do %>
<% @selection.each do |artwork| %>
<%= hidden_field_tag 'artworks_selection_ids[]', artwork.id %>
<% end %>
<blockquote>
<% Tag.find(:all, :order => "name ASC").each do |tag| %>
<%= check_box_tag 'tags_selection_ids[]', tag.id %><%= label_tag "tags_selection_ids_#{tag.id}", tag.name %><br />
<% end %>
</blockquote>
<%= submit_tag _("Associate") %>
<% end %>
</blockquote>
app/views/admin/artworks/selection_delete.rhtml
<blockquote>
<%= _("You asked to delete this selection of Artworks:") %> <%= display_list(@selection.collect{|t| t.full_title}, true) %>
<%= _("but this dangerous action is not implemented yet, sorry.") %>
</blockquote>
po/MyCyma.pot
msgid ""
msgstr ""
"Project-Id-Version: MyCyma 0.2.0\n"
"POT-Creation-Date: 2010-06-06 17:09+0200\n"
"POT-Creation-Date: 2010-06-08 01:47+0200\n"
"PO-Revision-Date: 2008-07-28 02:17+0200\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
......
msgstr ""
#: app/helpers/application_helper.rb:92
#: app/controllers/admin/artworks_controller.rb:6
msgid "Delete"
msgstr ""
......
msgid "Missing Thumbnail!"
msgstr ""
#: app/helpers/application_helper.rb:304
msgid "Empty selection"
msgstr ""
#: app/controllers/application.rb:42
msgid "Please login to continue"
msgstr ""
#: app/controllers/admin/artworks_controller.rb:6
msgid "Associate with Tag"
msgstr ""
#: app/controllers/logon_controller.rb:9
msgid "Login successful"
msgstr ""
......
msgid "Latest 10 Productions"
msgstr ""
#: app/views/layouts/application.rhtml:20
#: app/views/layouts/application.rhtml:32
msgid "View"
msgstr ""
#: app/views/layouts/application.rhtml:22
#: app/views/layouts/application.rhtml:34
msgid "Cyma Tree"
msgstr ""
#: app/views/layouts/application.rhtml:29
#: app/views/layouts/application.rhtml:41
msgid "Setup the Cyma"
msgstr ""
#: app/views/layouts/application.rhtml:31
#: app/views/layouts/application.rhtml:43
msgid "Manage Artworks"
msgstr ""
#: app/views/layouts/application.rhtml:32
#: app/views/layouts/application.rhtml:44
msgid "Manage Artwork Conditions"
msgstr ""
#: app/views/layouts/application.rhtml:33
#: app/views/layouts/application.rhtml:45
msgid "Manage Artwork Materials"
msgstr ""
#: app/views/layouts/application.rhtml:34
#: app/views/layouts/application.rhtml:46
msgid "Manage Artwork Placement Reasons"
msgstr ""
#: app/views/layouts/application.rhtml:35
#: app/views/layouts/application.rhtml:47
msgid "Manage Artwork Sets & Groups"
msgstr ""
#: app/views/layouts/application.rhtml:36
#: app/views/layouts/application.rhtml:48
msgid "Manage Artwork Sizes"
msgstr ""
#: app/views/layouts/application.rhtml:37
#: app/views/layouts/application.rhtml:49
msgid "Manage Artwork Supports"
msgstr ""
#: app/views/layouts/application.rhtml:39
#: app/views/layouts/application.rhtml:51
msgid "Manage Tags"
msgstr ""
#: app/views/layouts/application.rhtml:42
#: app/views/layouts/application.rhtml:54
msgid "Manage Users"
msgstr ""
#: app/views/layouts/application.rhtml:47
#: app/views/layouts/application.rhtml:59
msgid "About"
msgstr ""
#: app/views/layouts/application.rhtml:49
#: app/views/layouts/application.rhtml:61
msgid "Project page"
msgstr ""
#: app/views/layouts/application.rhtml:50
#: app/views/layouts/application.rhtml:62
msgid "Author site"
msgstr ""
#: app/views/layouts/application.rhtml:55
#: app/views/layouts/application.rhtml:67
msgid "Loggued in as '%s'"
msgstr ""
#: app/views/layouts/application.rhtml:56
#: app/views/layouts/application.rhtml:68
msgid "Not loggued in"
msgstr ""
......
msgstr ""
#: app/views/admin/artwork_step_images/index.rhtml:17
#: app/views/admin/artworks/index.rhtml:9
#: app/views/admin/artworks/index.rhtml:12
msgid "Preview"
msgstr ""
......
#: app/views/admin/artwork_conditions/index.rhtml:5
#: app/views/admin/artwork_sets/index.rhtml:5
#: app/views/admin/artwork_sizes/index.rhtml:5
#: app/views/admin/artworks/index.rhtml:11
#: app/views/admin/artworks/index.rhtml:14
#: app/views/admin/artwork_groups/index.rhtml:5
#: app/views/admin/tags/index.rhtml:5
msgid "Actions"
......
msgid "New Artwork"
msgstr ""
#: app/views/admin/artworks/index.rhtml:1
#: app/views/admin/artworks/selection_delete.rhtml:2
msgid "You asked to delete this selection of Artworks:"
msgstr ""
#: app/views/admin/artworks/selection_delete.rhtml:3
msgid "but this dangerous action is not implemented yet, sorry."
msgstr ""
#: app/views/admin/artworks/selection_associate_with_tag.rhtml:2
msgid "You asked to associate this selection of Artworks:"
msgstr ""
#: app/views/admin/artworks/selection_associate_with_tag.rhtml:3
msgid "with tags; pick your selection in the list of existing tags:"
msgstr ""
#: app/views/admin/artworks/selection_associate_with_tag.rhtml:13
msgid "Associate"
msgstr ""
#: app/views/admin/artworks/index.rhtml:2
msgid "List of Artworks"
msgstr ""
#: app/views/admin/artworks/index.rhtml:6
#: app/views/admin/artworks/index.rhtml:9
msgid "Title"
msgstr ""
#: app/views/admin/artworks/index.rhtml:7
#: app/views/admin/artworks/index.rhtml:10
msgid "Set"
msgstr ""
#: app/views/admin/artworks/index.rhtml:8
#: app/views/admin/artworks/index.rhtml:11
msgid "Group"
msgstr ""
#: app/views/admin/artworks/index.rhtml:10 app/views/view/artwork.rhtml:4
#: app/views/admin/artworks/index.rhtml:13 app/views/view/artwork.rhtml:4
msgid "Steps"
msgstr ""
#: app/views/admin/artworks/index.rhtml:24
#: app/views/admin/artworks/index.rhtml:28
#: app/views/admin/artworks/show.rhtml:52
msgid "View Steps"
msgstr ""
po/fr/MyCyma.po
msgid ""
msgstr ""
"Project-Id-Version: MyCyma 0.2.0\n"
"POT-Creation-Date: 2010-06-06 17:09+0200\n"
"POT-Creation-Date: 2010-06-08 01:47+0200\n"
"PO-Revision-Date: 2008-07-28 02:17+0200\n"
"Last-Translator: Marc Dequènes (Duck) <Duck@DuckCorp.org>\n"
"MIME-Version: 1.0\n"
......
msgstr "Modifier"
#: app/helpers/application_helper.rb:92
#: app/controllers/admin/artworks_controller.rb:6
msgid "Delete"
msgstr "Supprimer"
......
msgid "Missing Thumbnail!"
msgstr "Vignette manquante !"
#: app/helpers/application_helper.rb:304
msgid "Empty selection"
msgstr "Selection vide"
#: app/controllers/application.rb:42
msgid "Please login to continue"
msgstr "Veuillez vous identifier pour continuer"
#: app/controllers/admin/artworks_controller.rb:6
msgid "Associate with Tag"
msgstr "Associer à un Tag"
#: app/controllers/logon_controller.rb:9
msgid "Login successful"
msgstr "Identification réussie"
......
msgid "Latest 10 Productions"
msgstr "10 Dernières Réalisations"
#: app/views/layouts/application.rhtml:20
#: app/views/layouts/application.rhtml:32
msgid "View"
msgstr "Vue"
#: app/views/layouts/application.rhtml:22
#: app/views/layouts/application.rhtml:34
msgid "Cyma Tree"
msgstr "Arbre de la Cimaise"
#: app/views/layouts/application.rhtml:29
#: app/views/layouts/application.rhtml:41
msgid "Setup the Cyma"
msgstr "Gérer la Cimaise"
#: app/views/layouts/application.rhtml:31
#: app/views/layouts/application.rhtml:43
msgid "Manage Artworks"
msgstr "Gérer les Œuvres"
#: app/views/layouts/application.rhtml:32
#: app/views/layouts/application.rhtml:44
msgid "Manage Artwork Conditions"
msgstr "Gérer les États des Œuvres"
#: app/views/layouts/application.rhtml:33
#: app/views/layouts/application.rhtml:45
msgid "Manage Artwork Materials"
msgstr "Gérer les Matériaux des Œuvres"
#: app/views/layouts/application.rhtml:34
#: app/views/layouts/application.rhtml:46
msgid "Manage Artwork Placement Reasons"
msgstr "Gérer les Raisons de Placement des Œuvres"
#: app/views/layouts/application.rhtml:35
#: app/views/layouts/application.rhtml:47
msgid "Manage Artwork Sets & Groups"
msgstr "Gérer les Séries et les Ensembles d'Œuvres"
#: app/views/layouts/application.rhtml:36
#: app/views/layouts/application.rhtml:48
msgid "Manage Artwork Sizes"
msgstr "Gérer les Dimensions des Œuvres"
#: app/views/layouts/application.rhtml:37
#: app/views/layouts/application.rhtml:49
msgid "Manage Artwork Supports"
msgstr "Gérer les Supports"
#: app/views/layouts/application.rhtml:39
#: app/views/layouts/application.rhtml:51
msgid "Manage Tags"
msgstr "Gérer les Tags"
#: app/views/layouts/application.rhtml:42
#: app/views/layouts/application.rhtml:54
msgid "Manage Users"
msgstr "Gérer les Utilisateurs"
#: app/views/layouts/application.rhtml:47
#: app/views/layouts/application.rhtml:59
msgid "About"
msgstr "À Propos"
#: app/views/layouts/application.rhtml:49
#: app/views/layouts/application.rhtml:61
msgid "Project page"
msgstr "Page du Projet"
#: app/views/layouts/application.rhtml:50
#: app/views/layouts/application.rhtml:62
msgid "Author site"
msgstr "Site de l'auteur"
#: app/views/layouts/application.rhtml:55
#: app/views/layouts/application.rhtml:67
msgid "Loggued in as '%s'"
msgstr "Identifié en '%s'"
#: app/views/layouts/application.rhtml:56
#: app/views/layouts/application.rhtml:68
msgid "Not loggued in"
msgstr "Non identifié"
......
msgstr "Position"
#: app/views/admin/artwork_step_images/index.rhtml:17
#: app/views/admin/artworks/index.rhtml:9
#: app/views/admin/artworks/index.rhtml:12
msgid "Preview"
msgstr "Prévisualisation"
......
#: app/views/admin/artwork_conditions/index.rhtml:5
#: app/views/admin/artwork_sets/index.rhtml:5
#: app/views/admin/artwork_sizes/index.rhtml:5
#: app/views/admin/artworks/index.rhtml:11
#: app/views/admin/artworks/index.rhtml:14
#: app/views/admin/artwork_groups/index.rhtml:5
#: app/views/admin/tags/index.rhtml:5
msgid "Actions"
......
msgid "New Artwork"
msgstr "Nouvelle Œuvre"
#: app/views/admin/artworks/index.rhtml:1
#: app/views/admin/artworks/selection_delete.rhtml:2
msgid "You asked to delete this selection of Artworks:"
msgstr "Vous avez demandé à effacer cette selection d'Œuvres"
#: app/views/admin/artworks/selection_delete.rhtml:3
msgid "but this dangerous action is not implemented yet, sorry."
msgstr "mais cette opération dangereuse n'est pas encore possible."
#: app/views/admin/artworks/selection_associate_with_tag.rhtml:2
msgid "You asked to associate this selection of Artworks:"
msgstr "Vous avez demandé à associer cette selection d'Œuvres:"
#: app/views/admin/artworks/selection_associate_with_tag.rhtml:3
msgid "with tags; pick your selection in the list of existing tags:"
msgstr "à des tags ; faite votre selection dans la liste des tags existants :"
#: app/views/admin/artworks/selection_associate_with_tag.rhtml:13
msgid "Associate"
msgstr "Associer"
#: app/views/admin/artworks/index.rhtml:2
msgid "List of Artworks"
msgstr "Liste des Œuvres"
#: app/views/admin/artworks/index.rhtml:6
#: app/views/admin/artworks/index.rhtml:9
msgid "Title"
msgstr "Titre"
#: app/views/admin/artworks/index.rhtml:7
#: app/views/admin/artworks/index.rhtml:10
msgid "Set"
msgstr "Série"
#: app/views/admin/artworks/index.rhtml:8
#: app/views/admin/artworks/index.rhtml:11
msgid "Group"
msgstr "Ensemble"
#: app/views/admin/artworks/index.rhtml:10 app/views/view/artwork.rhtml:4
#: app/views/admin/artworks/index.rhtml:13 app/views/view/artwork.rhtml:4
msgid "Steps"
msgstr "Étapes"
#: app/views/admin/artworks/index.rhtml:24
#: app/views/admin/artworks/index.rhtml:28
#: app/views/admin/artworks/show.rhtml:52
msgid "View Steps"
msgstr "Voir les Étapes"

Also available in: Unified diff