2015-12-08 12:58:32 +03:00
|
|
|
import Ember from 'ember';
|
|
|
|
import TextInputMixin from 'ghost/mixins/text-input';
|
|
|
|
import boundOneWay from 'ghost/utils/bound-one-way';
|
|
|
|
import {formatDate} from 'ghost/utils/date-formatting';
|
|
|
|
|
|
|
|
const {Component} = Ember;
|
|
|
|
|
|
|
|
export default Component.extend(TextInputMixin, {
|
|
|
|
tagName: 'span',
|
|
|
|
classNames: 'input-icon icon-calendar',
|
|
|
|
|
|
|
|
datetime: boundOneWay('value'),
|
|
|
|
inputClass: null,
|
|
|
|
inputId: null,
|
|
|
|
inputName: null,
|
|
|
|
|
|
|
|
didReceiveAttrs() {
|
|
|
|
let datetime = this.get('datetime') || moment();
|
|
|
|
|
2016-04-06 18:26:58 +03:00
|
|
|
if (!this.get('update')) {
|
2015-12-08 12:58:32 +03:00
|
|
|
throw new Error(`You must provide an \`update\` action to \`{{${this.templateName}}}\`.`);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.set('datetime', formatDate(datetime));
|
|
|
|
},
|
|
|
|
|
|
|
|
focusOut() {
|
|
|
|
let datetime = this.get('datetime');
|
|
|
|
|
2016-04-06 18:26:58 +03:00
|
|
|
this.get('update')(datetime);
|
2015-12-08 12:58:32 +03:00
|
|
|
}
|
|
|
|
});
|