diff --git a/ghost/admin/app/components/posts-list/context-menu.hbs b/ghost/admin/app/components/posts-list/context-menu.hbs new file mode 100644 index 0000000000..2d3ba2b027 --- /dev/null +++ b/ghost/admin/app/components/posts-list/context-menu.hbs @@ -0,0 +1,42 @@ +
diff --git a/ghost/admin/app/components/posts-list/context-menu.js b/ghost/admin/app/components/posts-list/context-menu.js new file mode 100644 index 0000000000..260357a671 --- /dev/null +++ b/ghost/admin/app/components/posts-list/context-menu.js @@ -0,0 +1,72 @@ +import Component from '@glimmer/component'; +import {action} from '@ember/object'; +import {inject as service} from '@ember/service'; + +export default class PostsContextMenu extends Component { + @service ajax; + @service ghostPaths; + + get menu() { + return this.args.menu; + } + + get selectionList() { + return this.menu.selectionList; + } + + @action + deletePosts() { + // Use filter in menu.selectionList.filter + alert('Deleting posts not yet supported.'); + this.menu.close(); + } + + async performBulkEdit(_action, meta = {}) { + const filter = this.selectionList.filter; + let bulkUpdateUrl = this.ghostPaths.url.api(`posts/bulk`) + `?filter=${encodeURIComponent(filter)}`; + return await this.ajax.put(bulkUpdateUrl, { + data: { + bulk: { + action: _action, + meta + } + } + }); + } + + get shouldFeatureSelection() { + const firstPost = this.selectionList.availableModels[0]; + if (!firstPost) { + return true; + } + return !firstPost.featured; + } + + @action + async featurePosts() { + const updatedModels = this.selectionList.availableModels; + await this.performBulkEdit('feature'); + + // Update the models on the client side + for (const post of updatedModels) { + post.set('featured', true); + } + + // Close the menu + this.menu.close(); + } + + @action + async unfeaturePosts() { + const updatedModels = this.selectionList.availableModels; + await this.performBulkEdit('unfeature'); + + // Update the models on the client side + for (const post of updatedModels) { + post.set('featured', false); + } + + // Close the menu + this.menu.close(); + } +} diff --git a/ghost/admin/app/components/posts-list/list-item-old.hbs b/ghost/admin/app/components/posts-list/list-item-old.hbs new file mode 100644 index 0000000000..83533a2c53 --- /dev/null +++ b/ghost/admin/app/components/posts-list/list-item-old.hbs @@ -0,0 +1,200 @@ +{{!-- template-lint-disable no-invalid-interactive --}} ++ + Published + {{#if @post.hasEmail}} + {{#if this.isHovered}} + and sent to {{gh-pluralize @post.email.emailCount "member"}} + {{else}} + and sent + {{/if}} + {{/if}} + +
+ {{/unless}} + + {{else}} ++ {{#if @post.isScheduled}} + + + Scheduled + {{#if this.isHovered}} + + {{#if @post.emailOnly}} + to be sent + {{else}} + to be published {{if @post.newsletter "and sent "}} + {{/if}} + {{this.scheduledText}} to {{humanize-recipient-filter @post.emailSegment}} + + {{/if}} + + {{/if}} + + {{#if @post.isDraft}} + + + Draft + + {{/if}} + + {{#if @post.isPublished}} + + Published + {{#if @post.didEmailFail}} + but failed to send newsletter + {{else if @post.hasBeenEmailed}} + and sent + {{#if this.isHovered}} + to {{gh-pluralize @post.email.emailCount "member"}} + {{/if}} + {{/if}} + + {{/if}} + + {{#if @post.isSent}} + + {{#if @post.didEmailFail}} + Failed to send newsletter + {{else}} + Sent + {{#if this.isHovered}} + to {{gh-pluralize @post.email.emailCount "member"}} + {{/if}} + {{/if}} + + {{/if}} +
+ {{/unless}} +