Adds settings to complete the polls card and feature view.
This commit is contained in:
Juan Salvador Pérez García
2018-07-10 15:23:03 +02:00
parent 762c4faef6
commit a872c5b5df
12 changed files with 107 additions and 13 deletions

View File

@@ -1,5 +1,5 @@
class Admin::SettingsController < Admin::BaseController class Admin::SettingsController < Admin::BaseController
helper_method :successful_proposal_setting, :successful_proposals helper_method :successful_proposal_setting, :successful_proposals, :poll_feature_short_title_setting, :poll_feature_description_setting, :poll_feature_link_setting
def index def index
all_settings = Setting.all.group_by { |s| s.type } all_settings = Setting.all.group_by { |s| s.type }
@@ -35,4 +35,16 @@ class Admin::SettingsController < Admin::BaseController
def successful_proposals def successful_proposals
Proposal.successful Proposal.successful
end end
def poll_feature_short_title_setting
Setting.find_by(key: 'proposals.poll_short_title')
end
def poll_feature_description_setting
Setting.find_by(key: 'proposals.poll_description')
end
def poll_feature_link_setting
Setting.find_by(key: 'proposals.poll_link')
end
end end

View File

@@ -17,5 +17,59 @@
<% end %> <% end %>
</td> </td>
</tr> </tr>
<tr>
<td class="small-12 medium-4">
<strong><%= t("settings.#{poll_feature_short_title_setting.key}") %></strong>
</td>
<td class="small-12 medium-8">
<%= form_for poll_feature_short_title_setting,
url: admin_setting_path(poll_feature_short_title_setting),
html: { id: "edit_#{dom_id(poll_feature_short_title_setting)}"} do |f| %>
<div class="small-12 medium-6 large-9 column">
<%= f.text_field :value, label: false, id: dom_id(poll_feature_short_title_setting) %>
</div>
<div class="small-12 medium-6 large-3 column">
<%= f.submit(t('admin.settings.index.update_setting'), class: "button hollow expanded") %>
</div>
<% end %>
</td>
</tr>
<tr>
<td class="small-12 medium-4">
<strong><%= t("settings.#{poll_feature_description_setting.key}") %></strong>
</td>
<td class="small-12 medium-8">
<%= form_for poll_feature_description_setting,
url: admin_setting_path(poll_feature_description_setting),
html: { id: "edit_#{dom_id(poll_feature_description_setting)}"} do |f| %>
<div class="small-12 medium-6 large-9 column">
<%= f.cktext_area :value, label: false, id: dom_id(poll_feature_description_setting) %>
</div>
<div class="small-12 medium-6 large-3 column">
<%= f.submit(t('admin.settings.index.update_setting'), class: "button hollow expanded") %>
</div>
<% end %>
</td>
</tr>
<tr>
<td class="small-12 medium-4">
<strong><%= t("settings.#{poll_feature_link_setting.key}") %></strong>
</td>
<td class="small-12 medium-8">
<%= form_for poll_feature_link_setting,
url: admin_setting_path(poll_feature_link_setting),
html: { id: "edit_#{dom_id(poll_feature_link_setting)}"} do |f| %>
<div class="small-12 medium-6 large-9 column">
<%= f.text_field :value, label: false, id: dom_id(poll_feature_link_setting) %>
</div>
<div class="small-12 medium-6 large-3 column">
<%= f.submit(t('admin.settings.index.update_setting'), class: "button hollow expanded") %>
</div>
<% end %>
</td>
</tr>
</tbody> </tbody>
</table> </table>

View File

@@ -1,11 +1,23 @@
<% content_for :action_title, t('.title') %> <% content_for :action_title, t('.title') %>
<div class="row">
<div class="small-12 medium-9 column">
<%== Setting['proposals.poll_description'] %>
</div>
<div class="small-12 medium-3 column">
<% unless Setting['proposals.poll_link'].blank? %>
<div class="proposal-dashboard-action-links">
<h3><%= t('.links') %></h3>
<%= link_to t('.additiontal_information'), Setting['proposals.poll_link'], target: '_blank' %>
</div>
<% end %>
<strong><%= t('.count', count: @polls.count) %></strong>
<%= link_to t('.create'), <%= link_to t('.create'),
new_proposal_dashboard_poll_path(proposal), new_proposal_dashboard_poll_path(proposal),
class: 'button' %> class: 'button expanded' %>
</div>
<div class="row small-12 column">
<strong><%= t('.count', count: @polls.count) %></strong>
</div> </div>
<% if @polls.any? %> <% if @polls.any? %>

View File

@@ -2,7 +2,7 @@
<div class="row"> <div class="row">
<div class="column large-4"> <div class="column large-4">
<div class="counter"> <div class="counter">
<div class="counter-value"><%= proposal.votes_for.size %></div> <div class="counter-value"><%= number_with_delimiter(proposal.votes_for.size, delimiter: '.') %></div>
<div class="counter-label"><%= t('.supports') %></div> <div class="counter-label"><%= t('.supports') %></div>
</div> </div>
@@ -16,14 +16,14 @@
</div> </div>
<div class="counter"> <div class="counter">
<div class="counter-value"><%= community_members_count %></div> <div class="counter-value"><%= number_with_delimiter(community_members_count, delimiter: '.') %></div>
<div class="counter-label"><%= t('.community') %></div> <div class="counter-label"><%= t('.community') %></div>
</div> </div>
</div> </div>
<div class="column large-8"> <div class="column large-8">
<div class="current-goal"> <div class="current-goal">
<div class="counter-value"> <div class="counter-value">
<%= t('.support_count', count: next_goal_supports) %> <%= t('.support_count', count: number_with_delimiter(next_goal_supports, delimiter: '.')) %>
</div> </div>
<div class="counter-label"><%= t('.current_goal') %></div> <div class="counter-label"><%= t('.current_goal') %></div>

View File

@@ -25,7 +25,7 @@
<% if can?(:manage_polls, proposal) %> <% if can?(:manage_polls, proposal) %>
<%= polls_menu do %> <%= polls_menu do %>
<%= link_to proposal_dashboard_polls_path(proposal.to_param) do %> <%= link_to proposal_dashboard_polls_path(proposal.to_param) do %>
<span><%= t('.polls') %></span> <span data-tooltip title="<%= Setting['proposals.poll_short_title'] || t('.polls') %>"><%= t('.polls') %></span>
<% end %> <% end %>
<% end %> <% end %>
<% end %> <% end %>

View File

@@ -7,6 +7,7 @@
</p> </p>
<h4 class="text-center"><%= t('proposals_dashboard.menu.polls') %></h4> <h4 class="text-center"><%= t('proposals_dashboard.menu.polls') %></h4>
<p class="text-center"> <p class="text-center">
<%= Setting['proposals.poll_short_title'] %>
</p> </p>
</div> </div>

View File

@@ -557,6 +557,8 @@ en:
count: count:
one: You have created %{count} poll. one: You have created %{count} poll.
other: You have created %{count} polls. other: You have created %{count} polls.
links: Links
additiontal_information: Additional information
poll: poll:
published_on: Published on published_on: Published on
responses: responses:

View File

@@ -65,3 +65,6 @@ en:
proposal_improvement_path: Proposal improvement info internal link proposal_improvement_path: Proposal improvement info internal link
proposals: proposals:
successful_proposal_id: Successful proposal successful_proposal_id: Successful proposal
poll_short_title: Subtitle for polls feature
poll_description: Description for polls feature
poll_link: Additional information link

View File

@@ -557,6 +557,8 @@ es:
count: count:
one: Has creado %{count} encuesta. one: Has creado %{count} encuesta.
other: Has creado %{count} encuestas. other: Has creado %{count} encuestas.
links: Enlaces
additiontal_information: Información adicional
poll: poll:
published_on: Publicada published_on: Publicada
responses: responses:

View File

@@ -65,3 +65,6 @@ es:
proposal_improvement_path: Link a información para mejorar propuestas proposal_improvement_path: Link a información para mejorar propuestas
proposals: proposals:
successful_proposal_id: Propuesta exitosa successful_proposal_id: Propuesta exitosa
poll_short_title: Subtítulo funcionalidad encuestas
poll_description: Descripción funcionalidad encuestas
proposals.poll_link: Enlace información adicional

View File

@@ -134,3 +134,5 @@ Setting['feature.homepage.widgets.feeds.processes'] = true
# Proposals # Proposals
Setting['proposals.successful_proposal_id'] = nil Setting['proposals.successful_proposal_id'] = nil
Setting['proposals.poll_short_title'] = nil
Setting['proposals.poll_description'] = nil

View File

@@ -13,9 +13,12 @@ namespace :proposal_actions do
end end
end end
desc 'Initialize successful proposal id setting' desc 'Initialize proposal settings'
task initialize_successful_proposal_id: :environment do task initialize_settings: :environment do
Setting['proposals.successful_proposal_id'] = nil Setting['proposals.successful_proposal_id'] = nil if Setting.find_by(key: 'proposals.successful_proposal_id').nil?
Setting['proposals.poll_short_title'] = nil if Setting.find_by(key: 'proposals.poll_short_title').nil?
Setting['proposals.poll_description'] = nil if Setting.find_by(key: 'proposals.poll_description').nil?
Setting['proposals.poll_link'] = nil if Setting.find_by(key: 'proposals.poll_link').nil?
end end
desc 'Simulate successful proposal' desc 'Simulate successful proposal'