diff --git a/app/assets/stylesheets/proposal.scss b/app/assets/stylesheets/proposal.scss
index 4eb3ff94f..7ce64dddc 100644
--- a/app/assets/stylesheets/proposal.scss
+++ b/app/assets/stylesheets/proposal.scss
@@ -249,4 +249,49 @@
.proposal-dashboard-action-links {
margin-bottom: 15pt;
}
+
+ .resource-card {
+ min-height: 200pt;
+
+ .bottom-container {
+ position: relative;
+ padding-left: 0;
+ padding-right: 0;
+
+ .bottom-element {
+ position: absolute;
+ bottom: 0;
+ width: 100%;
+ }
+ }
+ }
+
+ .resource-card.success {
+ background-color: #c5f6eb;
+
+ i {
+ display: inline-block;
+ width: 20pt;
+ height: 20pt;
+ color: #00cf96;
+ border-radius: 10pt;
+ border: 1pt solid #00cf96;
+ padding-right: 4pt;
+ }
+ }
+
+ .resource-card.alert {
+ background-color: #ffe5e8;
+
+ i {
+ display: inline-block;
+ width: 20pt;
+ height: 20pt;
+ color: #ff828b;
+ border-radius: 10pt;
+ border: 1pt solid #ff828b;
+ padding-right: 4pt;
+
+ }
+ }
}
diff --git a/app/controllers/dashboard/base_controller.rb b/app/controllers/dashboard/base_controller.rb
index ae2ef7d17..a123863b4 100644
--- a/app/controllers/dashboard/base_controller.rb
+++ b/app/controllers/dashboard/base_controller.rb
@@ -13,11 +13,11 @@ class Dashboard::BaseController < ApplicationController
end
def proposed_actions
- @proposed_actions ||= ProposalDashboardAction.proposed_actions.active_for(proposal)
+ @proposed_actions ||= ProposalDashboardAction.proposed_actions.active_for(proposal).order(order: :asc)
end
def resources
- @resources ||= ProposalDashboardAction.resources.active_for(proposal)
+ @resources ||= ProposalDashboardAction.resources.active_for(proposal).order(order: :asc)
end
def next_goal_supports
diff --git a/app/controllers/proposals_dashboard_controller.rb b/app/controllers/proposals_dashboard_controller.rb
index 9aff111ca..497311010 100644
--- a/app/controllers/proposals_dashboard_controller.rb
+++ b/app/controllers/proposals_dashboard_controller.rb
@@ -1,5 +1,5 @@
class ProposalsDashboardController < Dashboard::BaseController
- helper_method :proposal_dashboard_action
+ helper_method :proposal_dashboard_action, :active_resources
def index
authorize! :dashboard, proposal
@@ -54,8 +54,11 @@ class ProposalsDashboardController < Dashboard::BaseController
private
-
def proposal_dashboard_action
@proposal_dashboard_action ||= ProposalDashboardAction.find(params[:id])
end
+
+ def active_resources
+ ProposalDashboardAction.active.resources.order(required_supports: :asc, day_offset: :asc)
+ end
end
diff --git a/app/helpers/proposals_dashboard_helper.rb b/app/helpers/proposals_dashboard_helper.rb
index 1e7d502fb..43bc78e21 100644
--- a/app/helpers/proposals_dashboard_helper.rb
+++ b/app/helpers/proposals_dashboard_helper.rb
@@ -61,4 +61,13 @@ module ProposalsDashboardHelper
def is_request_active(id)
controller_name == 'proposals_dashboard' && action_name == 'new_request' && proposal_dashboard_action&.id == id
end
+
+ def resoure_availability_label(resource)
+ label = []
+
+ label << t('.required_days', days: resource.day_offset) if resource.day_offset > 0
+ label << t('.required_supports', supports: number_with_delimiter(resource.required_supports, delimiter: '.')) if resource.required_supports > 0
+
+ label.join(" #{t('.and')}
")
+ end
end
diff --git a/app/models/link.rb b/app/models/link.rb
index 10261e9c0..c8a4a0a5b 100644
--- a/app/models/link.rb
+++ b/app/models/link.rb
@@ -3,5 +3,4 @@ class Link < ActiveRecord::Base
validates :label, presence: true
validates :url, presence: true
- validates :linkable, presence: true
end
diff --git a/app/models/proposal_dashboard_action.rb b/app/models/proposal_dashboard_action.rb
index 4eb1e8a69..7247c8dc7 100644
--- a/app/models/proposal_dashboard_action.rb
+++ b/app/models/proposal_dashboard_action.rb
@@ -39,8 +39,6 @@ class ProposalDashboardAction < ActiveRecord::Base
greater_than_or_equal_to: 0
}
- default_scope { order(order: :asc, title: :asc) }
-
scope :active, -> { where(active: true) }
scope :inactive, -> { where(active: false) }
scope :resources, -> { where(action_type: 1) }
@@ -53,20 +51,19 @@ class ProposalDashboardAction < ActiveRecord::Base
.where('day_offset <= ?', (Date.today - published_at).to_i)
end
- def self.next_goal_for(proposal)
+ def active_for?(proposal)
published_at = proposal.published_at&.to_date || Date.today
+ required_supports <= proposal.votes_for.size && day_offset <= (Date.today - published_at).to_i
+ end
+
+ def self.next_goal_for(proposal)
active
- .where(
- '(required_supports > ? or day_offset > ?)',
- proposal.votes_for.size,
- (Date.today - published_at).to_i)
+ .where('required_supports > ?', proposal.votes_for.size)
.order(required_supports: :asc)
&.first
end
- default_scope { order(order: :asc, title: :asc) }
-
def request_to_administrators?
request_to_administrators || false
end
diff --git a/app/views/proposals_dashboard/_resource.html.erb b/app/views/proposals_dashboard/_resource.html.erb
new file mode 100644
index 000000000..8adf199cd
--- /dev/null
+++ b/app/views/proposals_dashboard/_resource.html.erb
@@ -0,0 +1,30 @@
+
+ <% if resource.active_for?(proposal) %> + + <% else %> + + <% end %> +
++ <%= resource.short_description %> +
+