mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-03 23:00:14 -05:00
33 lines
896 B
JavaScript
33 lines
896 B
JavaScript
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';
|
|
import {invokeAction} from 'ember-invoke-action';
|
|
|
|
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();
|
|
|
|
if (!this.get('update')) {
|
|
throw new Error(`You must provide an \`update\` action to \`{{${this.templateName}}}\`.`);
|
|
}
|
|
|
|
this.set('datetime', formatDate(datetime));
|
|
},
|
|
|
|
focusOut() {
|
|
let datetime = this.get('datetime');
|
|
|
|
invokeAction(this, 'update', datetime);
|
|
}
|
|
});
|