2023-03-17 10:59:23 +00:00
|
|
|
<template>
|
2024-01-03 15:19:54 +00:00
|
|
|
<div class="element-preview__menu" @click.stop>
|
2023-10-04 14:24:37 +00:00
|
|
|
<span v-if="isDuplicating" class="element-preview__menu-item disabled">
|
|
|
|
<div class="loading"></div>
|
|
|
|
</span>
|
2023-06-27 09:29:02 +00:00
|
|
|
<a v-else class="element-preview__menu-item" @click="$emit('duplicate')">
|
2023-09-28 13:39:41 +00:00
|
|
|
<i class="iconoir-copy"></i>
|
2023-06-27 09:29:02 +00:00
|
|
|
<span class="element-preview__menu-item-description">
|
2024-03-05 08:16:41 +00:00
|
|
|
{{ $t('action.duplicate') }} (d)
|
2023-03-17 10:59:23 +00:00
|
|
|
</span>
|
|
|
|
</a>
|
2023-12-21 14:55:06 +00:00
|
|
|
<a
|
|
|
|
v-if="hasParent"
|
|
|
|
class="element-preview__menu-item"
|
2024-01-03 15:19:54 +00:00
|
|
|
@click="$emit('select-parent')"
|
2023-12-21 14:55:06 +00:00
|
|
|
>
|
|
|
|
<i class="iconoir-scale-frame-enlarge"></i>
|
|
|
|
<span class="element-preview__menu-item-description">
|
2024-03-05 08:16:41 +00:00
|
|
|
{{ $t('elementMenu.selectParent') }} (p)
|
2023-12-21 14:55:06 +00:00
|
|
|
</span>
|
|
|
|
</a>
|
2023-03-17 10:59:23 +00:00
|
|
|
<a
|
2024-11-28 08:47:54 +00:00
|
|
|
v-if="isDirectionVisible(DIRECTIONS.LEFT)"
|
2023-06-27 09:29:02 +00:00
|
|
|
class="element-preview__menu-item"
|
2024-11-28 08:47:54 +00:00
|
|
|
:class="{
|
|
|
|
'element-preview__menu-item--disabled': !isAllowedDirection(
|
|
|
|
DIRECTIONS.LEFT
|
|
|
|
),
|
|
|
|
}"
|
|
|
|
@click="$emit('move', DIRECTIONS.LEFT)"
|
2023-08-08 13:28:03 +00:00
|
|
|
>
|
2023-09-28 13:39:41 +00:00
|
|
|
<i class="iconoir-nav-arrow-left"></i>
|
2024-11-28 08:47:54 +00:00
|
|
|
<span class="element-preview__menu-item-description">
|
2023-08-08 13:28:03 +00:00
|
|
|
{{ $t('elementMenu.moveLeft') }}
|
|
|
|
</span>
|
|
|
|
</a>
|
|
|
|
<a
|
2024-11-28 08:47:54 +00:00
|
|
|
v-if="isDirectionVisible(DIRECTIONS.RIGHT)"
|
2023-08-08 13:28:03 +00:00
|
|
|
class="element-preview__menu-item"
|
2024-11-28 08:47:54 +00:00
|
|
|
:class="{
|
|
|
|
'element-preview__menu-item--disabled': !isAllowedDirection(
|
|
|
|
DIRECTIONS.RIGHT
|
|
|
|
),
|
|
|
|
}"
|
|
|
|
@click="$emit('move', DIRECTIONS.RIGHT)"
|
2023-08-08 13:28:03 +00:00
|
|
|
>
|
2023-09-28 13:39:41 +00:00
|
|
|
<i class="iconoir-nav-arrow-right"></i>
|
2024-11-28 08:47:54 +00:00
|
|
|
<span class="element-preview__menu-item-description">
|
2023-08-08 13:28:03 +00:00
|
|
|
{{ $t('elementMenu.moveRight') }}
|
|
|
|
</span>
|
|
|
|
</a>
|
|
|
|
<a
|
2024-11-28 08:47:54 +00:00
|
|
|
v-if="isDirectionVisible(DIRECTIONS.BEFORE)"
|
2023-08-08 13:28:03 +00:00
|
|
|
class="element-preview__menu-item"
|
2024-11-28 08:47:54 +00:00
|
|
|
:class="{
|
|
|
|
'element-preview__menu-item--disabled': !isAllowedDirection(
|
|
|
|
DIRECTIONS.BEFORE
|
|
|
|
),
|
|
|
|
}"
|
|
|
|
@click="$emit('move', DIRECTIONS.BEFORE)"
|
2023-03-17 10:59:23 +00:00
|
|
|
>
|
2023-09-28 13:39:41 +00:00
|
|
|
<i class="iconoir-nav-arrow-up"></i>
|
2024-11-28 08:47:54 +00:00
|
|
|
<span class="element-preview__menu-item-description">
|
2023-03-17 10:59:23 +00:00
|
|
|
{{ $t('elementMenu.moveUp') }}
|
|
|
|
</span>
|
|
|
|
</a>
|
|
|
|
<a
|
2024-11-28 08:47:54 +00:00
|
|
|
v-if="isDirectionVisible(DIRECTIONS.AFTER)"
|
2023-06-27 09:29:02 +00:00
|
|
|
class="element-preview__menu-item"
|
2024-11-28 08:47:54 +00:00
|
|
|
:class="{
|
|
|
|
'element-preview__menu-item--disabled': !isAllowedDirection(
|
|
|
|
DIRECTIONS.AFTER
|
|
|
|
),
|
|
|
|
}"
|
|
|
|
@click="$emit('move', DIRECTIONS.AFTER)"
|
2023-03-17 10:59:23 +00:00
|
|
|
>
|
2023-09-28 13:39:41 +00:00
|
|
|
<i class="iconoir-nav-arrow-down"></i>
|
2024-11-28 08:47:54 +00:00
|
|
|
<span class="element-preview__menu-item-description">
|
2023-03-17 10:59:23 +00:00
|
|
|
{{ $t('elementMenu.moveDown') }}
|
|
|
|
</span>
|
|
|
|
</a>
|
2023-06-27 09:29:02 +00:00
|
|
|
<a class="element-preview__menu-item" @click="$emit('delete')">
|
2023-09-28 13:39:41 +00:00
|
|
|
<i class="iconoir-bin"></i>
|
2023-06-27 09:29:02 +00:00
|
|
|
<span class="element-preview__menu-item-description">
|
2024-03-05 08:16:41 +00:00
|
|
|
{{ $t('action.delete') }} (del)
|
2023-03-17 10:59:23 +00:00
|
|
|
</span>
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2024-11-28 08:47:54 +00:00
|
|
|
import { DIRECTIONS } from '@baserow/modules/builder/enums'
|
2023-03-17 10:59:23 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'ElementMenu',
|
|
|
|
props: {
|
2023-08-08 13:28:03 +00:00
|
|
|
isDuplicating: {
|
2023-03-17 10:59:23 +00:00
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false,
|
|
|
|
},
|
2023-12-21 14:55:06 +00:00
|
|
|
hasParent: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false,
|
|
|
|
},
|
2024-11-28 08:47:54 +00:00
|
|
|
directions: {
|
2023-08-08 13:28:03 +00:00
|
|
|
type: Array,
|
2023-03-17 10:59:23 +00:00
|
|
|
required: false,
|
2024-11-28 08:47:54 +00:00
|
|
|
default: () => [DIRECTIONS.BEFORE, DIRECTIONS.AFTER],
|
2023-03-17 10:59:23 +00:00
|
|
|
},
|
2024-11-28 08:47:54 +00:00
|
|
|
allowedDirections: {
|
2023-08-08 13:28:03 +00:00
|
|
|
type: Array,
|
2023-03-17 10:59:23 +00:00
|
|
|
required: false,
|
2023-08-08 13:28:03 +00:00
|
|
|
default: () => [],
|
2023-03-17 10:59:23 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
computed: {
|
2024-11-28 08:47:54 +00:00
|
|
|
DIRECTIONS: () => DIRECTIONS,
|
2023-03-17 10:59:23 +00:00
|
|
|
},
|
2023-08-08 13:28:03 +00:00
|
|
|
methods: {
|
2024-11-28 08:47:54 +00:00
|
|
|
isDirectionVisible(direction) {
|
|
|
|
return this.directions.includes(direction)
|
2023-08-08 13:28:03 +00:00
|
|
|
},
|
2024-11-28 08:47:54 +00:00
|
|
|
isAllowedDirection(direction) {
|
|
|
|
return this.allowedDirections.includes(direction)
|
2023-08-08 13:28:03 +00:00
|
|
|
},
|
|
|
|
},
|
2023-03-17 10:59:23 +00:00
|
|
|
}
|
|
|
|
</script>
|