Skip to content

Commit

Permalink
Added the code
Browse files Browse the repository at this point in the history
  • Loading branch information
taras committed Mar 28, 2016
1 parent d2973f6 commit 019b85e
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 35 deletions.
10 changes: 10 additions & 0 deletions .vscodeignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
dist/**
tmp/**
build/**
cache/**
node_modules/**
bower_components/**
.sass-cache/**
connect.lock/**
coverage/*/**
libpeerconnection.log
33 changes: 0 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,33 +0,0 @@
[![Build Status](https://travis-ci.org/LocusEnergy/eui-calendar.svg?branch=master)](https://travis-ci.org/LocusEnergy/eui-calendar)

# Eui-calendar

This README outlines the details of collaborating on this Ember addon.

## Installation

* `git clone` this repository
* `npm install`
* `bower install`

## Running

* `ember server`
* Visit your app at http://localhost:4200.

## Running Tests

* `npm test` (Runs `ember try:testall` to test your addon against multiple Ember versions)
* `ember test`
* `ember test --server`

## Building

* `ember build`

For more information on using ember-cli, visit [http://www.ember-cli.com/](http://www.ember-cli.com/).


Questions / TODO:
- remove 'eui' prefix from the internal components?
- add warning if moment isn't defined in each selector? (for example: `return momentDecade(this.get('decade'), 'YYYY')` in year-selector)
40 changes: 40 additions & 0 deletions addon/components/eui-selectdate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import Ember from 'ember';
import layout from '../templates/components/eui-selectdate';
import Moment from 'moment';

const {
computed
} = Ember;

let EUISelectdateComponent = Ember.Component.extend({
layout,
tagName: 'eui-selectdate',
placeholder: 'Select a date',
didReceiveAttrs() {
this._super(...arguments);
this.set('_date', this.get('date') || Moment());
},
nextMonth: computed('_date', function(){
return this.get('_date').clone().add(1, 'month');
}),
actions: {
open() {
this.set('isOpen', true);
},
next(date) {
this.set('_date', date.clone().add(1, 'month'));
},
previous(date) {
this.set('_date', date.clone().subtract(1, 'month'));
},
select(date) {
this.sendAction('on-select', date);
}
}
});

EUISelectdateComponent.reopenClass({
positionalParams: ['date']
});

export default EUISelectdateComponent;
16 changes: 16 additions & 0 deletions addon/templates/components/eui-selectdate.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<button class="eui-selectdate--trigger" {{action 'open'}}>{{if date (moment-format date 'MMMM D') placeholder}}</button>

{{#if isOpen}}
<div class="eui-selectdate--window">
<button class="eui-selectdate--next" {{action 'next' _date}}>&gt;&gt;</button>
<button class="eui-selectdate--previous" {{action 'previous' _date}}>&lt;&lt;</button>
<div class="eui-selectdate--current-month">
<div class="eui-selectdate--current-month-name">{{moment-format _date 'MMMM YYYY'}}</div>
{{eui-day-selector _date on-select='select'}}
</div>
<div class="eui-selectdate--next-month">
<div class="eui-selectdate--next-month-name">{{moment-format nextMonth 'MMMM YYYY'}}</div>
{{eui-day-selector nextMonth on-select='select'}}
</div>
</div>
{{/if}}
1 change: 1 addition & 0 deletions app/components/eui-selectdate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from 'eui-calendar/components/eui-selectdate';
1 change: 1 addition & 0 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"compilerOptions":{"target":"es6","experimentalDecorators":true}}
2 changes: 2 additions & 0 deletions tests/dummy/app/templates/application.hbs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<h4>eui-calendar</h4>

{{eui-calendar}}

{{eui-selectdate}}
4 changes: 2 additions & 2 deletions tests/integration/eui-selectdate-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import DaySelector from 'eui-calendar/tests/page-objects/day-selector';

const FORMAT = 'MMMM YYYY';

moduleForComponent('eui-selectdate', 'Integration | Component | eui selectdate', {
moduleForComponent('eui-selectdate', 'Integration | Component | eui-selectdate', {
integration: true,
beforeEach() {
this.currentMonth = new DaySelector(this, '.eui-selectdate--current-month ');
Expand Down Expand Up @@ -115,7 +115,7 @@ test('it should render current and next month calendars', function (assert){
'', '', '', '', '', '', ''
], 'Days for January 2014 are shown in the calendar');

assert.deepEqual(this.nextMonth.days(), [
assert.deepEqual(this.nextMonth.days(), [
'', '', '', '', '', '', '1',
'2', '3', '4', '5', '6', '7', '8',
'9', '10', '11', '12', '13', '14', '15',
Expand Down

0 comments on commit 019b85e

Please sign in to comment.