mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-03 03:55:26 +03:00
7c2e923074
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
44 lines
1.2 KiB
JavaScript
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);
|
|
}
|
|
});
|