Commit f1e0dc83e44569b1b49c2654ef5a3d01b1538fe1

Authored by Daniela Feitosa
1 parent c2e00580

Some enhancements on CustomForms plugin

Forbidding not authorized people to access management of forms
Replacing "link_to" by "button" to look like others links of Noosfero
Added link to form on page for management of forms

(ActionItem1739)
plugins/custom_forms/controllers/custom_forms_plugin_myprofile_controller.rb
1 1 class CustomFormsPluginMyprofileController < MyProfileController
  2 +
  3 + protect 'post_content', :profile
2 4 def index
3 5 @forms = CustomFormsPlugin::Form.from(profile)
4 6 end
... ...
plugins/custom_forms/views/custom_forms_plugin_myprofile/_edit_select.html.erb
1 1 <% elem_id = "edit-select-#{counter}" %>
2 2 <div id=<%= elem_id %> class='edit-information'>
3   - <h1><%= _('Options') %></h1>
  3 + <h2><%= _('Options') %></h2>
4 4 <table class='action-table' style='width: 420px'>
5 5 <tr>
6 6 <th style='width: 40%'><%= _('Name') %></th>
... ... @@ -14,15 +14,15 @@
14 14 <% end %>
15 15 <%= render :partial => 'empty_option', :locals => {:counter => counter, :option_counter => option_counter} %>
16 16 <tr class='new-item'>
17   - <td colspan='3'><strong><%= link_to(_('NEW OPTION'), '#', :class => 'new-option', :field_id => counter)%></strong></td>
  17 + <td colspan='3'>
  18 + <%= button(:add, _('Add a new option'), '#', :class => 'new-option', :field_id => counter)%>
  19 + </td>
18 20 </tr>
19 21 </table>
20 22  
21   - <h2><%= _('Type') %></h2>
22   - <%#= labelled_check_box _('List'), "fields[#{counter}][list]", true, field.list %>
23   - <%#= labelled_check_box _('Multiple'), "fields[#{counter}][multiple]", true, field.multiple %>
  23 + <h3><%= _('Type') %></h3>
24 24 <%= labelled_radio_button 'Radio', "fields[#{counter}][kind]", 'radio', !field.multiple && !field.list %><br />
25   - <%= labelled_radio_button 'Check Box', "fields[#{counter}][kind]", 'check_box', field.multiple && !field.list %><br />
  25 + <%= labelled_radio_button 'Checkbox', "fields[#{counter}][kind]", 'check_box', field.multiple && !field.list %><br />
26 26 <%= labelled_radio_button 'Select', "fields[#{counter}][kind]", 'select', !field.multiple && field.list %><br />
27 27 <%= labelled_radio_button 'Multiple Select', "fields[#{counter}][kind]", 'multiple_select', field.multiple && field.list %><br />
28 28  
... ...
plugins/custom_forms/views/custom_forms_plugin_myprofile/_edit_text.html.erb
1 1 <% elem_id = "edit-text-#{counter}" %>
2 2 <div id=<%= elem_id %> class='edit-information'>
  3 + <h2><%= _('Default value') %></h2>
3 4 <%= labelled_form_field _('Default value'), text_field("fields[#{counter}]", :default_value, :value => field.default_value) %>
4 5  
5 6 <% button_bar do %>
... ...
plugins/custom_forms/views/custom_forms_plugin_myprofile/_empty_field.html.erb
1 1 <tr id="empty-field" style='display: none' last_id=<%= counter %>>
2   - <td style="text-align: left"><%= text_field "fields[#{counter}]", :name %></td>
  2 + <td style="text-align: left"><%= text_field "fields[#{counter}]", :name, :size => 25 %></td>
3 3 <td><%= select "fields[#{counter}]", :type, type_options, :selected => type_for_options(field.class) %></td>
4 4 <td><%= check_box "fields[#{counter}]", :mandatory %></td>
5 5 <%= hidden_field "fields[#{counter}]", :form_id, :value => @form.id %>
... ...
plugins/custom_forms/views/custom_forms_plugin_myprofile/_empty_option.html.erb
1 1 <tr id=<%= "empty-option-#{counter}" %> option_id=<%= option_counter %> style="display: none;">
2 2 <td><%= text_field_tag("fields[#{counter}][choices][#{option_counter}][name]") %></td>
3   - <td><%= text_field_tag("fields[#{counter}][choices][#{option_counter}][value]") %></td>
  3 + <td><%= text_field_tag("fields[#{counter}][choices][#{option_counter}][value]", nil, :size => 15) %></td>
4 4 <td class='actions'>
5 5 <%= button_without_text :remove, _('Remove'), '#', :class => 'remove-option', :field_id => counter, :option_id => option_counter, :confirm => _('Are you sure you want to remove this option?') %>
6 6 </td>
... ...
plugins/custom_forms/views/custom_forms_plugin_myprofile/_field.html.erb
1 1 <tr id=<%= "field-#{counter}" %>>
2   - <td style="text-align: left"><%= text_field "fields[#{counter}]", :name, :value => field.name %></td>
  2 + <td style="text-align: left"><%= text_field "fields[#{counter}]", :name, :value => field.name, :size => 25 %></td>
3 3 <td><%= type_to_label(field.type) %></td>
4 4 <%= hidden_field "fields[#{counter}]", :type, :value => type_for_options(field.class) %>
5 5 <td><%= check_box "fields[#{counter}]", :mandatory, :checked => field.mandatory %></td>
... ...
plugins/custom_forms/views/custom_forms_plugin_myprofile/_form.html.erb
... ... @@ -32,7 +32,9 @@
32 32 <% end %>
33 33 <%= render :partial => 'empty_field', :locals => {:field => @empty_field, :counter => counter} %>
34 34 <tr class='new-item'>
35   - <td colspan='5'><strong><%= link_to(_('NEW FIELD'), '#', :id => 'new-field')%></strong></td>
  35 + <td colspan='5'>
  36 + <%= button(:add, _('Add a new field'), '#', :id => 'new-field')%>
  37 + </td>
36 38 </tr>
37 39 </table>
38 40  
... ...
plugins/custom_forms/views/custom_forms_plugin_myprofile/index.html.erb
... ... @@ -11,7 +11,7 @@
11 11 </tr>
12 12 <% @forms.each do |form| %>
13 13 <tr>
14   - <td><%= form.name %></td>
  14 + <td><%= link_to form.name, {:controller => 'custom_forms_plugin_profile', :action => 'show', :id => form.id} %></td>
15 15 <td><%= period_range(form) %></td>
16 16 <td><%= form.submissions.count > 0 ? link_to(form.submissions.count, {:action => 'submissions', :id => form.id}) : 0 %></td>
17 17 <td><%= access_text(form) %></td>
... ... @@ -21,6 +21,8 @@
21 21 </tr>
22 22 <% end %>
23 23 <tr id="new-item">
24   - <td colspan='5'><strong><%= link_to(_('NEW FORM'), :action => 'create')%></strong></td>
  24 + <td colspan='5'>
  25 + <%= button(:add, _('Add a new form'), :action => 'create')%>
  26 + </td>
25 27 </tr>
26 28 </table>
... ...