<%= f.submit(class: 'button expanded', value: t('admin.proposal_dashboard_actions.form.submit_button')) %>
diff --git a/app/views/admin/proposal_dashboard/actions/index.html.erb b/app/views/admin/proposal_dashboard/actions/index.html.erb
index a12bb416a..997df7dac 100644
--- a/app/views/admin/proposal_dashboard/actions/index.html.erb
+++ b/app/views/admin/proposal_dashboard/actions/index.html.erb
@@ -10,7 +10,8 @@
| <%= ProposalDashboardAction.human_attribute_name(:title) %> |
<%= ProposalDashboardAction.human_attribute_name(:action_type) %> |
- <%= ProposalDashboardAction.human_attribute_name(:active) %> |
+ <%= ProposalDashboardAction.human_attribute_name(:required_supports) %> |
+ <%= ProposalDashboardAction.human_attribute_name(:active) %> |
|
@@ -26,8 +27,9 @@
| <%= action.title %> |
<%= t("admin.proposal_dashboard_actions.action_type.#{action.action_type}") %> |
- <%= active_human_readable(action.active) %> |
-
+ | <%= action.required_supports %> |
+ <%= active_human_readable(action.active) %> |
+
<%= link_to t('admin.proposal_dashboard_actions.index.edit'),
edit_admin_proposal_dashboard_action_path(action),
class: 'edit-banner button hollow' %>
diff --git a/app/views/admin/proposal_dashboard/administrator_tasks/_form.html.erb b/app/views/admin/proposal_dashboard/administrator_tasks/_form.html.erb
index 20985eda3..c1bfc7655 100644
--- a/app/views/admin/proposal_dashboard/administrator_tasks/_form.html.erb
+++ b/app/views/admin/proposal_dashboard/administrator_tasks/_form.html.erb
@@ -3,7 +3,6 @@
<%=t '.proposal', title: administrator_task.source.proposal.title %>
<%=t '.request', title: administrator_task.source.proposal_dashboard_action.title %>
- <%== administrator_task.source.comments unless administrator_task.source.comments.blank? %>
<%= link_to t('.check_details'), proposal_path(administrator_task.source.proposal), target: '_blank' %>
diff --git a/app/views/links/_link_fields.html.erb b/app/views/links/_link_fields.html.erb
new file mode 100644
index 000000000..6a615399f
--- /dev/null
+++ b/app/views/links/_link_fields.html.erb
@@ -0,0 +1,20 @@
+
+
+ <%= f.text_field :label, placeholder: t('.label_placeholder') %>
+
+
+
+ <%= f.text_field :url, placeholder: t('.url_placeholder') %>
+
+
+
+ <%= f.check_box :open_in_new_tab, label: Link.human_attribute_name(:open_in_new_tab) %>
+
+
+
+ <%= f.check_box :_destroy, label: t('.destroy') if f.object.id.present? %>
+
+
+
+
+
diff --git a/app/views/links/_nested_links.html.erb b/app/views/links/_nested_links.html.erb
new file mode 100644
index 000000000..c46209798
--- /dev/null
+++ b/app/views/links/_nested_links.html.erb
@@ -0,0 +1,22 @@
+
+ <%= f.hidden_field :id %>
+
+ <%= f.label :links, t('.title') %>
+ <%= t('.note') %>
+
+
+ <%= f.fields_for :links do |links_builder| %>
+ <%= render 'links/link_fields', f: links_builder %>
+ <% end %>
+
+
+ <%= link_to_add_association t('.add_new_link'), f, :links,
+ partial: 'links/link_fields',
+ id: 'new_link_button',
+ class: 'button hollow',
+ data: {
+ association_insertion_node: '#nested-links',
+ association_insertion_method: 'append'
+ } %>
+
+
diff --git a/app/views/proposals_dashboard/_form.html.erb b/app/views/proposals_dashboard/_form.html.erb
index c4bebac28..4b5ae62d0 100644
--- a/app/views/proposals_dashboard/_form.html.erb
+++ b/app/views/proposals_dashboard/_form.html.erb
@@ -1,12 +1,8 @@
-<%= form_for @proposal_executed_dashboard_action,
- url: create_request_proposal_dashboard_url(proposal, proposal_dashboard_action) do |f| %>
- <%= render 'shared/errors', resource: @proposal_executed_dashboard_action %>
-
-
- <%= f.label :comments %>
- <%= f.cktext_area :comments, ckeditor: { language: I18n.locale }, label: false %>
-
-
- <%= f.submit(class: 'button', value: t('.request')) %>
-
+<% if proposal_dashboard_action.request_to_administrators %>
+ <%= form_for @proposal_executed_dashboard_action,
+ url: create_request_proposal_dashboard_url(proposal, proposal_dashboard_action) do |f| %>
+
+ <%= f.submit(class: 'button hollow expanded', value: t('.request')) %>
+
+ <% end %>
<% end %>
diff --git a/app/views/proposals_dashboard/_menu.html.erb b/app/views/proposals_dashboard/_menu.html.erb
index 79b4e186f..a56ff4a52 100644
--- a/app/views/proposals_dashboard/_menu.html.erb
+++ b/app/views/proposals_dashboard/_menu.html.erb
@@ -32,12 +32,10 @@
<% resources.each do |resource| %>
>
- <% if resource.request_to_administrators? %>
- <%= link_to new_request_proposal_dashboard_path(proposal, resource) do %>
- <%= resource.title %>
- <% end %>
- <% else %>
- <%= link_to resource.title, resource.link, target: '_blank' %>
+ <%= link_to new_request_proposal_dashboard_path(proposal, resource) do %>
+
+ <%= resource.title %>
+
<% end %>
<% end %>
diff --git a/app/views/proposals_dashboard/_proposed_action.html.erb b/app/views/proposals_dashboard/_proposed_action.html.erb
index b91a6c736..3cf8d458e 100644
--- a/app/views/proposals_dashboard/_proposed_action.html.erb
+++ b/app/views/proposals_dashboard/_proposed_action.html.erb
@@ -1,30 +1,18 @@
|
|
- <% if action.link.blank? %>
-
+ <%= link_to new_request_proposal_dashboard_path(proposal, action) do %>
+
<%= action.title %>
- <% else %>
- <%= link_to action.link, target: '_blank' do %>
-
- <%= action.title %>
-
- <% end %>
<% end %>
|
<% if action.proposals.where(id: proposal.id).any? %>
<%=l action.proposal_executed_dashboard_actions.find_by(proposal: proposal).executed_at, format: :short %>
<% else %>
- <% if action.request_to_administrators? %>
- <%= link_to t('.execute'),
- new_request_proposal_dashboard_path(proposal, action) %>
- <% else %>
- <%= link_to t('.execute'),
- execute_proposal_dashboard_path(proposal.to_param, action.to_param),
- method: 'post',
- data: { confirm: t('admin.actions.confirm') } %>
- <% end %>
+ <%= link_to t('.execute'),
+ execute_proposal_dashboard_path(proposal, action),
+ method: 'post' %>
<% end %>
|
diff --git a/app/views/proposals_dashboard/new_request.html.erb b/app/views/proposals_dashboard/new_request.html.erb
index e52a2aa2d..7e2e6dec6 100644
--- a/app/views/proposals_dashboard/new_request.html.erb
+++ b/app/views/proposals_dashboard/new_request.html.erb
@@ -1,15 +1,25 @@
-<% content_for :action_title, t('.title') %>
-
-
+<% content_for :action_title, proposal_dashboard_action.title %>
+
- <%= back_link_to %>
+ <%== proposal_dashboard_action.description %>
+
-
<%= proposal_dashboard_action.title %>
-
- <%= proposal_dashboard_action.description %>
-
+
+ <% if proposal_dashboard_action.links.any? %>
+
+
<%= t('.links') %>
+ <% proposal_dashboard_action.links.each do |link| %>
+ <% if link.open_in_new_tab %>
+ <%= link_to link.label, link.url, target: '_blank' %>
+ <% else %>
+ <%= link_to link.label, link.url %>
+ <% end %>
+ <% end %>
+
+ <% end %>
+ <%= render 'documents/documents', documents: proposal_dashboard_action.documents %>
<%= render 'proposals_dashboard/form' %>
diff --git a/config/locales/en/activerecord.yml b/config/locales/en/activerecord.yml
index f2454734c..6e0838c8b 100644
--- a/config/locales/en/activerecord.yml
+++ b/config/locales/en/activerecord.yml
@@ -112,6 +112,9 @@ en:
administrator_task:
one: Task
other: Tasks
+ link:
+ one: Link
+ other: Links
attributes:
budget:
name: "Name"
@@ -267,6 +270,7 @@ en:
limit: Number of items
proposal_dashboard_action:
title: Title
+ short_description: Short description
description: Description
link: External link
request_to_administrators: Admin request
@@ -275,12 +279,13 @@ en:
order: Order
active: Active
action_type: Type
- proposal_executed_dashboard_action:
- comments: Comments for the administrator
administrator_task:
source: Source
user: Executed by
- executed_at: Executed at
+ link:
+ label: Title
+ url: Link
+ open_in_new_tab: Open in new tab
errors:
models:
user:
diff --git a/config/locales/en/general.yml b/config/locales/en/general.yml
index e4f521acc..2bf232593 100644
--- a/config/locales/en/general.yml
+++ b/config/locales/en/general.yml
@@ -531,7 +531,7 @@ en:
retire: Retire
send_notification: Send notification
new_request:
- title: Administrator request
+ links: Links
dashboard:
polls:
form:
@@ -943,3 +943,12 @@ en:
text_sign_in: login
text_sign_up: sign up
title: How I can comment this document?
+ links:
+ nested_links:
+ title: Links
+ note: Add the links that are of interest
+ add_new_link: Add new link
+ link_fields:
+ label_placeholder: Link title
+ url_placeholder: Link address
+ destroy: Remove link
diff --git a/config/locales/es/activerecord.yml b/config/locales/es/activerecord.yml
index 0b17a6f4c..976ad6847 100644
--- a/config/locales/es/activerecord.yml
+++ b/config/locales/es/activerecord.yml
@@ -112,6 +112,9 @@ es:
administrator_task:
one: Tarea
other: Tareas
+ link:
+ one: Enlace
+ other: Enlaces
attributes:
budget:
name: "Nombre"
@@ -268,6 +271,7 @@ es:
limit: Número de elementos
proposal_dashboard_action:
title: Título
+ short_description: Descripción corta
description: Descripción
link: Enlace externo
request_to_administrators: Petición para administrador
@@ -276,12 +280,14 @@ es:
order: Orden
active: Activa
action_type: Tipo
- proposal_executed_dashboard_action:
- comments: Comentarios para el administrador
administrator_task:
source: Fuente
user: Ejecutado por
executed_at: Ejecutado el
+ link:
+ label: Título
+ url: Enlace
+ open_in_new_tab: Abrir en ventana nueva
errors:
models:
user:
diff --git a/config/locales/es/general.yml b/config/locales/es/general.yml
index 78aa4c351..22515db26 100644
--- a/config/locales/es/general.yml
+++ b/config/locales/es/general.yml
@@ -531,7 +531,7 @@ es:
retire: Retirar
send_notification: Enviar notificación
new_request:
- title: Petición al administrador
+ liks: Enlaces
dashboard:
polls:
form:
@@ -942,3 +942,12 @@ es:
text_sign_in: iniciar sesión
text_sign_up: registrarte
title: "¿Cómo puedo comentar este documento?"
+ links:
+ nested_links:
+ title: Enlaces
+ note: Añade los enlaces que sean de interés.
+ add_new_link: Añadir nuevo enlace
+ link_fields:
+ label_placeholder: Título del enlace
+ url_placeholder: Dirección del enlace
+ destroy: Borrar enlace
diff --git a/db/migrate/20180702050717_add_short_description_to_proposal_dashboard_actions.rb b/db/migrate/20180702050717_add_short_description_to_proposal_dashboard_actions.rb
new file mode 100644
index 000000000..5921b93c0
--- /dev/null
+++ b/db/migrate/20180702050717_add_short_description_to_proposal_dashboard_actions.rb
@@ -0,0 +1,6 @@
+class AddShortDescriptionToProposalDashboardActions < ActiveRecord::Migration
+ def change
+ add_column :proposal_dashboard_actions, :short_description, :string
+ change_column :proposal_dashboard_actions, :description, :text
+ end
+end
diff --git a/db/migrate/20180702060913_create_links.rb b/db/migrate/20180702060913_create_links.rb
new file mode 100644
index 000000000..cbe0ac431
--- /dev/null
+++ b/db/migrate/20180702060913_create_links.rb
@@ -0,0 +1,12 @@
+class CreateLinks < ActiveRecord::Migration
+ def change
+ create_table :links do |t|
+ t.string :label
+ t.string :url
+ t.boolean :open_in_new_tab
+ t.references :linkable, polymorphic: true, index: true
+
+ t.timestamps null: false
+ end
+ end
+end
diff --git a/db/migrate/20180702085737_remove_comments_from_proposal_executed_dashboard_action.rb b/db/migrate/20180702085737_remove_comments_from_proposal_executed_dashboard_action.rb
new file mode 100644
index 000000000..1f15c7bb1
--- /dev/null
+++ b/db/migrate/20180702085737_remove_comments_from_proposal_executed_dashboard_action.rb
@@ -0,0 +1,5 @@
+class RemoveCommentsFromProposalExecutedDashboardAction < ActiveRecord::Migration
+ def change
+ remove_column :proposal_executed_dashboard_actions, :comments, :text
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 6998489f7..7942e3844 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20180625075520) do
+ActiveRecord::Schema.define(version: 20180702085737) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -635,6 +635,18 @@ ActiveRecord::Schema.define(version: 20180625075520) do
add_index "legislation_questions", ["hidden_at"], name: "index_legislation_questions_on_hidden_at", using: :btree
add_index "legislation_questions", ["legislation_process_id"], name: "index_legislation_questions_on_legislation_process_id", using: :btree
+ create_table "links", force: :cascade do |t|
+ t.string "label"
+ t.string "url"
+ t.boolean "open_in_new_tab"
+ t.integer "linkable_id"
+ t.string "linkable_type"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ end
+
+ add_index "links", ["linkable_type", "linkable_id"], name: "index_links_on_linkable_type_and_linkable_id", using: :btree
+
create_table "local_census_records", force: :cascade do |t|
t.string "document_number", null: false
t.string "document_type", null: false
@@ -895,7 +907,7 @@ ActiveRecord::Schema.define(version: 20180625075520) do
create_table "proposal_dashboard_actions", force: :cascade do |t|
t.string "title", limit: 80
- t.string "description"
+ t.text "description"
t.string "link"
t.boolean "request_to_administrators", default: false
t.integer "day_offset", default: 0
@@ -904,13 +916,13 @@ ActiveRecord::Schema.define(version: 20180625075520) do
t.boolean "active", default: true
t.datetime "hidden_at"
t.integer "action_type", default: 0, null: false
+ t.string "short_description"
end
create_table "proposal_executed_dashboard_actions", force: :cascade do |t|
t.integer "proposal_id"
t.integer "proposal_dashboard_action_id"
t.datetime "executed_at"
- t.text "comments"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
diff --git a/lib/tasks/proposal_actions.rake b/lib/tasks/proposal_actions.rake
new file mode 100644
index 000000000..ba72c1191
--- /dev/null
+++ b/lib/tasks/proposal_actions.rake
@@ -0,0 +1,13 @@
+namespace :proposal_actions do
+ desc 'Move link attribute to links collection'
+ task migrate_links: :environment do
+ ProposalDashboardAction.where.not(link: nil).each do |action|
+ Link.create!(
+ label: action.title,
+ url: action.link,
+ open_in_new_tab: true,
+ linkable: action
+ )
+ end
+ end
+end
diff --git a/spec/factories.rb b/spec/factories.rb
index 9ffb97b35..625a121eb 100644
--- a/spec/factories.rb
+++ b/spec/factories.rb
@@ -1076,14 +1076,10 @@ LOREM_IPSUM
proposal
proposal_dashboard_action
executed_at { Time.current }
-
- trait :with_comments do
- comments { Faker::Lorem.sentence(10) }
- end
end
factory :administrator_task do
- source { |s| s.association(:proposal_executed_dashboard_action, :with_comments) }
+ source { |s| s.association(:proposal_executed_dashboard_action) }
user
executed_at { Time.current }
@@ -1097,4 +1093,15 @@ LOREM_IPSUM
executed_at { Time.current }
end
end
+
+ factory :link do
+ linkable { |s| s.association(:proposal_dashboard_action) }
+ label { Faker::Lorem.sentence }
+ url { Faker::Internet.url }
+ open_in_new_tab false
+
+ trait :open_in_new_tab do
+ open_in_new_tab true
+ end
+ end
end
diff --git a/spec/features/admin/administrator_tasks_spec.rb b/spec/features/admin/administrator_tasks_spec.rb
index 08a1bac3b..7830f5663 100644
--- a/spec/features/admin/administrator_tasks_spec.rb
+++ b/spec/features/admin/administrator_tasks_spec.rb
@@ -55,10 +55,6 @@ describe 'Administrator tasks' do
expect(page).to have_button('Mark as solved')
end
- scenario 'shows the comments added by the user during the request' do
- expect(page).to have_content(task.source.comments)
- end
-
context 'and the Mark as solved button is pressed' do
before do
click_button 'Mark as solved'
diff --git a/spec/models/link_spec.rb b/spec/models/link_spec.rb
new file mode 100644
index 000000000..aa905d1fb
--- /dev/null
+++ b/spec/models/link_spec.rb
@@ -0,0 +1,29 @@
+require 'rails_helper'
+
+describe Link do
+ subject do
+ build :link,
+ linkable: proposal_dashboard_action,
+ label: label,
+ url: url,
+ open_in_new_tab: true
+ end
+
+ let(:proposal_dashboard_action) { build :proposal_dashboard_action }
+ let(:label) { Faker::Lorem.sentence }
+ let(:url) { Faker::Internet.url }
+
+ it { should be_valid }
+
+ context 'when label is blank' do
+ let(:label) { '' }
+
+ it { should_not be_valid }
+ end
+
+ context 'when url is blank' do
+ let(:url) { '' }
+
+ it { should_not be_valid }
+ end
+end
diff --git a/spec/models/proposal_dashboard_action_spec.rb b/spec/models/proposal_dashboard_action_spec.rb
index 13383cc4f..83d7d568a 100644
--- a/spec/models/proposal_dashboard_action_spec.rb
+++ b/spec/models/proposal_dashboard_action_spec.rb
@@ -7,7 +7,6 @@ describe ProposalDashboardAction do
description: description,
day_offset: day_offset,
required_supports: required_supports,
- link: link,
request_to_administrators: request_to_administrators,
action_type: action_type
end
@@ -16,7 +15,6 @@ describe ProposalDashboardAction do
let(:description) { Faker::Lorem.sentence }
let(:day_offset) { 0 }
let(:required_supports) { 0 }
- let(:link) { nil }
let(:request_to_administrators) { true }
let(:action_type) { 'resource' }
@@ -48,18 +46,6 @@ describe ProposalDashboardAction do
it { should_not be_valid }
end
-
- context 'and description is very short' do
- let(:description) { 'abc' }
-
- it { should_not be_valid }
- end
-
- context 'and description is very long' do
- let(:description) { 'a' * 256 }
-
- it { should_not be_valid }
- end
end
context 'when validating day_offset' do
@@ -102,32 +88,6 @@ describe ProposalDashboardAction do
end
end
- context 'when url is blank' do
- let(:link) { nil }
-
- context 'and no request_to_administrators' do
- let(:request_to_administrators) { false }
-
- it { should_not be_valid }
- end
-
- context 'and request_to_administrators' do
- let(:request_to_administrators) { true }
-
- it { should be_valid }
- end
- end
-
- context 'when url is not blank' do
- let(:link) { Faker::Internet.url }
-
- context 'and no request_to_administrators' do
- let(:request_to_administrators) { false }
-
- it { should be_valid }
- end
- end
-
context 'when action type is nil' do
let(:action_type) { nil }
diff --git a/spec/models/proposal_executed_dashboard_action_spec.rb b/spec/models/proposal_executed_dashboard_action_spec.rb
index 6072d4867..19c522ed3 100644
--- a/spec/models/proposal_executed_dashboard_action_spec.rb
+++ b/spec/models/proposal_executed_dashboard_action_spec.rb
@@ -5,8 +5,7 @@ describe ProposalExecutedDashboardAction do
build :proposal_executed_dashboard_action,
proposal: proposal,
proposal_dashboard_action: proposal_dashboard_action,
- executed_at: executed_at,
- comments: comments
+ executed_at: executed_at
end
let(:proposal) { create :proposal }
@@ -15,7 +14,6 @@ describe ProposalExecutedDashboardAction do
end
let(:request_to_administrators) { false }
let(:executed_at) { Time.current }
- let(:comments) { '' }
it { should be_valid }
@@ -40,17 +38,7 @@ describe ProposalExecutedDashboardAction do
context 'when the action sends a request to the administrators' do
let(:request_to_administrators) { true }
- context 'and comments are blank' do
- let(:comments) { '' }
-
- it { should_not be_valid }
- end
-
- context 'and comments have value' do
- let(:comments) { Faker::Lorem.sentence }
-
- it { should be_valid }
- end
+ it { should be_valid }
end
context 'when it has been already executed' do