Skip to content

Commit

Permalink
PSM: Reset 'Published Date'
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
felixrieseberg committed Dec 1, 2014
1 parent c06e649 commit 4bc5f91
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
14 changes: 13 additions & 1 deletion core/client/controllers/post-settings-menu.js
Expand Up @@ -74,15 +74,23 @@ var PostSettingsMenuController = Ember.ObjectController.extend({
.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');

// We're using a fake setter to reset
// the cache for this property
if (arguments.length > 1) {
return formatDate(moment());
}

if (pubDate) {
return formatDate(pubDate);
}

return formatDate(moment());
}),
/*jshint unused:true */

slugValue: boundOneWay('slug'),

Expand Down Expand Up @@ -463,6 +471,10 @@ var PostSettingsMenuController = Ember.ObjectController.extend({
if (uploader && uploader[0]) {
uploader[0].uploaderUi.reset();
}
},

resetPubDate: function () {
this.set('publishedAtValue', '');
}
}
});
Expand Down
3 changes: 2 additions & 1 deletion core/client/routes/editor/new.js
Expand Up @@ -20,8 +20,9 @@ var EditorNewRoute = AuthenticatedRoute.extend(base, {
// from previous posts
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('resetPubDate');

this._super(controller, model);
}
Expand Down

0 comments on commit 4bc5f91

Please sign in to comment.