import Ember from 'ember';

export default Ember.Component.extend({
  classNameBindings: [':as-calendar-header'],
  tagName: 'header',

  isInCurrentWeek: Ember.computed.oneWay('model.isInCurrentWeek'),
  model: null,
  title: '',

  actions: {
    navigateWeek: function(index) {
      this.get('model').navigateWeek(index);

      if (this.attrs['onNavigateWeek']) {
        this.attrs['onNavigateWeek'](index);
      }
    },

    goToCurrentWeek: function() {
      this.get('model').goToCurrentWeek();
    }
  }
});

import Ember from 'ember';

export default Ember.Component.extend({
  classNameBindings: [':as-calendar-header'],
  tagName: 'header',

  isInCurrentWeek: Ember.computed.oneWay('model.isInCurrentWeek'),
  model: null,
  title: '',

  actions: {
    navigateWeek: function(index) {
      this.get('model').navigateWeek(index);

      if (this.attrs['onNavigateWeek']) {
        this.attrs['onNavigateWeek'](index);
      }
    },

    goToCurrentWeek: function() {
      this.get('model').goToCurrentWeek();
      
      if (this.attrs['onNavigateWeek']) {
        this.attrs['onNavigateWeek'](0);
      }
    }
  }
});

Make 'This week' button trigger onNavigateWeek with index 0
Make 'This week' button trigger onNavigateWeek with index 0

The onNavigateWeek action can be used to monitor what dates are showing
on the calendar external to the component. Previously however the
calendar did not expose an event that triggers when the ‘This week’
button is clicked.
