Created
August 3, 2016 09:36
-
-
Save alcance/4eaf1bf77c31f41a1ddcf92517ad35c7 to your computer and use it in GitHub Desktop.
schedulerzored
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
import moment from 'moment'; | |
export default Ember.Component.extend({ | |
// ATTRIBUTES | |
month: null, | |
minDate: null, | |
maxDate: null, | |
showWeekdays: true, | |
selectDate: null, | |
// PROPERTIES | |
_minDate: null, | |
_maxDate: null, | |
classNames: ['date-picker__calendar__outer'], | |
selectedDates: [], | |
/** | |
* This takes the given month and converts it to the beginning of the Date object. | |
* If no month is given, it will default to the current month. | |
* | |
* @property currentMonth | |
*/ | |
currentMonth: Ember.computed('month', function() { | |
let date = Ember.get(this, 'month'); | |
return date ? date.clone().startOf('month') : moment().startOf('month'); | |
}), | |
/** | |
* The localized weekdays, starting with monday. | |
* | |
* @property weekdays | |
* @type {String[]} | |
* @readOnly | |
* @private | |
*/ | |
weekdays: Ember.computed(function() { | |
let weekdays = moment.weekdaysMin() | |
weekdays.push(weekdays.shift()); | |
return weekdays; | |
}), | |
/** | |
* The current day. | |
* | |
* @property today | |
* @type {Date} | |
* @readOnly | |
* @private | |
*/ | |
today: Ember.computed(function() { | |
return moment().startOf('day'); | |
}), | |
// HOOKS BEGIN | |
// didReceiveAttrs runs after init, and it also runs on subsequent re-renders | |
didReceiveAttrs() { | |
let minDate = Ember.get(this, 'minDate'); | |
let maxDate = Ember.get(this, 'maxDate'); | |
Ember.set(this, '_minDate', minDate ? minDate.clone().startOf('day') : null); | |
Ember.set(this, '_maxDate', maxDate ? maxDate.clone().startOf('day') : null); | |
}, | |
// METHODS | |
actions: { | |
selectDate(date) { | |
let action = Ember.get(this, 'attrs.selectedDate'); | |
if (action) { | |
action(date); | |
} | |
}, | |
setWeekDayTime(value) { | |
console.log(value); | |
} | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'Scheduler' | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.10.4", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "2.7.0", | |
"ember-data": "2.7.0", | |
"ember-template-compiler": "2.7.0" | |
}, | |
"addons": {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment