Skip to content

Commit

Permalink
v1.11.0
Browse files Browse the repository at this point in the history
Merge pull request #632 from TechforgoodCAST/develop
  • Loading branch information
suninthesky authored Mar 16, 2018
2 parents 6441311 + 433de42 commit 339d6c1
Show file tree
Hide file tree
Showing 47 changed files with 829 additions and 430 deletions.
73 changes: 45 additions & 28 deletions app/admin/fund.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
:max_duration_awarded_limited, :max_duration_awarded,
:min_org_income_limited, :min_org_income,
:max_org_income_limited, :max_org_income,
:pretty_name,
country_ids: [], district_ids: [], theme_ids: [],
tags: [], permitted_costs: [], permitted_org_types: [],
questions_attributes: [:id, :group, :criterion, :criterion_id, :criterion_type, :_destroy]
Expand Down Expand Up @@ -61,26 +62,34 @@ def find_resource
config.sort_order = 'updated_at_desc'

show do
attributes_table do
row :slug
row :funder do |fund|
link_to fund.funder.name, [:admin, fund.funder]
end
row :name
row :description do fund.description_html.html_safe end
row :open_call
row :featured
row :state
row :currency
row :application_link do
"<a href=\"#{fund.application_link}\">#{fund.application_link}</a>".html_safe
end
row :key_criteria do fund.key_criteria_html.html_safe end
row :tags do
fund.tags.each.map{|r| "<span class=\"status_tag\">#{r}</span>"}.join(" ").html_safe
tabs do
tab :summary do
attributes_table do
row :funder do |fund|
link_to fund.funder.name, [:admin, fund.funder]
end
row :name
row :state
row :description do fund.description_html.html_safe end
row :application_link do
"<a href=\"#{fund.application_link}\">#{fund.application_link}</a>".html_safe
end
row :key_criteria do fund.key_criteria_html.html_safe end
row :themes do
fund.themes.each.map do |t|
"<span class='status_tag'>#{t.name}</span>"
end.join(" \&bull; ").html_safe
end
end
end
row :themes do
fund.themes.each.map{|t| "<span class=\"status_tag\">#{t.name}</span>"}.join(" ").html_safe
tab :admin do
attributes_table do
row :slug
row :pretty_name
row :open_call
row :featured
row :currency
end
end
end

Expand Down Expand Up @@ -109,16 +118,23 @@ def find_resource

attributes_table do
row :restrictions_known
row :priorities_known
row :questions do
fund.questions.group_by{ |q| q.criterion_type }.each.map do |r, qs|
questions = qs.each.map do |q|
c = q.criterion
"<li>#{c.details}#{(" [INVERT]" if c.invert)}</li>"
end.join("")
"<strong>#{r.pluralize(qs.size)}</strong><ul>#{questions}</ul>"
end.join("").html_safe
row :restrictions do
labels = {
'Recipient' => 'Is your organisation...',
'Proposal' => 'Is your funding proposal for...'
}
invert = { true => 'Must', false => 'Must not' }

fund.restrictions.group_by { |r| [r.category, r.invert] }.map do |k, v|
li = v.map { |r| "<li>#{r.details}</li>" }.join
"
<i>#{invert[k[1]]}</i><br/>
<strong>#{labels[k[0]]}</strong>
<ul>#{li}</ul>
"
end.join.html_safe
end
row :priorities_known
end
end

Expand Down Expand Up @@ -157,6 +173,7 @@ def find_resource
f.input :slug
f.input :funder, input_html: { class: 'chosen-select' }
f.input :name
f.input :pretty_name
f.input :description
f.input :open_call
f.input :featured
Expand Down
1 change: 1 addition & 0 deletions app/assets/stylesheets/v2/application.sass
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
@import modules/padding
@import modules/shadow
@import modules/tag
@import modules/tooltip
@import modules/typography

@import custom
Expand Down
2 changes: 1 addition & 1 deletion app/assets/stylesheets/v2/custom.sass
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ article.featured
// =========================================================================
.markdown
h1, h2, h3, h4, h5, h6, p, ul
h1, h2, h3, h4, h5, h6, p, ul, ol
margin-bottom: 20px
h1, h2, h3, h4
font-weight: 300
Expand Down
1 change: 0 additions & 1 deletion app/assets/stylesheets/v2/modules/border.sass
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
.circle
border-radius: 9999px
.rounded
overflow: hidden
+prefix(border-radius, $base-radius, webkit moz)
.rounded-top
+prefix(border-radius, $base-radius $base-radius 0 0, webkit moz)
Expand Down
11 changes: 8 additions & 3 deletions app/assets/stylesheets/v2/modules/shadow.sass
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
// Config
// =========================================================================
@import base

// =========================================================================
.shadow
box-shadow: 0px 3px 6px 0px rgba(0, 0, 0, .16)
-moz-box-shadow: 0px 3px 6px 0px rgba(0, 0, 0, .16)
-webkit-box-shadow: 0px 3px 6px 0px rgba(0, 0, 0, .16)
+prefix(box-shadow, 0px 3px 6px 0px rgba(0, 0, 0, .16), moz webkit)
58 changes: 58 additions & 0 deletions app/assets/stylesheets/v2/modules/tooltip.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Config
// =========================================================================
@import base

// =========================================================================
.tooltip
position: relative
&:hover
cursor: help
&:after, &:before
opacity: 1

&:after, &:before
position: absolute
left: 50%
opacity: 0
transition: opacity 0.2s ease
+prefix(box-shadow, 0px 3px 6px 0px rgba(0, 0, 0, .16), moz webkit)

&:after
top: -5px
content: ''
transform: translateX(-50%)
border-width: 7px 6px 0 6px
border-style: solid
border-color: map-get($colors, night) transparent transparent transparent

&:before
top: -4px
content: attr(aria-label)
transform: translateX(-50%) translateY(-100%)
padding: map-get($scales, 15)
background: map-get($colors, night)
color: map-get($colors, 'white')
font-size: map-get($scales, 14)
line-height: map-get($scales, 18)
border-radius: $base-radius
min-width: 206px
pointer-events: none

.tooltip-left
&:after, &:before
transition: none

&:before
left: calc(0% - 6px)
top: 50%
transform: translateX(-100%) translateY(calc(-50% + 1px))
padding: map-get($scales, 5)
min-width: auto
white-space: nowrap

&:after
left: calc(0% - 10px)
top: 50%
transform: translateY(calc(-50% + 1px)) rotate(-90deg)
2 changes: 1 addition & 1 deletion app/cells/current_proposal_cell.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def title
if model
model.complete? ? model.title.truncate_words(3) : 'Current proposal'
else
'No proposal'
'No proposal to check'
end
end

Expand Down
32 changes: 0 additions & 32 deletions app/cells/progress/apply.rb

This file was deleted.

27 changes: 0 additions & 27 deletions app/cells/progress/request.rb

This file was deleted.

4 changes: 2 additions & 2 deletions app/cells/progress/show.slim
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
.mx-auto.shadow.border.rounded.border-silver.maxw420
= cell(:current_proposal, model&.proposal)

- steps.each do |s|
- steps.each_with_index do |s, i|
.border-top.border-silver class=s.highlight
.flex.items-center.px20.py16.progress-item
.indicator.mr20 class=s.indicator
.indicator.mr20 class=(s.indicator + position(i))
h5.mr-auto = s.label
h6.bold = s.message
45 changes: 29 additions & 16 deletions app/cells/progress_cell.rb
Original file line number Diff line number Diff line change
@@ -1,33 +1,46 @@
class ProgressCell < Cell::ViewModel
private

def eligibility_status
model&.eligibility_status
end

def fund
model&.fund || OpenStruct.new(stub?: false)
end

def proposal
model&.proposal
def position(i)
if i.zero?
' bot'
elsif i == (steps.size - 1)
' top'
else
' bot top'
end
end

def eligibility_status
model&.eligibility_status
def proposal
model&.proposal
end

def steps # TODO: refactor
opts = { fund: fund, proposal: proposal, status: eligibility_status }
old_opts = { fund: fund, proposal: proposal, status: eligibility_status }
opts = { assessment: model, featured: fund.featured? }

sections = {
request: Progress::Request.new(opts),
eligibility: Progress::Eligibility.new(opts),
suitability: Progress::Suitability.new(old_opts),
reveal: Progress::Reveal.new(opts),
apply: Progress::Apply.new(opts)
}

if fund.stub?
[
::Progress::Request.new(opts.merge(position: 'bot')),
::Progress::Eligibility.new(opts.merge(position: 'top bot')),
::Progress::Suitability.new(opts.merge(position: 'top bot')),
::Progress::Apply.new(opts.merge(position: 'top'))
]
sections.slice(:request, :eligibility, :suitability, :apply).values
elsif options[:subscribed] || fund.featured? || model&.revealed?
sections.slice(:eligibility, :suitability, :apply).values
else
[
::Progress::Eligibility.new(opts.merge(position: 'bot')),
::Progress::Suitability.new(opts.merge(position: 'top bot')),
::Progress::Apply.new(opts.merge(position: 'top'))
]
sections.slice(:eligibility, :suitability, :reveal, :apply).values
end
end
end
2 changes: 1 addition & 1 deletion app/cells/v2_navbar/show.slim
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

- if model&.organisation
= link_to 'Dashboard', proposals_path, class: "#{type} ml35"
= link_to 'Pricing', account_subscription_path(model&.organisation), class: "#{type} ml35" unless model.organisation.subscribed?
= link_to 'Funds', funds_path, class: "#{type} ml35"
= link_to 'Sign out', logout_path, class: "#{type} ml35"
- else
= link_to 'About', about_path, class: "#{type} ml35"
Expand Down
7 changes: 6 additions & 1 deletion app/controllers/funds_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
class FundsController < ApplicationController
before_action :update_legacy_suitability, except: :sources
before_action :load_fund, only: %i[hidden show]
before_action :stub_assessment, only: %i[hidden show]

def show
authorize FundContext.new(@fund, @proposal)
Expand Down Expand Up @@ -56,7 +57,7 @@ def query
.funding_type(params[:type])
.revealed(params[:revealed])
.active
.select('funds.*', 'assessments.eligibility_status')
.select_view_columns
end

def themed_query
Expand All @@ -73,4 +74,8 @@ def load_stubs(funds)
@fund_stubs = Fund.stubs.includes(:funder).order('RANDOM()').limit(5) if
funds.empty?
end

def stub_assessment
@stub_assessment = OpenStruct.new(fund: @fund, proposal: @proposal)
end
end
2 changes: 1 addition & 1 deletion app/controllers/microsites_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def results
.order_by
.active
.where(funder: @funder)
.select('funds.*', 'assessments.eligibility_status')
.select_view_columns

# TODO: refactor
@assessments = Assessment.includes(:fund, :proposal, :recipient)
Expand Down
Loading

0 comments on commit 339d6c1

Please sign in to comment.