mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-27 18:52:14 +03:00
Changed ember models to use moment for dates
Closes #2888 -Added moment-date `DS.Transform` -`models/post` and `models/user` both use `DS.attr('moment-date')` in place of `date` now.
This commit is contained in:
parent
fd48a12b42
commit
fc28cddb8d
@ -12,11 +12,11 @@ var Post = DS.Model.extend({
|
||||
meta_title: DS.attr('string'),
|
||||
meta_description: DS.attr('string'),
|
||||
author: DS.belongsTo('user', { async: true }),
|
||||
created_at: DS.attr('date'),
|
||||
created_at: DS.attr('moment-date'),
|
||||
created_by: DS.belongsTo('user', { async: true }),
|
||||
updated_at: DS.attr('date'),
|
||||
updated_at: DS.attr('moment-date'),
|
||||
updated_by: DS.belongsTo('user', { async: true }),
|
||||
published_at: DS.attr('date'),
|
||||
published_at: DS.attr('moment-date'),
|
||||
published_by: DS.belongsTo('user', { async: true }),
|
||||
tags: DS.hasMany('tag', { async: true }),
|
||||
|
||||
|
@ -14,10 +14,10 @@ var User = DS.Model.extend({
|
||||
language: DS.attr('string'),
|
||||
meta_title: DS.attr('string'),
|
||||
meta_description: DS.attr('string'),
|
||||
last_login: DS.attr('date'),
|
||||
created_at: DS.attr('date'),
|
||||
last_login: DS.attr('moment-date'),
|
||||
created_at: DS.attr('moment-date'),
|
||||
created_by: DS.attr('number'),
|
||||
updated_at: DS.attr('date'),
|
||||
updated_at: DS.attr('moment-date'),
|
||||
updated_by: DS.attr('number'),
|
||||
|
||||
isSignedIn: Ember.computed.bool('id'),
|
||||
|
16
ghost/admin/transforms/moment-date.js
Normal file
16
ghost/admin/transforms/moment-date.js
Normal file
@ -0,0 +1,16 @@
|
||||
/* global moment */
|
||||
var MomentDate = DS.Transform.extend({
|
||||
deserialize: function (serialized) {
|
||||
if (serialized) {
|
||||
return moment(serialized);
|
||||
}
|
||||
return serialized;
|
||||
},
|
||||
serialize: function (deserialized) {
|
||||
if (deserialized) {
|
||||
return moment(deserialized).toDate();
|
||||
}
|
||||
return deserialized;
|
||||
}
|
||||
});
|
||||
export default MomentDate;
|
Loading…
Reference in New Issue
Block a user