Skip to content

Instantly share code, notes, and snippets.

@feanor07
Last active December 6, 2018 07:24
Show Gist options
  • Save feanor07/84a4311290e71f8fba86d6cca77e3204 to your computer and use it in GitHub Desktop.
Save feanor07/84a4311290e71f8fba86d6cca77e3204 to your computer and use it in GitHub Desktop.
so53643322
import Days from 'ember-power-calendar/components/power-calendar/days'
export default Days.extend({
// eliminate monday and sunday from the weekdays already constructed ad power-calendar-days
weekdaysWithoutMondayAndSunday: Ember.computed('weekdays', function() {
return this.get('weekdays').slice(2,7)
})
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
actions: {
selectDate(value) {
this.set('fixedDummyDate', value)
}
}
});
import Ember from 'ember';
export function mondaySundayChecker(params/*, hash*/) {
console.log(params[0])
const day = Ember.get(params[0], 'moment').format('dddd')
return day !== 'Monday' && day !== 'Sunday';
}
export default Ember.Helper.helper(mondaySundayChecker);
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{#power-calendar
center=fixedDummyDate
selected=fixedDummyDate
onSelect=(action 'selectDate' value='date')
daysComponent="days-without-monday-sunday"
as |calendar|}}
{{calendar.days}}
{{/power-calendar}}
<div class="ember-power-calendar-row ember-power-calendar-weekdays">
{{#each weekdaysWithoutMondayAndSunday as |wdn|}}
<div class="ember-power-calendar-weekday">{{wdn}}</div>
{{/each}}
</div>
<div class="ember-power-calendar-day-grid" onkeydown={{action "onKeyDown" calendar}}>
{{#each weeks key='id' as |week|}}
<div class="ember-power-calendar-row ember-power-calendar-week" data-missing-days={{week.missingDays}}>
{{#each week.days key='id' as |day|}}
{{#if (monday-sunday-checker day)}}
<button type="button"
data-date="{{day.id}}"
class="ember-power-calendar-day {{if onSelect 'ember-power-calendar-day--interactive'}} {{if day.isCurrentMonth 'ember-power-calendar-day--current-month' 'ember-power-calendar-day--other-month'}} {{if day.isSelected 'ember-power-calendar-day--selected'}} {{if day.isToday 'ember-power-calendar-day--today'}} {{if day.isFocused 'ember-power-calendar-day--focused'}} {{if day.isRangeStart 'ember-power-calendar-day--range-start'}} {{if day.isRangeEnd 'ember-power-calendar-day--range-end'}}"
onclick={{action calendar.actions.select day calendar}}
onfocus={{action 'onFocusDay' day}}
onblur={{action 'onBlurDay'}}
disabled={{day.isDisabled}}>
{{#if hasBlock}}
{{yield day publicAPI}}
{{else}}
{{day.number}}
{{/if}}
</button>
{{/if}}
{{/each}}
</div>
{{/each}}
</div>
{
"version": "0.15.1",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js",
"ember": "3.4.3",
"ember-template-compiler": "3.4.3",
"ember-testing": "3.4.3"
},
"addons": {
"ember-data": "3.4.2",
"ember-power-calendar": "0.8.1",
"ember-moment": "7.7.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment