mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-18 16:01:40 +03:00
a5d3101ec9
refs TryGhost/Team#2401 - Previously, if you opened a new post using the plus button on the sidebar while on a different post's analytics page, the breadcrumbs would point back to Analytics instead of the Posts list view. Going back to Analytics brought you back to the analytics page for the post you just created, which wasn't populating since it likely hadn't been published yet. - This commit fixes the issue by setting fromAnalytics = false if transitioning to a new Post, even if the previous route was the analytics page.
78 lines
2.1 KiB
JavaScript
78 lines
2.1 KiB
JavaScript
import $ from 'jquery';
|
|
import AuthenticatedRoute from 'ghost-admin/routes/authenticated';
|
|
import {run} from '@ember/runloop';
|
|
import {inject as service} from '@ember/service';
|
|
|
|
export default AuthenticatedRoute.extend({
|
|
feature: service(),
|
|
notifications: service(),
|
|
ui: service(),
|
|
|
|
classNames: ['editor'],
|
|
|
|
activate() {
|
|
this._super(...arguments);
|
|
this.ui.set('isFullScreen', true);
|
|
},
|
|
|
|
setupController(controller, model, transition) {
|
|
if (transition.from?.name === 'posts.analytics' && transition.to?.name !== 'editor.new') {
|
|
controller.fromAnalytics = true;
|
|
}
|
|
},
|
|
|
|
resetController(controller) {
|
|
controller.fromAnalytics = false;
|
|
},
|
|
|
|
deactivate() {
|
|
this._super(...arguments);
|
|
this.ui.set('isFullScreen', false);
|
|
},
|
|
|
|
actions: {
|
|
save() {
|
|
this._blurAndScheduleAction(function () {
|
|
this.controller.send('save');
|
|
});
|
|
},
|
|
|
|
authorizationFailed() {
|
|
// noop - re-auth is handled by controller save
|
|
return;
|
|
},
|
|
|
|
willTransition(transition) {
|
|
// exit early if an upgrade is required because our extended route
|
|
// class will abort the transition and show an error
|
|
if (this.get('upgradeStatus.isRequired')) {
|
|
return this._super(...arguments);
|
|
}
|
|
|
|
this.controller.willTransition(transition);
|
|
}
|
|
},
|
|
|
|
buildRouteInfoMetadata() {
|
|
return {
|
|
titleToken: () => {
|
|
return this.get('controller.post.title') || 'Editor';
|
|
},
|
|
bodyClasses: ['gh-body-fullscreen'],
|
|
mainClasses: ['gh-main-white']
|
|
};
|
|
},
|
|
|
|
_blurAndScheduleAction(func) {
|
|
let selectedElement = $(document.activeElement);
|
|
|
|
// TODO: we should trigger a blur for textareas as well as text inputs
|
|
if (selectedElement.is('input[type="text"]')) {
|
|
selectedElement.trigger('focusout');
|
|
}
|
|
|
|
// wait for actions triggered by the focusout to finish before saving
|
|
run.scheduleOnce('actions', this, func);
|
|
}
|
|
});
|