Files
nairobi/app/helpers/legislation_helper.rb
Javi Martín fc9a87a8ab Use native HTML5 date fields in the admin section
We've had to add a couple of hacks in order to make jQuery UI datepicker
work with Turbolinks, and one of our tests is failing because the
datepicker changes its height when changing from a month with 5 weeks to
a month with 6 weeks.

We could add a workaround so the test still passes (jQuery UI doesn't
provide a configuration option to always displays 6 weeks in the
datepicker), but I think it's easier to just use the HTML5 native date
input field, which also allows us to simplify the code a bit and IMHO it
improves the user experience, particularly when using mobile phones.

Since date fields are not supported in Safari and Internet Explorer,
we're still using the jQuery UI datepicker on those browsers (and on any
other browser not supporting date fields).

Due to these changes, we're moving the tests checking datepicker's
behaviour to the dashboard. I've choosing not to change the public pages
because I'm not 100% sure everybody would like this change (some people
prefer the datepicker because we can configure the way it looks).
2020-08-28 12:55:58 +02:00

47 lines
1.2 KiB
Ruby

module LegislationHelper
def format_date(date)
l(date, format: "%d %b %Y") if date
end
def new_legislation_proposal_link_text(process)
t("proposals.index.start_proposal")
end
def legislation_process_tabs(process)
{
"info" => edit_admin_legislation_process_path(process),
"homepage" => edit_admin_legislation_process_homepage_path(process),
"questions" => admin_legislation_process_questions_path(process),
"proposals" => admin_legislation_process_proposals_path(process),
"draft_versions" => admin_legislation_process_draft_versions_path(process),
"milestones" => admin_legislation_process_milestones_path(process)
}
end
def banner_color?
@process.background_color.present? && @process.font_color.present?
end
def default_bg_color
"#e7f2fc"
end
def default_font_color
"#222222"
end
def bg_color_or_default
@process.background_color.presence || default_bg_color
end
def font_color_or_default
@process.font_color.presence || default_font_color
end
def css_for_process_header
if banner_color?
"background: #{@process.background_color};color: #{@process.font_color};"
end
end
end