Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce widget props #3388

Merged
merged 33 commits into from
Apr 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
903651f
prioritize other layers instead of tree cover
pjosh Apr 16, 2018
77eb18e
Initial commit
01painadam Apr 18, 2018
bb80165
initial commit
01painadam Apr 18, 2018
bd20b92
Tidies code to appease our es-lint overlords
01painadam Apr 19, 2018
ccc039b
Adds latest week functionality
01painadam Apr 19, 2018
30ef54f
Merge branch 'develop' of github.com:Vizzuality/gfw into feature/glad…
edbrett Apr 20, 2018
528309d
Updates .env and main glad widget
01painadam Apr 20, 2018
d607736
Merge branch 'feature/glad_summary_tables' of github.com:Vizzuality/g…
01painadam Apr 20, 2018
88012aa
Updates ranked-glads widget
01painadam Apr 20, 2018
db63ed5
Minor aesthetic changes to code
01painadam Apr 20, 2018
c423e59
rails site map generator
edbrett Apr 26, 2018
ae15299
add blog
edbrett Apr 26, 2018
bdacc98
add all countries routes
edbrett Apr 26, 2018
9e6a3bb
Merge pull request #3382 from Vizzuality/fix/sitemaps
pjosh Apr 26, 2018
a3122e7
Merge branch 'develop' of https://github.com/Vizzuality/gfw into fix/…
pjosh Apr 26, 2018
44c9e84
Merge pull request #3385 from Vizzuality/fix/forest-change-analysis
edbrett Apr 26, 2018
98337c7
remove es6 features in the old files
pjosh Apr 27, 2018
8c047af
Merge pull request #3387 from Vizzuality/fix/ie-vs-es6
edbrett Apr 27, 2018
d26e755
only fetch data when empty
edbrett Apr 27, 2018
c093d07
clear props
edbrett Apr 27, 2018
2d9d67a
update vunerability
edbrett Apr 27, 2018
169e297
Minor changes to services
01painadam Apr 27, 2018
3a48757
Merge branch 'feature/glad_summary_tables' of github.com:Vizzuality/g…
01painadam Apr 27, 2018
40c2fc3
remove errors in widgets
edbrett Apr 27, 2018
c8b9d09
fix table assignment
edbrett Apr 27, 2018
4d4529c
Merge pull request #3367 from Vizzuality/feature/glad_summary_tables
edbrett Apr 27, 2018
f64f4e6
Merge branch 'develop' of github.com:Vizzuality/gfw into reduce-widge…
edbrett Apr 27, 2018
515dfff
merge upstream
edbrett Apr 29, 2018
b3a01e7
remove errors from render
edbrett Apr 29, 2018
253270f
fix meta issues with selectors
edbrett Apr 30, 2018
9ac0c18
fix plantations
edbrett Apr 30, 2018
779f1e7
fix settings and map layers buttons
edbrett Apr 30, 2018
e6d4f06
fix map selection from widget
edbrett Apr 30, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ gem 'fog'
gem 'rmagick', :require => false
gem 'mini_magick'
gem 'unf'
gem 'sitemap_generator'

# requirejs
gem 'erubis'
Expand Down
11 changes: 7 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ GEM
sass-rails (< 5.1)
sprockets (< 4.0)
concurrent-ruby (1.0.5)
crass (1.0.3)
crass (1.0.4)
database_cleaner (1.6.2)
debug_inspector (0.0.3)
diff-lcs (1.3)
Expand Down Expand Up @@ -295,7 +295,7 @@ GEM
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
json (2.1.0)
loofah (2.2.1)
loofah (2.2.2)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.0)
Expand Down Expand Up @@ -347,8 +347,8 @@ GEM
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.0.3)
loofah (~> 2.0)
rails-html-sanitizer (1.0.4)
loofah (~> 2.2, >= 2.2.2)
rails_12factor (0.0.3)
rails_serve_static_assets
rails_stdout_logging
Expand Down Expand Up @@ -415,6 +415,8 @@ GEM
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.2)
sitemap_generator (6.0.1)
builder (~> 3.0)
spring (2.0.2)
activesupport (>= 4.2)
sprockets (3.7.1)
Expand Down Expand Up @@ -495,6 +497,7 @@ DEPENDENCIES
shoulda-matchers
show_me_the_cookies
simplecov
sitemap_generator
spring
sprockets-rails (= 2.3.3)
typhoeus
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
86 changes: 43 additions & 43 deletions app/assets/javascripts/abstract/timeline/TimelineDatePicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ define(
'text!templates/datePickerTorque.handlebars',
'text!templates/datePickerTorque-legend.handlebars'
],
(
function(
_,
Backbone,
moment,
Expand All @@ -25,14 +25,14 @@ define(
Presenter,
tpl,
legendTpl
) => {
const SelectedDates = Backbone.Model.extend({
getRange() {
) {
var SelectedDates = Backbone.Model.extend({
getRange: function() {
return [this.get('startDate'), this.get('endDate')];
},

setDate(id, date) {
let otherDate;
setDate: function(id, date) {
var otherDate;
if (id === 'startDate') {
otherDate = this.get('endDate');
if (date.isAfter(otherDate)) {
Expand All @@ -46,7 +46,7 @@ define(
}

if (date.toDate().getHours() !== 0) {
const tzOffset = date.toDate().getTimezoneOffset();
var tzOffset = date.toDate().getTimezoneOffset();
if (tzOffset > 0) {
date = date.add(tzOffset, 'minutes');
}
Expand All @@ -55,13 +55,13 @@ define(
}
});

const TorqueTimelineDatePicker = Backbone.View.extend({
var TorqueTimelineDatePicker = Backbone.View.extend({
className: 'timeline-date-pickers',

template: Handlebars.compile(tpl),
legendTemplate: Handlebars.compile(legendTpl),

initialize(options) {
initialize: function(options) {
options = options || {};
this.presenter = options.presenter;
this.dataService = options.dataService;
Expand All @@ -82,7 +82,7 @@ define(
this.retrieveAvailableDates();
},

render() {
render: function() {
this.$el.html(
this.template({
title: this.layer.title,
Expand All @@ -95,25 +95,25 @@ define(
return this;
},

renderPickers() {
const context = this;
const onPickerRender = function () {
const pickerContext = this;
renderPickers: function() {
var context = this;
var onPickerRender = function () {
var pickerContext = this;

this.$root.find('.picker__day').each(function () {
const $el = $(this);
const date = moment($el.data('pick'));
const day = date.dayOfYear();
var $el = $(this);
var date = moment($el.data('pick'));
var day = date.dayOfYear();

const histogram =
var histogram =
context.histograms && context.histograms[date.year()];
if (histogram) {
if (histogram[day - 1] > 0) {
// Disabled dates to prevent inverted selected dates
// e.g. picking 6/09 for start, and 4/09 for end
const id = pickerContext.component.$node.attr('id');
const endDate = context.selectedDates.get('endDate');
const startDate = context.selectedDates.get('startDate');
var id = pickerContext.component.$node.attr('id');
var endDate = context.selectedDates.get('endDate');
var startDate = context.selectedDates.get('startDate');

if (context.layer.slug !== 'umd_as_it_happens') {
if (id === 'startDate') {
Expand All @@ -130,22 +130,22 @@ define(
}
});

const $footer = this.$root.find('.picker__footer');
var $footer = this.$root.find('.picker__footer');
if (context.layer.slug !== 'umd_as_it_happens') {
$footer.prepend(context.legendTemplate());
}
};

const onPickerOpen = function () {
var onPickerOpen = function () {
this.component.disabled = function (dateToVerify) {
const date = moment.utc(dateToVerify.obj);
const id = this.component.$node.attr('id');
var date = moment.utc(dateToVerify.obj);
var id = this.component.$node.attr('id');

if (id === 'startDate') {
const endDate = context.selectedDates.get('endDate');
var endDate = context.selectedDates.get('endDate');
return date.isAfter(endDate);
} else if (id === 'endDate') {
const startDate = context.selectedDates.get('startDate');
var startDate = context.selectedDates.get('startDate');
return date.isBefore(startDate);
}

Expand All @@ -155,13 +155,13 @@ define(
this.render();
};

const tzOffset = new Date().getTimezoneOffset();
const minDate = moment
var tzOffset = new Date().getTimezoneOffset();
var minDate = moment
.utc(this.layer.mindate)
.add(tzOffset, 'minutes')
.toDate();

const maxDate = this.maxDate
var maxDate = this.maxDate
? this.maxDate.toDate()
: moment
.utc()
Expand All @@ -181,36 +181,36 @@ define(
klass: {
picker: 'picker -top'
},
onSet(event) {
onSet: function(event) {
if (event.select !== undefined) {
const id = this.component.$node.attr('id');
let timezone = new Date().getTimezoneOffset() * 60 * 1000,
var id = this.component.$node.attr('id');
var timezone = new Date().getTimezoneOffset() * 60 * 1000,
offsetDate = event.select - timezone;
context.selectedDates.setDate(id, moment.utc(offsetDate));
}
}
});
},

updateTorque() {
const dateRange = this.selectedDates.getRange();
updateTorque: function() {
var dateRange = this.selectedDates.getRange();
this.onChange(dateRange);
this.presenter.setTorqueDateRange(dateRange);
},

setMinMaxDate(data) {
const tzOffset = new Date().getTimezoneOffset() + 60;
setMinMaxDate: function(data) {
var tzOffset = new Date().getTimezoneOffset() + 60;
if (this.layer.slug === 'umd_as_it_happens') {
this.minDate = moment.utc(data.minDate);
} else {
this.minDate = moment.utc(data.minDate).endOf('day');
}
this.maxDate = moment.utc(data.maxDate);
const minDate = this.minDate
var minDate = this.minDate
.clone()
.add(tzOffset, 'minutes')
.toDate();
const maxDate = this.maxDate
var maxDate = this.maxDate
.clone()
.add(tzOffset, 'minutes')
.toDate();
Expand All @@ -222,15 +222,15 @@ define(
.set('max', maxDate);
},

retrieveAvailableDates() {
const dateService = new this.dataService();
retrieveAvailableDates: function() {
var dateService = new this.dataService();
this.histograms = [];

dateService.fetchDates().then(response => {
dateService.fetchDates().then(function(response){
this.histograms = response.counts;
this.renderPickers();
this.setMinMaxDate(response);
});
}.bind(this));
}
});

Expand Down
Loading