mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-25 20:03:12 +03:00
PSM: Reset 'Published Date'
Closes #4557 - The underlying issue is that the PSM is already loaded when Ember routes from an existing post to a new post. Instead of resetting the ‘Published Date’ value manually (with jQuery), I’m using Ember’s computed property setter to ‘refresh’ the cache for that property. I believe that this Ember solution is better than manually going in and resetting it with jQuery.
This commit is contained in:
parent
1e7b892f79
commit
85677984d3
@ -74,15 +74,23 @@ var PostSettingsMenuController = Ember.ObjectController.extend({
|
|||||||
.create(deferred);
|
.create(deferred);
|
||||||
}),
|
}),
|
||||||
|
|
||||||
publishedAtValue: Ember.computed('published_at', function () {
|
/*jshint unused:false */
|
||||||
|
publishedAtValue: Ember.computed('published_at', function (key, value) {
|
||||||
var pubDate = this.get('published_at');
|
var pubDate = this.get('published_at');
|
||||||
|
|
||||||
|
// We're using a fake setter to reset
|
||||||
|
// the cache for this property
|
||||||
|
if (arguments.length > 1) {
|
||||||
|
return formatDate(moment());
|
||||||
|
}
|
||||||
|
|
||||||
if (pubDate) {
|
if (pubDate) {
|
||||||
return formatDate(pubDate);
|
return formatDate(pubDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
return formatDate(moment());
|
return formatDate(moment());
|
||||||
}),
|
}),
|
||||||
|
/*jshint unused:true */
|
||||||
|
|
||||||
slugValue: boundOneWay('slug'),
|
slugValue: boundOneWay('slug'),
|
||||||
|
|
||||||
@ -463,6 +471,10 @@ var PostSettingsMenuController = Ember.ObjectController.extend({
|
|||||||
if (uploader && uploader[0]) {
|
if (uploader && uploader[0]) {
|
||||||
uploader[0].uploaderUi.reset();
|
uploader[0].uploaderUi.reset();
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
resetPubDate: function () {
|
||||||
|
this.set('publishedAtValue', '');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -20,8 +20,9 @@ var EditorNewRoute = AuthenticatedRoute.extend(base, {
|
|||||||
// from previous posts
|
// from previous posts
|
||||||
psm.removeObserver('titleScratch', psm, 'titleObserver');
|
psm.removeObserver('titleScratch', psm, 'titleObserver');
|
||||||
|
|
||||||
// Ensure that the PSM Image Uploader resets
|
// Ensure that the PSM Image Uploader and Publish Date selector resets
|
||||||
psm.send('resetUploader');
|
psm.send('resetUploader');
|
||||||
|
psm.send('resetPubDate');
|
||||||
|
|
||||||
this._super(controller, model);
|
this._super(controller, model);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user