Commit c12f8abdb8076feeb85a073c64f8d50dd022dddc

Authored by Victor Costa
1 parent b5a544e6

Add title to badge

db/migrate/20150330102818_create_badges.rb
... ... @@ -3,6 +3,7 @@ class CreateBadges < ActiveRecord::Migration
3 3 create_table :gamification_plugin_badges do |t|
4 4 t.string :name
5 5 t.integer :level
  6 + t.string :title
6 7 t.string :description
7 8 t.string :custom_fields
8 9 t.references :owner, :polymorphic => true
... ...
lib/gamification_plugin/badge.rb
... ... @@ -4,7 +4,7 @@ class GamificationPlugin::Badge < Noosfero::Plugin::ActiveRecord
4 4  
5 5 has_many :badges_sash, :class_name => 'Merit::BadgesSash'
6 6  
7   - attr_accessible :owner, :name, :description, :level, :custom_fields
  7 + attr_accessible :owner, :name, :description, :level, :custom_fields, :title
8 8  
9 9 serialize :custom_fields
10 10  
... ...
views/gamification/dashboard.html.erb
... ... @@ -38,9 +38,9 @@
38 38 <ul class="badge-list">
39 39 <% environment.gamification_plugin_badges.each do |badge| %>
40 40 <li class="badge <%= badge.name %> <%= @target.badges.include?(badge) ? 'earned' : 'not-earned' %>">
41   - <div class="badge">
  41 + <div class="badge" title="<%= badge.description %>">
42 42 <div class="image <%= badge.name %>"></div>
43   - <div class="description"><%= badge.description %></div>
  43 + <div class="title"><%= badge.title %></div>
44 44 <div class="level"><%= _('Level %s' % badge.level) %></div>
45 45 </div>
46 46 </li>
... ...
views/gamification_plugin_badges/_form.html.erb
... ... @@ -16,6 +16,10 @@
16 16 <%= f.select :name, Merit::BadgeRules::AVAILABLE_RULES.map{ |key, rule| key } %>
17 17 </div>
18 18 <div class="field">
  19 + <%= f.label :title %><br />
  20 + <%= f.text_field :title %>
  21 + </div>
  22 + <div class="field">
19 23 <%= f.label :description %><br />
20 24 <%= f.text_field :description %>
21 25 </div>
... ...
views/gamification_plugin_badges/index.html.erb
... ... @@ -3,7 +3,7 @@
3 3 <table>
4 4 <tr>
5 5 <th>Name</th>
6   - <th>Description</th>
  6 + <th>Title</th>
7 7 <th>Level</th>
8 8 <th>Threshold</th>
9 9 <th></th>
... ... @@ -14,7 +14,7 @@
14 14 <% @gamification_plugin_badges.each do |gamification_plugin_badge| %>
15 15 <tr>
16 16 <td><%= gamification_plugin_badge.name %></td>
17   - <td><%= gamification_plugin_badge.description %></td>
  17 + <td><%= gamification_plugin_badge.title %></td>
18 18 <td><%= gamification_plugin_badge.level %></td>
19 19 <td><%= gamification_plugin_badge.threshold %></td>
20 20 <td><%= link_to 'Show', :action => :show, :id => gamification_plugin_badge.id %></td>
... ...
views/gamification_plugin_badges/show.html.erb
... ... @@ -8,6 +8,11 @@
8 8 </p>
9 9  
10 10 <p>
  11 + <b>Title:</b>
  12 + <%= @gamification_plugin_badge.title %>
  13 +</p>
  14 +
  15 +<p>
11 16 <b>Description:</b>
12 17 <%= @gamification_plugin_badge.description %>
13 18 </p>
... ...