mirror of https://github.com/nocodb/nocodb
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
136 lines
3.3 KiB
136 lines
3.3 KiB
3 years ago
|
<template>
|
||
|
<v-menu
|
||
3 years ago
|
v-model="active"
|
||
3 years ago
|
dense
|
||
3 years ago
|
:offset-x="offsetX"
|
||
|
:offset-y="offsetY"
|
||
|
:position-x="positionX"
|
||
|
:position-y="positionY"
|
||
|
:open-on-hover="nested"
|
||
|
>
|
||
3 years ago
|
<!-- nested menu activator -->
|
||
|
<template
|
||
|
v-if="nested"
|
||
3 years ago
|
#activator="{on}"
|
||
|
>
|
||
3 years ago
|
<v-list-item
|
||
|
dense
|
||
|
class=""
|
||
|
v-on="on"
|
||
|
>
|
||
|
<v-list-item-title class="">
|
||
3 years ago
|
<slot name="activator">
|
||
|
{{ parent }}
|
||
|
</slot>
|
||
3 years ago
|
</v-list-item-title>
|
||
|
<v-list-item-action
|
||
|
class="my-0 py-0"
|
||
|
>
|
||
|
<v-icon>mdi-menu-right</v-icon>
|
||
|
</v-list-item-action>
|
||
|
</v-list-item>
|
||
|
</template>
|
||
|
<v-list dense>
|
||
3 years ago
|
<div
|
||
|
v-for="(item, index) in items"
|
||
|
:key="index"
|
||
|
class=""
|
||
|
>
|
||
3 years ago
|
<template v-if="item">
|
||
|
<v-list-item
|
||
3 years ago
|
v-if="typeof item !== 'object'"
|
||
3 years ago
|
dense
|
||
3 years ago
|
@click="$emit('click', {value :item})"
|
||
|
>
|
||
|
<v-list-item-title
|
||
|
class=""
|
||
|
>
|
||
3 years ago
|
{{ index }}
|
||
|
</v-list-item-title>
|
||
|
</v-list-item>
|
||
|
<!-- if value is a nested object then populating nested menu recursively -->
|
||
|
<v-list-item
|
||
3 years ago
|
v-else
|
||
3 years ago
|
dense
|
||
3 years ago
|
class="px-0"
|
||
|
>
|
||
|
<recursiveMenu
|
||
|
offset-x
|
||
|
nested
|
||
|
:items="item"
|
||
|
:parent="index"
|
||
|
@click="onSubMenuClick"
|
||
|
/>
|
||
3 years ago
|
</v-list-item>
|
||
|
</template>
|
||
3 years ago
|
<v-divider v-else />
|
||
3 years ago
|
</div>
|
||
|
</v-list>
|
||
|
</v-menu>
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
3 years ago
|
export default {
|
||
|
name: 'RecursiveMenu',
|
||
|
props: {
|
||
|
items: Object, // key value pairs where key will be the menu item name and value is passed with click event handler
|
||
|
value: Boolean, // for getting v-model value
|
||
|
nested: Boolean, // for populating nested menu(recursively - for internal use)
|
||
|
offsetY: Boolean,
|
||
|
offsetX: Boolean,
|
||
|
parent: String, // for activator slot label
|
||
|
positionX: Number,
|
||
|
positionY: Number
|
||
|
},
|
||
3 years ago
|
data() {
|
||
3 years ago
|
return {
|
||
|
active: false
|
||
|
}
|
||
|
},
|
||
|
watch: {
|
||
|
// two way binding of v-model
|
||
3 years ago
|
value(v) {
|
||
3 years ago
|
this.active = v
|
||
3 years ago
|
},
|
||
3 years ago
|
active(v) {
|
||
3 years ago
|
this.$emit('input', v)
|
||
|
}
|
||
|
},
|
||
|
methods: {
|
||
|
// event propagating to parent v-menu(click event)
|
||
3 years ago
|
onSubMenuClick(event) {
|
||
3 years ago
|
this.$emit('click', event)
|
||
|
// hiding parent menu
|
||
|
this.active = false
|
||
3 years ago
|
}
|
||
|
}
|
||
3 years ago
|
}
|
||
3 years ago
|
</script>
|
||
|
|
||
|
<style scoped>
|
||
|
</style>
|
||
|
<!--
|
||
|
/**
|
||
|
* @copyright Copyright (c) 2021, Xgene Cloud Ltd
|
||
|
*
|
||
|
* @author Naveen MR <oof1lab@gmail.com>
|
||
|
* @author Pranav C Balan <pranavxc@gmail.com>
|
||
|
*
|
||
|
* @license GNU AGPL version 3 or any later version
|
||
|
*
|
||
|
* This program is free software: you can redistribute it and/or modify
|
||
|
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||
|
*
|
||
|
* You should have received a copy of the GNU Affero General Public License
|
||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||
|
*
|
||
|
*/
|
||
|
-->
|