Skip to content

Commit

Permalink
[#168] update the charts filter after add/remove trackable
Browse files Browse the repository at this point in the history
[#168] workaround the bug when no data shown for some charts on initial render
[#168] flatten the promises structure since they were designed to be used so
  • Loading branch information
mpugach committed Feb 2, 2017
1 parent 20f4061 commit f9a9666
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 15 deletions.
32 changes: 20 additions & 12 deletions frontend/app/components/checkin/trackables-step.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,19 +154,27 @@ export default Ember.Component.extend(TrackablesFromType, {
},

saveCheckin() {
this.get('checkin').set('hasDirtyAttributes', true);
this.set('checkin.hasDirtyAttributes', true);

Ember.run.next(this, function() {
Ember.RSVP.all([
this.untrackRemovedTracked(),
this.trackAddedTracked()
]).then(() => {
this.get('checkin').save().then(() => {
Ember.Logger.info('Checkin successfully saved');
this.onCheckinSaved();
}, (error) => {
this.get('checkin').handleSaveError(error);
});
});
Ember
.RSVP
.all([
this.untrackRemovedTracked(),
this.trackAddedTracked()
])
.then(() => this.get('checkin').save())
.then(
() => {
Ember.Logger.info('Checkin successfully saved');

return this.onCheckinSaved();
},
(error) => {
this.get('checkin').handleSaveError(error);
}
)
.then(() => this.get('chartsVisibilityService').refresh());
});
},

Expand Down
14 changes: 11 additions & 3 deletions frontend/app/components/health-chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,17 @@ export default Component.extend(Resizable, FieldsByUnits, {
timelineLength: alias('timeline.length'),
visibilityFilter: alias('chartsVisibilityService.visibilityFilter'),

updateTrackables: observer('centeredDate', function() {
debounce(this, this.fetchDataChart, 1000);
}),
updateTrackables: observer(
'centeredDate',
'chartLoaded',
'chartsVisibilityService.payload.symptoms.@each.visible',
'chartsVisibilityService.payload.conditions.@each.visible',
'chartsVisibilityService.payload.treatments.@each.visible',
'chartsVisibilityService.payload.weathersMesures.@each.visible',
function() {
debounce(this, this.fetchDataChart, 1000);
}
),

daysRadius: computed('SVGWidth', function() {
return Math.ceil(get(this, 'SVGWidth') / (get(this, 'pixelsPerDate') * 2));
Expand Down
1 change: 1 addition & 0 deletions frontend/app/instance-initializers/charts-visibility.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ export default {
application.inject('component:health-chart', 'chartsVisibilityService', 'service:charts-visibility');
application.inject('component:chart-navigation', 'chartsVisibilityService', 'service:charts-visibility');
application.inject('component:charts-filter-form', 'chartsVisibilityService', 'service:charts-visibility');
application.inject('component:checkin/trackables-step', 'chartsVisibilityService', 'service:charts-visibility');
}
};

0 comments on commit f9a9666

Please sign in to comment.