diff --git a/addon/components/content-panel.hbs b/addon/components/content-panel.hbs index 8fea000..ccb2811 100644 --- a/addon/components/content-panel.hbs +++ b/addon/components/content-panel.hbs @@ -44,19 +44,61 @@
- {{#if @prefixTitleRight}} -
- {{@prefixTitleRight}} -
- {{/if}} - {{#if @titleStatusRight}} - - - + {{#if @titleRightSideComponent}} + {{component @titleRightSideComponent context=@titleRightSideComponentContext}} + {{else}} + {{#if @prefixTitleRight}} +
+ {{@prefixTitleRight}} +
+ {{/if}} + {{#if @titleStatusRight}} + + {{#if @titleStatusRightText}} + + {{@titleStatusRightText}} + + {{else}} + + {{/if}} + + {{/if}} + {{#each @actionButtons as |button|}} +
diff --git a/addon/components/content-panel.js b/addon/components/content-panel.js index 621185f..b5d4fdd 100644 --- a/addon/components/content-panel.js +++ b/addon/components/content-panel.js @@ -26,4 +26,18 @@ export default class ContentPanelComponent extends Component { @action close() { this.isOpen = false; } + + @action onDropdownItemClick(action, dd) { + if (typeof dd.actions === 'object' && typeof dd.actions.close === 'function') { + dd.actions.close(); + } + + if (typeof action.fn === 'function') { + action.fn(action.context); + } + + if (typeof action.onClick === 'function') { + action.onClick(action.context); + } + } } diff --git a/addon/components/dropdown-button.hbs b/addon/components/dropdown-button.hbs index 1fee8d8..4d5cfcc 100644 --- a/addon/components/dropdown-button.hbs +++ b/addon/components/dropdown-button.hbs @@ -1,4 +1,4 @@ - + {{#if @buttonComponent}} {{component @buttonComponent buttonComponentArgs=this.buttonComponentArgs text=@text class=(concat @buttonClass (if dd.isOpen ' dd-is-open')) wrapperClass=@buttonWrapperClass type=this.type active=@active size=this.buttonSize isLoading=@isLoading disabled=@disabled textClass=@textClass helpText=@helpText tooltipPlacement=@tooltipPlacement img=@img imgClass=@imgClass alt=@alt}} diff --git a/addon/components/dropdown-button.js b/addon/components/dropdown-button.js index e05af6a..e951bc3 100644 --- a/addon/components/dropdown-button.js +++ b/addon/components/dropdown-button.js @@ -1,5 +1,5 @@ import Component from '@glimmer/component'; -import { computed } from '@ember/object'; +import { computed, action } from '@ember/object'; import { isBlank } from '@ember/utils'; export default class DropdownButtonComponent extends Component { @@ -32,4 +32,15 @@ export default class DropdownButtonComponent extends Component { return isBlank(buttonComponentArgs) || typeof buttonComponentArgs !== 'object' ? {} : buttonComponentArgs; } + + /** + * Trigger callback when dropdown button node is inserted to dom. + * + * @memberof DropdownButtonComponent + */ + @action onInsert() { + if (typeof this.args.onInsert === 'function') { + this.args.onInsert(...arguments); + } + } } diff --git a/addon/components/layout/sidebar/item.hbs b/addon/components/layout/sidebar/item.hbs index f1ddc0f..8669837 100644 --- a/addon/components/layout/sidebar/item.hbs +++ b/addon/components/layout/sidebar/item.hbs @@ -1,8 +1,58 @@ - +
{{#if @icon}} {{/if}}
{{yield}}
+
\ No newline at end of file diff --git a/addon/components/layout/sidebar/item.js b/addon/components/layout/sidebar/item.js index 211b1dd..ea6f28a 100644 --- a/addon/components/layout/sidebar/item.js +++ b/addon/components/layout/sidebar/item.js @@ -9,6 +9,7 @@ export default class LayoutSidebarItemComponent extends Component { @service router; @service hostRouter; @tracked active; + @tracked dropdownButtonNode; constructor() { super(...arguments); @@ -41,6 +42,11 @@ export default class LayoutSidebarItemComponent extends Component { } @action onClick(event) { + if (this.isPointerWithinDropdownButton(event)) { + event.preventDefault(); + return; + } + const { url, target, route, model, onClick, options } = this.args; const router = this.getRouter(); const anchor = event.target?.closest('a'); @@ -78,6 +84,36 @@ export default class LayoutSidebarItemComponent extends Component { } } + @action onDropdownItemClick(action, dd) { + if (typeof dd.actions === 'object' && typeof dd.actions.close === 'function') { + dd.actions.close(); + } + + if (typeof action.fn === 'function') { + action.fn(action.context); + } + + if (typeof action.onClick === 'function') { + action.onClick(action.context); + } + } + + @action onInsert(dropdownButtonNode) { + this.dropdownButtonNode = dropdownButtonNode; + + if (typeof this.args.onDropdownButtonInsert === 'function') { + this.args.onDropdownButtonInsert(...arguments); + } + } + + isPointerWithinDropdownButton({ target }) { + if (this.dropdownButtonNode) { + return this.dropdownButtonNode.contains(target); + } + + return false; + } + getRouter() { return this.router ?? this.hostRouter; } diff --git a/addon/components/layout/sidebar/panel.hbs b/addon/components/layout/sidebar/panel.hbs index 3d59b90..c2abddb 100644 --- a/addon/components/layout/sidebar/panel.hbs +++ b/addon/components/layout/sidebar/panel.hbs @@ -1,3 +1,3 @@ - + {{yield}} \ No newline at end of file diff --git a/addon/components/pagination.hbs b/addon/components/pagination.hbs index cdd04e7..d72566c 100644 --- a/addon/components/pagination.hbs +++ b/addon/components/pagination.hbs @@ -1,15 +1,30 @@
-