@@ -8,7 +8,13 @@ class Admin::ProposalDashboardActionsController < Admin::BaseController
|
||||
end
|
||||
|
||||
def new
|
||||
@proposal_dashboard_action = ProposalDashboardAction.new(active: true, day_offset: 0, required_supports: 0, request_to_administrators: true)
|
||||
@proposal_dashboard_action = ProposalDashboardAction.new(
|
||||
active: true,
|
||||
day_offset: 0,
|
||||
required_supports: 0,
|
||||
request_to_administrators: true,
|
||||
action_type: 'proposed_action'
|
||||
)
|
||||
end
|
||||
|
||||
def create
|
||||
@@ -41,7 +47,7 @@ class Admin::ProposalDashboardActionsController < Admin::BaseController
|
||||
def proposal_dashboard_action_params
|
||||
params
|
||||
.require(:proposal_dashboard_action)
|
||||
.permit(:title, :description, :link, :request_to_administrators, :day_offset, :required_supports, :order, :active)
|
||||
.permit(:title, :description, :link, :request_to_administrators, :day_offset, :required_supports, :order, :active, :action_type)
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@ class ProposalDashboardAction < ActiveRecord::Base
|
||||
acts_as_paranoid column: :hidden_at
|
||||
include ActsAsParanoidAliases
|
||||
|
||||
enum action_type: %i[proposed_action resource]
|
||||
|
||||
validates :title,
|
||||
presence: true,
|
||||
allow_blank: false,
|
||||
@@ -14,6 +16,8 @@ class ProposalDashboardAction < ActiveRecord::Base
|
||||
allow_blank: false,
|
||||
length: { in: 4..255 }
|
||||
|
||||
validates :action_type, presence: true
|
||||
|
||||
validates :day_offset,
|
||||
presence: true,
|
||||
numericality: {
|
||||
|
||||
@@ -16,6 +16,15 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="small-12 medium-3 column">
|
||||
<%= f.label :action_type %>
|
||||
<% ProposalDashboardAction.action_types.keys.each do |action_type_value| %>
|
||||
<%= f.radio_button :action_type, action_type_value, label: false %>
|
||||
<%= f.label "action_type_#{action_type_value}", t("admin.proposal_dashboard_actions.action_type.#{action_type_value}") %>
|
||||
<br>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div class="small-12 column">
|
||||
<%= f.check_box :request_to_administrators, label: ProposalDashboardAction.human_attribute_name(:request_to_administrators) %>
|
||||
</div>
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th><%= ProposalDashboardAction.human_attribute_name(:title) %></th>
|
||||
<th><%= ProposalDashboardAction.human_attribute_name(:action_type) %></th>
|
||||
<th><%= ProposalDashboardAction.human_attribute_name(:active) %></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
@@ -24,6 +25,7 @@
|
||||
<% @proposal_dashboard_actions.each do |action| %>
|
||||
<tr id="<%= dom_id(action) %>">
|
||||
<td><%= action.title %></td>
|
||||
<td><%= t("admin.proposal_dashboard_actions.action_type.#{action.action_type}") %></td>
|
||||
<td><%= active_human_readable(action.active) %></td>
|
||||
<td style="text-align: right">
|
||||
<%= link_to t('admin.proposal_dashboard_actions.index.edit'),
|
||||
|
||||
@@ -271,6 +271,7 @@ en:
|
||||
required_supports: Required supports for the activation
|
||||
order: Order
|
||||
active: Active
|
||||
action_type: Type
|
||||
errors:
|
||||
models:
|
||||
user:
|
||||
|
||||
@@ -1091,6 +1091,9 @@ en:
|
||||
success: Geozone successfully deleted
|
||||
error: This geozone can't be deleted since there are elements attached to it
|
||||
proposal_dashboard_actions:
|
||||
action_type:
|
||||
proposed_action: Proposed action
|
||||
resource: Resource
|
||||
index:
|
||||
create: Create
|
||||
edit: Edit
|
||||
|
||||
@@ -272,6 +272,7 @@ es:
|
||||
required_supports: Soportes requeridos para la activación
|
||||
order: Orden
|
||||
active: Activa
|
||||
action_type: Tipo
|
||||
errors:
|
||||
models:
|
||||
user:
|
||||
|
||||
@@ -1091,6 +1091,9 @@ es:
|
||||
success: Distrito borrado correctamente
|
||||
error: No se puede borrar el distrito porque ya tiene elementos asociados
|
||||
proposal_dashboard_actions:
|
||||
action_type:
|
||||
proposed_action: Acción propuesta
|
||||
resource: Recurso
|
||||
index:
|
||||
create: Crear
|
||||
edit: Editar
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class AddActionTypeToProposalDashboardActions < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :proposal_dashboard_actions, :action_type, :integer, null: false, default: 0
|
||||
end
|
||||
end
|
||||
@@ -888,6 +888,7 @@ ActiveRecord::Schema.define(version: 20180711224810) do
|
||||
t.integer "order", default: 0
|
||||
t.boolean "active", default: true
|
||||
t.datetime "hidden_at"
|
||||
t.integer "action_type", default: 0, null: false
|
||||
end
|
||||
|
||||
create_table "proposal_notifications", force: :cascade do |t|
|
||||
|
||||
@@ -1039,6 +1039,7 @@ LOREM_IPSUM
|
||||
order 0
|
||||
active true
|
||||
hidden_at nil
|
||||
action_type 'proposed_action'
|
||||
|
||||
trait :admin_request do
|
||||
link nil
|
||||
@@ -1061,5 +1062,13 @@ LOREM_IPSUM
|
||||
trait :deleted do
|
||||
hidden_at { Time.now.utc }
|
||||
end
|
||||
|
||||
trait :proposed_action do
|
||||
action_type 'proposed_action'
|
||||
end
|
||||
|
||||
trait :resource do
|
||||
action_type 'resource'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -9,7 +9,8 @@ describe ProposalDashboardAction do
|
||||
day_offset: day_offset,
|
||||
required_supports: required_supports,
|
||||
link: link,
|
||||
request_to_administrators: request_to_administrators
|
||||
request_to_administrators: request_to_administrators,
|
||||
action_type: action_type
|
||||
end
|
||||
|
||||
let(:title) { Faker::Lorem.sentence }
|
||||
@@ -18,6 +19,7 @@ describe ProposalDashboardAction do
|
||||
let(:required_supports) { 0 }
|
||||
let(:link) { nil }
|
||||
let(:request_to_administrators) { true }
|
||||
let(:action_type) { 'resource' }
|
||||
|
||||
it { is_expected.to be_valid }
|
||||
|
||||
@@ -126,5 +128,11 @@ describe ProposalDashboardAction do
|
||||
it { is_expected.to be_valid }
|
||||
end
|
||||
end
|
||||
|
||||
context 'when action type is nil' do
|
||||
let(:action_type) { nil }
|
||||
|
||||
it { is_expected.not_to be_valid }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user