1
0
Fork 0
mirror of https://github.com/TryGhost/Ghost-Admin.git synced 2023-12-14 02:33:04 +01:00
Ghost-Admin/app/components/gh-contentfilter.js
Kevin Ansfield 24bf414cc3 Added access level filter to posts and pages lists in admin
no issue

- adds `visibility` query param to posts and pages controllers/routes that is tied to the `filter` query param used in API requests
- adds dropdown for selecting post/page visibility to `<GhContentFilter>`
2020-06-09 12:19:40 +01:00

36 lines
1.3 KiB
JavaScript

import Component from '@glimmer/component';
import {get} from '@ember/object';
import {inject as service} from '@ember/service';
export default class GhContentfilterComponent extends Component {
@service customViews;
@service feature;
@service router;
get showCustomViewManagement() {
let isOwnerOrAdmin = get(this.args.currentUser || {}, 'isOwnerOrAdmin');
let onPostsScreen = this.router.currentRouteName === 'posts';
let isDefaultView = this.customViews?.activeView?.isDefault;
let hasFilter = this.args.selectedType.value
|| this.args.selectedVisibility.value
|| this.args.selectedAuthor.slug
|| this.args.selectedTag.slug
|| this.args.selectedOrder.value;
return isOwnerOrAdmin && onPostsScreen && !isDefaultView && hasFilter;
}
calculateActionsDropdownPosition(trigger, content) {
let {top, left, width, height} = trigger.getBoundingClientRect();
// content.firstElementChild is required because we use .dropdown-menu which is absolute positioned
let {width: contentWidth} = content.firstElementChild.getBoundingClientRect();
let style = {
left: left + width - contentWidth,
top: top + height + 5
};
return {style};
}
}