-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add CTAs to create instance from Portlets Tab - MEED-6919 - Mee…
- Loading branch information
Showing
10 changed files
with
199 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
131 changes: 131 additions & 0 deletions
131
layout-webapp/src/main/webapp/vue-app/portlets/components/portlets/Menu.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
<!-- | ||
|
||
This file is part of the Meeds project (https://meeds.io/). | ||
|
||
Copyright (C) 2020 - 2024 Meeds Association contact@meeds.io | ||
|
||
This program is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU Lesser General Public | ||
License as published by the Free Software Foundation; either | ||
version 3 of the License, or (at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
Lesser General Public License for more details. | ||
|
||
You should have received a copy of the GNU Lesser General Public License | ||
along with this program; if not, write to the Free Software Foundation, | ||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
|
||
--> | ||
<template> | ||
<v-menu | ||
v-model="menu" | ||
:left="!$vuetify.rtl" | ||
:right="$vuetify.rtl" | ||
:content-class="menuId" | ||
offset-y> | ||
<template #activator="{ on, attrs }"> | ||
<v-btn | ||
:aria-label="$t('portlets.menu.open')" | ||
icon | ||
small | ||
class="mx-auto" | ||
v-bind="attrs" | ||
v-on="on"> | ||
<v-icon size="16" class="icon-default-color">fas fa-ellipsis-v</v-icon> | ||
</v-btn> | ||
</template> | ||
<v-hover v-if="menu" @input="hoverMenu = $event"> | ||
<v-list | ||
class="pa-0" | ||
dense | ||
@mouseout="menu = false" | ||
@focusout="menu = false"> | ||
<v-list-item-group v-model="listItem"> | ||
<v-list-item | ||
dense | ||
@click="$root.$emit('portlet-instance-add', null, false, portlet.contentId)"> | ||
<v-icon size="13"> | ||
fa-plus | ||
</v-icon> | ||
<v-list-item-title class="ps-2"> | ||
{{ $t('portlets.label.createInstance') }} | ||
</v-list-item-title> | ||
</v-list-item> | ||
</v-list-item-group> | ||
</v-list> | ||
</v-hover> | ||
</v-menu> | ||
</template> | ||
<script> | ||
export default { | ||
props: { | ||
portlet: { | ||
type: Object, | ||
default: null, | ||
}, | ||
}, | ||
data: () => ({ | ||
menu: false, | ||
hoverMenu: false, | ||
listItem: null, | ||
menuId: `PortletMenu${parseInt(Math.random() * 10000)}`, | ||
}), | ||
computed: { | ||
portletId() { | ||
return this.portlet?.id; | ||
}, | ||
name() { | ||
return this.$te(this.portlet?.name) ? this.$t(this.portlet?.name) : this.portlet?.name; | ||
}, | ||
editLayoutLink() { | ||
return `/portal/administration/layout-editor?portletContentId=${this.portletId}`; | ||
}, | ||
}, | ||
watch: { | ||
listItem() { | ||
if (this.menu) { | ||
this.menu = false; | ||
this.listItem = null; | ||
} | ||
}, | ||
menu() { | ||
if (this.menu) { | ||
this.$root.$emit('portlet-menu-opened', this.portletId); | ||
} else { | ||
this.$root.$emit('portlet-menu-closed', this.portletId); | ||
} | ||
}, | ||
hoverMenu() { | ||
if (!this.hoverMenu) { | ||
window.setTimeout(() => { | ||
if (!this.hoverMenu) { | ||
this.menu = false; | ||
} | ||
}, 200); | ||
} | ||
}, | ||
}, | ||
created() { | ||
this.$root.$on('portlet-menu-opened', this.checkMenuStatus); | ||
document.addEventListener('click', this.closeMenuOnClick); | ||
}, | ||
beforeDestroy() { | ||
this.$root.$off('portlet-menu-opened', this.checkMenuStatus); | ||
document.removeEventListener('click', this.closeMenuOnClick); | ||
}, | ||
methods: { | ||
closeMenuOnClick(e) { | ||
if (e.target && !e.target.closest(`.${this.menuId}`)) { | ||
this.menu = false; | ||
} | ||
}, | ||
checkMenuStatus(portletId) { | ||
if (this.menu && portletId !== this.portlet.id) { | ||
this.menu = false; | ||
} | ||
}, | ||
}, | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters