Implements #182
Implements 182. resources are shown as cards in dashboard progress view. Implements #182 Implements 182. resources are shown as cards in dashboard progress view.
This commit is contained in:
@@ -249,4 +249,49 @@
|
|||||||
.proposal-dashboard-action-links {
|
.proposal-dashboard-action-links {
|
||||||
margin-bottom: 15pt;
|
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;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,11 +13,11 @@ class Dashboard::BaseController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def proposed_actions
|
def proposed_actions
|
||||||
@proposed_actions ||= ProposalDashboardAction.proposed_actions.active_for(proposal)
|
@proposed_actions ||= ProposalDashboardAction.proposed_actions.active_for(proposal).order(order: :asc)
|
||||||
end
|
end
|
||||||
|
|
||||||
def resources
|
def resources
|
||||||
@resources ||= ProposalDashboardAction.resources.active_for(proposal)
|
@resources ||= ProposalDashboardAction.resources.active_for(proposal).order(order: :asc)
|
||||||
end
|
end
|
||||||
|
|
||||||
def next_goal_supports
|
def next_goal_supports
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
class ProposalsDashboardController < Dashboard::BaseController
|
class ProposalsDashboardController < Dashboard::BaseController
|
||||||
helper_method :proposal_dashboard_action
|
helper_method :proposal_dashboard_action, :active_resources
|
||||||
|
|
||||||
def index
|
def index
|
||||||
authorize! :dashboard, proposal
|
authorize! :dashboard, proposal
|
||||||
@@ -54,8 +54,11 @@ class ProposalsDashboardController < Dashboard::BaseController
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
|
||||||
def proposal_dashboard_action
|
def proposal_dashboard_action
|
||||||
@proposal_dashboard_action ||= ProposalDashboardAction.find(params[:id])
|
@proposal_dashboard_action ||= ProposalDashboardAction.find(params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def active_resources
|
||||||
|
ProposalDashboardAction.active.resources.order(required_supports: :asc, day_offset: :asc)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -61,4 +61,13 @@ module ProposalsDashboardHelper
|
|||||||
def is_request_active(id)
|
def is_request_active(id)
|
||||||
controller_name == 'proposals_dashboard' && action_name == 'new_request' && proposal_dashboard_action&.id == id
|
controller_name == 'proposals_dashboard' && action_name == 'new_request' && proposal_dashboard_action&.id == id
|
||||||
end
|
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')}<br>")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,5 +3,4 @@ class Link < ActiveRecord::Base
|
|||||||
|
|
||||||
validates :label, presence: true
|
validates :label, presence: true
|
||||||
validates :url, presence: true
|
validates :url, presence: true
|
||||||
validates :linkable, presence: true
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -39,8 +39,6 @@ class ProposalDashboardAction < ActiveRecord::Base
|
|||||||
greater_than_or_equal_to: 0
|
greater_than_or_equal_to: 0
|
||||||
}
|
}
|
||||||
|
|
||||||
default_scope { order(order: :asc, title: :asc) }
|
|
||||||
|
|
||||||
scope :active, -> { where(active: true) }
|
scope :active, -> { where(active: true) }
|
||||||
scope :inactive, -> { where(active: false) }
|
scope :inactive, -> { where(active: false) }
|
||||||
scope :resources, -> { where(action_type: 1) }
|
scope :resources, -> { where(action_type: 1) }
|
||||||
@@ -53,20 +51,19 @@ class ProposalDashboardAction < ActiveRecord::Base
|
|||||||
.where('day_offset <= ?', (Date.today - published_at).to_i)
|
.where('day_offset <= ?', (Date.today - published_at).to_i)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.next_goal_for(proposal)
|
def active_for?(proposal)
|
||||||
published_at = proposal.published_at&.to_date || Date.today
|
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
|
active
|
||||||
.where(
|
.where('required_supports > ?', proposal.votes_for.size)
|
||||||
'(required_supports > ? or day_offset > ?)',
|
|
||||||
proposal.votes_for.size,
|
|
||||||
(Date.today - published_at).to_i)
|
|
||||||
.order(required_supports: :asc)
|
.order(required_supports: :asc)
|
||||||
&.first
|
&.first
|
||||||
end
|
end
|
||||||
|
|
||||||
default_scope { order(order: :asc, title: :asc) }
|
|
||||||
|
|
||||||
def request_to_administrators?
|
def request_to_administrators?
|
||||||
request_to_administrators || false
|
request_to_administrators || false
|
||||||
end
|
end
|
||||||
|
|||||||
30
app/views/proposals_dashboard/_resource.html.erb
Normal file
30
app/views/proposals_dashboard/_resource.html.erb
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<div class="column" id="<%= dom_id(resource) %>">
|
||||||
|
<div class="card resource-card <%= resource.active_for?(proposal) ? 'success' : 'alert' %>">
|
||||||
|
<div class="card-section">
|
||||||
|
<p class="text-right">
|
||||||
|
<% if resource.active_for?(proposal) %>
|
||||||
|
<i class="fi-check"></i>
|
||||||
|
<% else %>
|
||||||
|
<i class="fi-lock"></i>
|
||||||
|
<% end %>
|
||||||
|
</p>
|
||||||
|
<h4 class="text-center"><%= resource.title %></h4>
|
||||||
|
<p class="text-center">
|
||||||
|
<%= resource.short_description %>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="card-section text-center bottom-container">
|
||||||
|
<% if resource.active_for?(proposal) %>
|
||||||
|
<div class="bottom-element text-center">
|
||||||
|
<%= link_to t('.view_resource'), new_request_proposal_dashboard_path(proposal, resource), class: 'button success' %>
|
||||||
|
</div>
|
||||||
|
<% else %>
|
||||||
|
<strong>
|
||||||
|
<%== resoure_availability_label(resource) %>
|
||||||
|
</strong>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
10
app/views/proposals_dashboard/_resources.html.erb
Normal file
10
app/views/proposals_dashboard/_resources.html.erb
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<% if active_resources.any? %>
|
||||||
|
<div class="action-title">
|
||||||
|
<h5><%= t('.available_resources') %></h5>
|
||||||
|
<hr>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row small-up-2 medium-up-3 large-up-4">
|
||||||
|
<%= render partial: 'resource', collection: active_resources %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
@@ -27,3 +27,5 @@
|
|||||||
<%= render partial: 'proposed_action', locals: { action: action } %>
|
<%= render partial: 'proposed_action', locals: { action: action } %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
<%= render 'resources' %>
|
||||||
|
|||||||
@@ -532,6 +532,13 @@ en:
|
|||||||
send_notification: Send notification
|
send_notification: Send notification
|
||||||
new_request:
|
new_request:
|
||||||
links: Links
|
links: Links
|
||||||
|
resources:
|
||||||
|
available_resources: Available resources
|
||||||
|
resource:
|
||||||
|
required_days: "%{days} days required"
|
||||||
|
required_supports: "%{supports} supports required"
|
||||||
|
and: and
|
||||||
|
view_resource: See resource
|
||||||
dashboard:
|
dashboard:
|
||||||
polls:
|
polls:
|
||||||
index:
|
index:
|
||||||
|
|||||||
@@ -532,6 +532,13 @@ es:
|
|||||||
send_notification: Enviar notificación
|
send_notification: Enviar notificación
|
||||||
new_request:
|
new_request:
|
||||||
liks: Enlaces
|
liks: Enlaces
|
||||||
|
resources:
|
||||||
|
available_resources: Recursos disponibles
|
||||||
|
resource:
|
||||||
|
required_days: "%{days} días necesarios"
|
||||||
|
required_supports: "%{supports} apoyos necesarios"
|
||||||
|
and: y
|
||||||
|
view_resource: Ver recurso
|
||||||
dashboard:
|
dashboard:
|
||||||
polls:
|
polls:
|
||||||
index:
|
index:
|
||||||
|
|||||||
Reference in New Issue
Block a user