Ghost/ghost/admin/app/components/gh-datetime-input.js
Kevin Ansfield 7c2e923074 Rename "offset" to "blogTimezone"
refs https://github.com/TryGhost/Ghost/pull/6941#issuecomment-224553575
- `blogTimezone` and `timezone` better reflect their values (a string representing a timezone in the format `Europe/Dublin`) than `offset` which suggests a fixed value
2016-06-08 12:09:19 +01:00

44 lines
1.2 KiB
JavaScript

import Ember from 'ember';
import TextInputMixin from 'ghost-admin/mixins/text-input';
import boundOneWay from 'ghost-admin/utils/bound-one-way';
import {formatDate} from 'ghost-admin/utils/date-formatting';
import {invokeAction} from 'ember-invoke-action';
const {
Component,
RSVP,
inject: {service}
} = Ember;
export default Component.extend(TextInputMixin, {
tagName: 'span',
classNames: 'input-icon icon-calendar',
datetime: boundOneWay('value'),
inputClass: null,
inputId: null,
inputName: null,
timeZone: service(),
didReceiveAttrs() {
let promises = {
datetime: RSVP.resolve(this.get('datetime') || moment.utc()),
blogTimezone: RSVP.resolve(this.get('timeZone.blogTimezone'))
};
if (!this.get('update')) {
throw new Error(`You must provide an \`update\` action to \`{{${this.templateName}}}\`.`);
}
RSVP.hash(promises).then((hash) => {
this.set('datetime', formatDate(hash.datetime || moment.utc(), hash.blogTimezone));
});
},
focusOut() {
let datetime = this.get('datetime');
invokeAction(this, 'update', datetime);
}
});