Skip to content
This repository has been archived by the owner on Mar 4, 2020. It is now read-only.

Commit

Permalink
Merge branch 'feature/data-download-page-rebased' of github.com:Vizzu…
Browse files Browse the repository at this point in the history
…ality/gfw-climate into feature/data-download-page-rebased
  • Loading branch information
simaob committed Oct 26, 2017
2 parents 2994264 + 3644fad commit 45468d9
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ define(
placeholder: 'Select a country'
},
{
id: 'indicator_ids',
id: 'widget_ids',
name: 'Indicators'
},
{
Expand All @@ -59,7 +59,7 @@ define(
placeholder: 'Select an indicator'
}
],
mandatorys: ['country_codes', 'indicator_ids'],
mandatorys: ['country_codes', 'widget_ids'],
validationMsg: 'Please select, at least, a country, an indicator and a year',
tresh: [10, 15, 20, 25, 30],
switchs: [
Expand Down Expand Up @@ -125,7 +125,7 @@ define(
case 'jurisdiction_ids':
filter.options = [];
break;
case 'indicator_ids':
case 'widget_ids':
filter.options = this.getIndicatorsOptions();
break;
case 'dataSource':
Expand Down Expand Up @@ -372,7 +372,7 @@ define(
case 'country_codes':
this.onCountryChange(selection);
break;
case 'indicator_ids':
case 'widget_ids':
this.onIndicatorsChange(selection);
break;
case 'dataSource':
Expand Down Expand Up @@ -472,15 +472,6 @@ define(
query += '&';
}
var value = view.selection.join(',');
if (view.filter.id === 'indicator_ids') {
var options = view.filter.options.filter(function(o) {
return view.selection.includes(o.value);
});
var indicators = options.map(function(i) {
return i.indicators;
});
value = _.flatten(indicators);
}
query += view.filter.id + '[]=' + value;
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ define(

renderOptions: function(options, placeholder) {
this.filter.options = options;
var selected = _.filter(options, function(option) {
return option.selected;
});
this.selection = _.map(selected, function(select) {
return select.value + '';
});
this.selectAllEl.prop('disabled', !options.length);
this.optionsContainer.html(
this.optionsTemplate({
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/v1/downloads_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def index

def download_params
params.permit(:iso, :id_1, :area, :start_year, :end_year,
units: [], indicator_ids: [], thresholds: [])
units: [], widget_ids: [], thresholds: [])
end
end
end
4 changes: 3 additions & 1 deletion app/models/download.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ def initialize options
@start_year = options[:start_year]
@end_year = options[:end_year]
@units = options[:units]
@indicator_ids = options[:indicator_ids]
@indicator_ids = options[:widget_ids].map do |widget_id|
Widget.find(widget_id).indicators.map{ |i| i["id"] }
end.flatten
@thresholds = options[:thresholds]
end

Expand Down
2 changes: 1 addition & 1 deletion app/models/widget.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ def data_url(collection, id, params)

url.to_s
end

end

0 comments on commit 45468d9

Please sign in to comment.