Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
* develop: (43 commits)
  Hide sectoral for now
  Fix ie 11 crashes
  Avoid crashing when there's no label to match value
  Update NDC import process and controller
  Update frontend selectors
  Update import process and ndcs controller
  Add parent category to category model, db and import process
  Update browser list to match internet explorer
  Remove code added by rebase
  Fix frontend by adding integer conversion
  Fix import process
  Add integer conversion
  Change indicator slug creation
  Update main db import task
  Add up to date schema.rb
  Add test case for category import
  Make rubocop happy
  Update indc endpoint and serializers
  Add new indc import process
  Fix migrations, schema, models and specs
  ...
  • Loading branch information
j8seangel committed Nov 3, 2017
2 parents bc47b10 + 1b278d9 commit 2c3b247
Show file tree
Hide file tree
Showing 151 changed files with 1,646 additions and 1,867 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/favicons/android-icon-48x48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/favicons/android-icon-72x72.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/favicons/android-icon-96x96.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/favicons/apple-icon-114x114.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/favicons/apple-icon-120x120.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/favicons/apple-icon-144x144.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/favicons/apple-icon-152x152.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/favicons/apple-icon-180x180.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/favicons/apple-icon-57x57.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/favicons/apple-icon-60x60.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/favicons/apple-icon-72x72.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/favicons/apple-icon-76x76.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/favicons/apple-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions app/assets/images/favicons/browserconfig.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<browserconfig><msapplication><tile><square70x70logo src="/ms-icon-70x70.png"/><square150x150logo src="/ms-icon-150x150.png"/><square310x310logo src="/ms-icon-310x310.png"/><TileColor>#ffffff</TileColor></tile></msapplication></browserconfig>
Binary file added app/assets/images/favicons/favicon-16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/favicons/favicon-32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/favicons/favicon-96x96.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/favicons/favicon.ico
Binary file not shown.
41 changes: 41 additions & 0 deletions app/assets/images/favicons/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"name": "App",
"icons": [
{
"src": "\/android-icon-36x36.png",
"sizes": "36x36",
"type": "image\/png",
"density": "0.75"
},
{
"src": "\/android-icon-48x48.png",
"sizes": "48x48",
"type": "image\/png",
"density": "1.0"
},
{
"src": "\/android-icon-72x72.png",
"sizes": "72x72",
"type": "image\/png",
"density": "1.5"
},
{
"src": "\/android-icon-96x96.png",
"sizes": "96x96",
"type": "image\/png",
"density": "2.0"
},
{
"src": "\/android-icon-144x144.png",
"sizes": "144x144",
"type": "image\/png",
"density": "3.0"
},
{
"src": "\/android-icon-192x192.png",
"sizes": "192x192",
"type": "image\/png",
"density": "4.0"
}
]
}
Binary file added app/assets/images/favicons/ms-icon-144x144.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/favicons/ms-icon-150x150.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/favicons/ms-icon-310x310.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/favicons/ms-icon-70x70.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
81 changes: 34 additions & 47 deletions app/controllers/api/v1/ndcs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,43 @@ module V1

class NdcsController < ApiController
def index
categories = ::Indc::Category.all
sectors = ::Indc::Sector.all
sectors = ::Indc::Sector.
all

categories = ::Indc::Category.
includes(:category_type)

if params[:filter]
categories = categories.where(
category_type: params[:filter]
indc_category_types: { name: params[:filter] },
)
end

if params[:category]
parent = ::Indc::Category.
includes(:category_type).
where(
indc_category_types: { name: 'global' },
slug: params[:category]
)

categories = categories
.where(
parent_id: parent.map(&:id)
)
end


indicators = ::Indc::Indicator.
includes(
:labels, :source, :categories,
values: [:sector, :label, :location]
).
where(id: categories.flat_map(&:indicator_ids).uniq)

if location_list
indicators = indicators.where(
values: {locations: {iso_code3: location_list}}
)
end

Expand Down Expand Up @@ -62,50 +93,6 @@ def content_overview

private

def indicators
indicators = ::Indc::Indicator.includes(
:labels,
:categories,
values: [:location]
)

if location_list
indicators = indicators.where(
values: {locations: {iso_code3: location_list}}
)
end

if params[:filter]
indicators = indicators.where(
indc_categories: {category_type: params[:filter]}
)
end

if params[:category]
indicator_ids = ::GlobalIndc::Category.
includes(:indicators, children: :indicators).
where(
parent_id: nil,
slug: params[:category]
).
flat_map(&:children).
flat_map(&:indicators).
map do |indicator|
if indicator.wb_indicator_id
"wb#{indicator.wb_indicator_id}"
elsif indicator.cait_indicator_id
"cait#{indicator.cait_indicator_id}"
end
end

indicators = indicators.where(
id: indicator_ids
)
end

indicators
end

def location_list
if params[:location].blank?
nil
Expand Down
116 changes: 48 additions & 68 deletions app/javascript/app/components/accordion/accordion-component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,95 +14,75 @@ class Accordion extends PureComponent {
className,
data,
handleOnClick,
activeSection,
compare
openSlug,
children,
isChild
} = this.props;
return (
<div className={className}>
{data.map((section, index) => {
let isOpen = index === 0;
if (activeSection) {
if (activeSection !== 'none') {
const isActiveInResults = data.some(
d => d.slug === activeSection
);
isOpen =
activeSection === section.slug ||
(index === 0 && !isActiveInResults);
} else {
isOpen = false;
{data &&
data.length > 0 &&
data.map((section, index) => {
let isOpen = index === 0;
if (openSlug) {
if (openSlug !== 'none') {
const isActiveInResults = data.some(d => d.slug === openSlug);
isOpen =
openSlug === section.slug ||
(index === 0 && !isActiveInResults);
} else {
isOpen = false;
}
}
}
return section.definitions.length ? (
<section key={section.slug} className={styles.accordion}>
<button
className={styles.header}
onClick={() => handleOnClick(section.slug)}
return (
<section
key={`${section.slug}-${section.title}`}
className={styles.accordion}
>
<div className={layout.content}>
<div className={styles.title}>
{section.title}
<Icon
icon={dropdownArrow}
className={cx(styles.iconArrow, {
[styles.isOpen]: isOpen
})}
/>
</div>
</div>
</button>
<Collapse isOpened={isOpen}>
<div className={styles.accordionContent}>
<button
className={cx(styles.header, isChild ? styles.subHeader : '')}
onClick={() => handleOnClick(section.slug)}
>
<div className={layout.content}>
<dl className={styles.definitionList}>
{section.definitions.map(def => (
<div
key={`${def.slug}-${section.slug}`}
className={cx(
compare
? styles.definitionCompare
: styles.definition
)}
>
<dt className={styles.definitionTitle}>
{def.title}
</dt>
{def.descriptions.map(desc => (
<dd
key={`${def.slug}-${desc.iso}`}
className={styles.definitionDesc}
>
<div
dangerouslySetInnerHTML={{ __html: desc.value }} // eslint-disable-line
/>
</dd>
))}
</div>
))}
</dl>
<div className={styles.title}>
{section.title}
<Icon
icon={dropdownArrow}
className={cx(styles.iconArrow, {
[styles.isOpen]: isOpen
})}
/>
</div>
</div>
</div>
</Collapse>
</section>
) : null;
})}
</button>
<Collapse isOpened={isOpen}>
<div />
{React.Children.map(children, (child, i) => {
if (i === index) return child;
return null;
})}
</Collapse>
</section>
);
})}
</div>
);
}
}

Accordion.propTypes = {
className: PropTypes.string,
activeSection: PropTypes.string,
openSlug: PropTypes.string,
handleOnClick: PropTypes.func,
data: PropTypes.arrayOf(
PropTypes.shape({
title: PropTypes.string,
slug: PropTypes.string,
definitions: PropTypes.array.isRequired
definitions: PropTypes.array
})
),
compare: PropTypes.bool
children: PropTypes.node,
isChild: PropTypes.bool
};

Accordion.defaultProps = {
Expand Down
64 changes: 11 additions & 53 deletions app/javascript/app/components/accordion/accordion-styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,17 @@
}
}

.subHeader {
background-color: rgba($light-gray, 0.5);
padding-top: 10px;
padding-bottom: 10px;
font-size: $font-size-m;

.title {
padding-left: 15px;
}
}

.iconArrow {
transition: transform 0.25s ease-in-out;
position: absolute;
Expand All @@ -37,56 +48,3 @@
}
}

.accordionContent {
background-color: $light-gray;
border-bottom: solid 1px rgba($theme-color, 0.3);
}

.definitionCompare {
@extend %grid;

@include msGridColumns(1fr, 1fr, 1fr, 1fr);

grid-template-columns: repeat(4, 1fr);
padding: 30px 0;
border-bottom: solid 1px rgba(#9090b2, 0.15);

&:last-child {
border-bottom: 0;
}
}

.definition {
@extend %grid;

@include msGridColumns(1fr, 3fr);

grid-template-columns: 1fr 3fr;
padding: 20px 0;
border-bottom: solid 1px rgba(#9090b2, 0.15);

&:last-child {
border-bottom: 0;
}
}

.definitionTitle {
margin-right: 40px;
color: $theme-color;
font-weight: $font-weight-bold;
font-family: $font-family-1;
}

.definitionDesc {
color: $theme-color;
font-family: $font-family-1;
line-height: 1.4em;
}

.loader {
min-height: 400px;
position: absolute;
top: 0;
left: 0;
right: 0;
}
Loading

0 comments on commit 2c3b247

Please sign in to comment.