Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

🔥 remove content screen keyboard shortcuts #775

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions app/controllers/posts.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ export default Controller.extend({
_hasLoadedTags: false,
_hasLoadedAuthors: false,

showDeletePostModal: false,

availableTypes: [{
name: 'All posts',
value: null
Expand Down Expand Up @@ -101,10 +99,6 @@ export default Controller.extend({
}),

actions: {
toggleDeletePostModal() {
this.toggleProperty('showDeletePostModal');
},

changeType(type) {
this.set('type', get(type, 'value'));
},
Expand Down
75 changes: 1 addition & 74 deletions app/routes/posts.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import $ from 'jquery';
import AuthenticatedRoute from 'ghost-admin/routes/authenticated';
import InfinityRoute from 'ember-infinity/mixins/route';
import ShortcutsRoute from 'ghost-admin/mixins/shortcuts-route';
import {assign} from 'ember-platform';
import {isBlank} from 'ember-utils';

export default AuthenticatedRoute.extend(InfinityRoute, ShortcutsRoute, {
export default AuthenticatedRoute.extend(InfinityRoute, {
titleToken: 'Content',

perPage: 30,
Expand All @@ -32,7 +31,6 @@ export default AuthenticatedRoute.extend(InfinityRoute, ShortcutsRoute, {
},

_type: null,
_selectedPostIndex: null,

model(params) {
return this.get('session.user').then((user) => {
Expand Down Expand Up @@ -121,50 +119,8 @@ export default AuthenticatedRoute.extend(InfinityRoute, ShortcutsRoute, {
});
},

stepThroughPosts(step) {
let currentPost = this.get('controller.selectedPost');
let posts = this.get('controller.model');
let length = posts.get('length');
let newPosition;

// when the currentPost is deleted we won't be able to use indexOf.
// we keep track of the index locally so we can select next after deletion
if (this._selectedPostIndex !== null && length) {
newPosition = this._selectedPostIndex + step;
} else {
newPosition = posts.indexOf(currentPost) + step;
}

// if we are on the first or last item
// just do nothing (desired behavior is to not
// loop around)
if (newPosition >= length) {
return;
} else if (newPosition < 0) {
return;
}

this._selectedPostIndex = newPosition;
this.set('controller.selectedPost', posts.objectAt(newPosition));
},

shortcuts: {
'up, k': 'moveUp',
'down, j': 'moveDown',
'enter': 'editPost',
'c': 'newPost',
'command+backspace, ctrl+backspace': 'deletePost'
},

resetController() {
this.set('controller.selectedPost', null);
this.set('controller.showDeletePostModal', false);
},

actions: {
willTransition() {
this._selectedPostIndex = null;

if (this.get('controller')) {
this.resetController();
}
Expand All @@ -175,35 +131,6 @@ export default AuthenticatedRoute.extend(InfinityRoute, ShortcutsRoute, {
$('.content-list').scrollTop(0);

this._super(...arguments);
},

newPost() {
this.transitionTo('editor.new');
},

moveUp() {
this.stepThroughPosts(-1);
},

moveDown() {
this.stepThroughPosts(1);
},

editPost() {
let selectedPost = this.get('controller.selectedPost');

if (selectedPost) {
this.transitionTo('editor.edit', selectedPost.get('id'));
}
},

deletePost() {
this.get('controller').send('toggleDeletePostModal');
},

onPostDeletion() {
// select next post (re-select the current index)
this.stepThroughPosts(0);
}
}
});
11 changes: 0 additions & 11 deletions app/templates/posts.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@
{{#each model as |post|}}
{{gh-posts-list-item
post=post
active=(eq post selectedPost)
onDoubleClick="openEditor"
data-test-post-id=post.id}}
{{else}}
Expand All @@ -110,15 +109,5 @@
triggerOffset=1000}}
</section>

{{#if showDeletePostModal}}
{{gh-fullscreen-modal "delete-post"
model=(hash
post=selectedPost
onSuccess=(route-action 'onPostDeletion')
)
close=(action "toggleDeletePostModal")
modifier="action wide"}}
{{/if}}

{{outlet}}
</section>