From ae07206100653df63014fcd3c07c7447aee4ad67 Mon Sep 17 00:00:00 2001 From: Tobias Klika Date: Wed, 20 May 2020 13:15:20 +0200 Subject: [PATCH] open actions on right-click too --- .../App/components/buttons/dot-button.vue | 12 +-- .../App/components/buttons/icon-button.vue | 6 +- .../App/components/overlays/dropdown-list.vue | 13 ++- zero.Web.UI/App/components/tree.vue | 82 ++++++++++++++++++- zero.Web.UI/Sass/Core/_settings.scss | 2 +- zero.Web.UI/Sass/Modules/Buttons/_button.scss | 3 +- 6 files changed, 95 insertions(+), 23 deletions(-) diff --git a/zero.Web.UI/App/components/buttons/dot-button.vue b/zero.Web.UI/App/components/buttons/dot-button.vue index 4336ccec..dae5bcc5 100644 --- a/zero.Web.UI/App/components/buttons/dot-button.vue +++ b/zero.Web.UI/App/components/buttons/dot-button.vue @@ -1,5 +1,5 @@  @@ -59,6 +62,8 @@ data: () => ({ items: [], status: 'none', + actionsOpen: false, + actionsLoaded: false, actions: [], configuration: {} }), @@ -119,6 +124,73 @@ 'is-inactive': item.isInactive, 'is-open': item.isOpen }; + }, + + // hide actions overlay + hideActions() + { + if (this.actionsLoaded) + { + this.actionsOpen = false; + } + }, + + // right clicked on an item + onRightClicked(item, ev) + { + if (this.configuration.onActionsRequested) + { + ev.preventDefault(); + this.onActionsClicked(item, ev); + } + }, + + // actions button clicked on item + onActionsClicked(item, ev) + { + this.actionsLoaded = false; + this.actionsOpen = !this.actionsOpen; + + if (!this.actionsOpen) + { + this.actionsLoaded = true; + return; + } + + this.actions = this.configuration.onActionsRequested(item); + + this.$nextTick(() => + { + let dropdown = this.$refs.dropdown; + let target = ev.target; + do + { + if (target.classList.contains('ui-tree-item')) + { + break; + } + } + while (target = target.parentElement); + + target = target.querySelector('.ui-tree-item-actions'); + + var rect = target.getBoundingClientRect(); + var width = 240; + + var position = { + x: rect.left - width + rect.width, + y: rect.top + rect.height + }; + + dropdown.style.top = position.y + 'px'; + dropdown.style.left = position.x + 'px'; + dropdown.style.width = width + 'px'; + + setTimeout(() => + { + this.actionsLoaded = true; + }, 300); + }); } } @@ -264,4 +336,10 @@ opacity: 0; color: var(--color-fg-mid); } + + .ui-tree-dropdown + { + position: fixed; + min-width: 200px; + } \ No newline at end of file diff --git a/zero.Web.UI/Sass/Core/_settings.scss b/zero.Web.UI/Sass/Core/_settings.scss index 56dfb870..1d502eaa 100644 --- a/zero.Web.UI/Sass/Core/_settings.scss +++ b/zero.Web.UI/Sass/Core/_settings.scss @@ -49,7 +49,7 @@ --padding: 32px; --padding-s: 24px; --height-top: 74px; - --radius: 5px; + --radius: 3px; --font-size-xs: 12px; --font-size-s: 13px; diff --git a/zero.Web.UI/Sass/Modules/Buttons/_button.scss b/zero.Web.UI/Sass/Modules/Buttons/_button.scss index 559a38bb..c0a8e1a9 100644 --- a/zero.Web.UI/Sass/Modules/Buttons/_button.scss +++ b/zero.Web.UI/Sass/Modules/Buttons/_button.scss @@ -236,7 +236,7 @@ button::-moz-focus-inner width: 36px; text-align: center; justify-content: center; - font-size: var(--font-size-xl); + color: var(--color-text); &:hover { @@ -245,6 +245,7 @@ button::-moz-focus-inner .ui-button-icon { + font-size: var(--font-size-xl); margin: 0; } }