_form.html.erb
2.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<%= form_for(@gamification_plugin_badge, :url => {:action => @gamification_plugin_badge.new_record? ? :create : :update, :id => @gamification_plugin_badge.id }) do |f| %>
<% if @gamification_plugin_badge.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@gamification_plugin_badge.errors.count, "error") %> prohibited this gamification_plugin_badge from being saved:</h2>
<ul>
<% @gamification_plugin_badge.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<% rules = Merit::BadgeRules::AVAILABLE_RULES %>
<% rules.merge! Merit::BadgeRules::CONFERENCE_RULES if defined? Merit::BadgeRules::CONFERENCE_RULES %>
<div class="field" id="gamification-plugin-form-badge-name">
<%= f.label :name %><br />
<%= f.select :name, rules.map{ |key, rule| key } %>
</div>
<div class="field">
<%= f.label :title %><br />
<%= f.text_field :title %>
</div>
<div class="field">
<%= f.label :description %><br />
<%= f.text_field :description %>
</div>
<div class="field">
<%= f.label :level %><br />
<%= f.text_field :level %>
</div>
<div class="field">
<%= f.label :profile_owner %><br />
<% tokenized_owner = @gamification_plugin_badge.owner.present? && @gamification_plugin_badge.owner.kind_of?(Organization) ? prepare_to_token_input([@gamification_plugin_badge.owner]) : nil %>
<%= token_input_field_tag('gamification_plugin_badge[owner_id]', 'badge-owner', {:action => 'search_owners'}, {:focus => false, :hint_text => _('Choose a profile or leave it blank for a global badge'), :token_limit => 1, :pre_populate => tokenized_owner}) %>
</div>
<div class="action-fields">
<h4><%= _('Actions') %></h4>
<%= f.fields_for :custom_fields do |c| %>
<% rules.each do |name, settings| %>
<div class='controller-actions <%= "name_#{name}" %>'>
<% settings.select {|s| s[:action].present?}.each do |setting| %>
<%= c.label _(setting[:action]) %>
<%= c.fields_for setting[:action] do |d| %>
<% action = (@gamification_plugin_badge.custom_fields || {}).fetch(setting[:action], {}) %>
<div class="field">
<%= d.label :threshold %><br />
<%= d.text_field :threshold, {value: action.fetch('threshold', "")} %>
</div>
<br>
<% end %>
<% end %>
</div>
<% end %>
<% end %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>