Skip to content

Commit

Permalink
Correction affichage des tags dans les comptes. Correction des vues.
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas NAUDIN committed Apr 10, 2014
1 parent 2c01a25 commit c7fd8f9
Show file tree
Hide file tree
Showing 6 changed files with 722 additions and 42 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Expand Up @@ -80,4 +80,4 @@ pickle-email-*.html
/public/assets

# Exuberant CTags
tags
./tags
4 changes: 2 additions & 2 deletions app/controllers/accounts_controller.rb
Expand Up @@ -231,7 +231,7 @@ def add_tag
@tag = Tag.find(params[:tag_id])
@account = Account.find(params[:account_id])
@account.tags << @tag
redirect_to account_events_url(@account.id), :notice => "Affectation du tag effectuée."
redirect_to account_tags_url(@account.id), :notice => "Affectation du tag effectuée."
else
flash[:error] = t('app.cancan.messages.unauthorized').gsub('[action]', t('app.actions.update')).gsub('[undefined_article]', t('app.default.undefine_article_male')).gsub('[model]', t('app.controllers.Account'))
redirect_to accounts_url
Expand All @@ -249,7 +249,7 @@ def delete_tag
@account.tags.delete(@tag)

respond_to do |format|
format.html { redirect_to account_events_url(@account.id), :notice => "Suppression de l'affectation du tag effectuée." }
format.html { redirect_to account_tags_url(@account.id), :notice => "Suppression de l'affectation du tag effectuée." }
format.json { render :json => @tag }
end
else
Expand Down
31 changes: 31 additions & 0 deletions app/views/tags/_index.html.erb
@@ -0,0 +1,31 @@
<%= render 'title', :locals => { :title => @title }%>

<div class="container-fluid">

<table class="table table-bordered table-striped">
<thead>
<tr>
<th><center>#</center></th>
<th><center>Nom</center></th>
<th><center>Description</center></th>
<th><center>Éditer</center></th>
</tr>
</thead>

<tbody>
<% @tags.each do |tag| %>
<tr>
<td><center><%= tag.id %></center></td>
<td><center><%= tag.name %></center></td>
<td><center><%= truncate(tag.description, :length => 75, :separator => ' ')%></center></td>
<td><center><%= link_to image_tag("glyphicons/glyphicons_151_edit.png"), edit_tag_path(tag),{:title => "Éditer le tag", :class =>"btn"} %></center></td>
</tr>
<% end %>
</tbody>
</table>

<br />

<%= paginate @tags %>

</div>
@@ -1,3 +1,5 @@
<% @tags_select = Tag.all - @account.tags %>

<div class="container-fluid" style="margin-top: 1em;">


Expand All @@ -12,16 +14,9 @@




<div class="container-fluid">
<div class="row-fluid">
<div class="span9">
<%
@tags = @account.tags.order('name')
@tags_paginated = @account.tags.order('name').page(params[:page])
@tags_select_tmp = Tag.order('name ASC').all
@tags_select = @tags_select_tmp.reject { |e| @tags.include? e }
%>
<%= form_tag({:controller => "accounts", :action => "add_tag", :account_id => @account.id}, :method => "post") do %>
<%= select_tag :tag_id, options_from_collection_for_select(@tags_select, "id", "name") %>
<% if (@tags_select.count > 0) %>
Expand Down Expand Up @@ -50,7 +45,7 @@
<tbody>


<% @tags_paginated.each do |tag| %>
<% @tags.each do |tag| %>
<tr>
<td style="width: 15em;" class="text-center"><%= tag.name %></td>
<td><%= truncate(tag.description, :length => 500, :separator => ' ') %></td>
Expand All @@ -61,7 +56,7 @@

<br />

<%= paginate @tags_paginated %>
<%= paginate @tags %>
<% end %>
Expand Down
37 changes: 7 additions & 30 deletions app/views/tags/index.html.erb
@@ -1,31 +1,8 @@
<%= render 'title', :locals => { :title => @title }%>
<%
index = 'index'
if @account
index += '_when_account'
end
%>
<div class="container-fluid">

<table class="table table-bordered table-striped">
<thead>
<tr>
<th><center>#</center></th>
<th><center>Nom</center></th>
<th><center>Description</center></th>
<th><center>Éditer</center></th>
</tr>
</thead>

<tbody>
<% @tags.each do |tag| %>
<tr>
<td><center><%= tag.id %></center></td>
<td><center><%= tag.name %></center></td>
<td><center><%= truncate(tag.description, :length => 75, :separator => ' ')%></center></td>
<td><center><%= link_to image_tag("glyphicons/glyphicons_151_edit.png"), edit_tag_path(tag),{:title => "Éditer le tag", :class =>"btn"} %></center></td>
</tr>
<% end %>
</tbody>
</table>

<br />

<%= paginate @tags %>

</div>
<%= render partial: index %>

0 comments on commit c7fd8f9

Please sign in to comment.