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.
106 lines
3.0 KiB
106 lines
3.0 KiB
4 years ago
|
<template>
|
||
|
<v-menu
|
||
3 years ago
|
v-model="active"
|
||
4 years ago
|
dense
|
||
3 years ago
|
:offset-x="offsetX"
|
||
|
:offset-y="offsetY"
|
||
|
:position-x="positionX"
|
||
|
:position-y="positionY"
|
||
|
:open-on-hover="nested"
|
||
|
>
|
||
4 years ago
|
<!-- nested menu activator -->
|
||
3 years ago
|
<template v-if="nested" #activator="{ on }">
|
||
|
<v-list-item dense class="" v-on="on">
|
||
4 years ago
|
<v-list-item-title class="">
|
||
3 years ago
|
<slot name="activator">
|
||
|
{{ parent }}
|
||
|
</slot>
|
||
4 years ago
|
</v-list-item-title>
|
||
3 years ago
|
<v-list-item-action class="my-0 py-0">
|
||
4 years ago
|
<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="">
|
||
4 years ago
|
<template v-if="item">
|
||
3 years ago
|
<v-list-item v-if="typeof item !== 'object'" dense @click="$emit('click', { value: item })">
|
||
|
<v-list-item-title class="">
|
||
4 years ago
|
{{ index }}
|
||
|
</v-list-item-title>
|
||
|
</v-list-item>
|
||
|
<!-- if value is a nested object then populating nested menu recursively -->
|
||
3 years ago
|
<v-list-item v-else dense class="px-0">
|
||
|
<recursiveMenu offset-x nested :items="item" :parent="index" @click="onSubMenuClick" />
|
||
4 years ago
|
</v-list-item>
|
||
|
</template>
|
||
3 years ago
|
<v-divider v-else />
|
||
4 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,
|
||
3 years ago
|
positionY: Number,
|
||
3 years ago
|
},
|
||
3 years ago
|
data() {
|
||
3 years ago
|
return {
|
||
3 years ago
|
active: false,
|
||
|
};
|
||
3 years ago
|
},
|
||
|
watch: {
|
||
|
// two way binding of v-model
|
||
3 years ago
|
value(v) {
|
||
3 years ago
|
this.active = v;
|
||
4 years ago
|
},
|
||
3 years ago
|
active(v) {
|
||
3 years ago
|
this.$emit('input', v);
|
||
|
},
|
||
3 years ago
|
},
|
||
|
methods: {
|
||
|
// event propagating to parent v-menu(click event)
|
||
3 years ago
|
onSubMenuClick(event) {
|
||
3 years ago
|
this.$emit('click', event);
|
||
3 years ago
|
// hiding parent menu
|
||
3 years ago
|
this.active = false;
|
||
|
},
|
||
|
},
|
||
|
};
|
||
4 years ago
|
</script>
|
||
|
|
||
3 years ago
|
<style scoped></style>
|
||
4 years ago
|
<!--
|
||
|
/**
|
||
|
* @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/>.
|
||
|
*
|
||
|
*/
|
||
|
-->
|