Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
When having `startFromDate` and `startingDate` set, clicking on 'THIS WEEK' button should keep the same first weekday
  • Loading branch information
rafaelbnp committed Jul 14, 2017
1 parent 3ec0cd1 commit 2c4b64e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
12 changes: 10 additions & 2 deletions addon/models/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default Ember.Object.extend({
occurrencePreview: null,

isInCurrentWeek: Ember.computed('week', '_currentWeek', function() {
return this.get('week').isSame(this.get('_currentWeek'));
return this.get('week').isSame(this.get('_currentWeek'), 'week');
}),

timeSlots: Ember.computed(
Expand Down Expand Up @@ -71,6 +71,14 @@ export default Ember.Object.extend({
},

goToCurrentWeek: function() {
this.set('startingTime', moment());
const startingDate = this.get('startingDate');
const startFromDate = this.get('startFromDate');
let startingTime = moment();

if (startFromDate && startingDate) {
startingTime = moment().day(startingDate.day());
}

this.set('startingTime', startingTime);
}
});
3 changes: 2 additions & 1 deletion addon/models/component-calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ export default Calendar.extend({
component: null,
timeZone: Ember.computed.oneWay('component.timeZone'),
startFromDate: Ember.computed.readOnly('component.startFromDate'),
startingTime: computedMoment('component.startingDate'),
startingDate: computedMoment('component.startingDate'),
startingTime: Ember.computed.reads('startingDate'),
dayStartingTime: computedDuration('component.dayStartingTime'),
dayEndingTime: computedDuration('component.dayEndingTime'),
timeSlotDuration: computedDuration('component.timeSlotDuration'),
Expand Down

0 comments on commit 2c4b64e

Please sign in to comment.