mirror of
https://gitlab.com/bramw/baserow.git
synced 2025-04-03 04:35:31 +00:00
Add Keyboard Shortcut Support for Page Elements
This commit is contained in:
parent
f80d8c8ded
commit
37636210c7
4 changed files with 31 additions and 12 deletions
web-frontend/modules/builder
|
@ -6,7 +6,7 @@
|
||||||
<a v-else class="element-preview__menu-item" @click="$emit('duplicate')">
|
<a v-else class="element-preview__menu-item" @click="$emit('duplicate')">
|
||||||
<i class="iconoir-copy"></i>
|
<i class="iconoir-copy"></i>
|
||||||
<span class="element-preview__menu-item-description">
|
<span class="element-preview__menu-item-description">
|
||||||
{{ $t('action.duplicate') }}
|
{{ $t('action.duplicate') }} (d)
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
<a
|
<a
|
||||||
|
@ -16,7 +16,7 @@
|
||||||
>
|
>
|
||||||
<i class="iconoir-scale-frame-enlarge"></i>
|
<i class="iconoir-scale-frame-enlarge"></i>
|
||||||
<span class="element-preview__menu-item-description">
|
<span class="element-preview__menu-item-description">
|
||||||
{{ $t('elementMenu.selectParent') }}
|
{{ $t('elementMenu.selectParent') }} (p)
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
<a
|
<a
|
||||||
|
@ -89,7 +89,7 @@
|
||||||
<a class="element-preview__menu-item" @click="$emit('delete')">
|
<a class="element-preview__menu-item" @click="$emit('delete')">
|
||||||
<i class="iconoir-bin"></i>
|
<i class="iconoir-bin"></i>
|
||||||
<span class="element-preview__menu-item-description">
|
<span class="element-preview__menu-item-description">
|
||||||
{{ $t('action.delete') }}
|
{{ $t('action.delete') }} (del)
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<div
|
<div
|
||||||
|
:key="element.id"
|
||||||
class="element-preview"
|
class="element-preview"
|
||||||
:class="{
|
:class="{
|
||||||
'element-preview--active': isSelected,
|
'element-preview--active': isSelected,
|
||||||
|
@ -7,7 +8,11 @@
|
||||||
'element-preview--in-error': inError,
|
'element-preview--in-error': inError,
|
||||||
'element-preview--first-element': isFirstElement,
|
'element-preview--first-element': isFirstElement,
|
||||||
}"
|
}"
|
||||||
|
tabindex="0"
|
||||||
@click="onSelect"
|
@click="onSelect"
|
||||||
|
@keyup.d.stop="duplicateElement"
|
||||||
|
@keyup.delete.stop="deleteElement"
|
||||||
|
@keyup.p.stop="selectParentElement"
|
||||||
>
|
>
|
||||||
<InsertElementButton
|
<InsertElementButton
|
||||||
v-show="isSelected"
|
v-show="isSelected"
|
||||||
|
@ -101,6 +106,16 @@ export default {
|
||||||
isDuplicating: false,
|
isDuplicating: false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
watch: {
|
||||||
|
/**
|
||||||
|
* Focuses the element if the element has been selected.
|
||||||
|
*/
|
||||||
|
isSelected(newValue, old) {
|
||||||
|
if (newValue && !old) {
|
||||||
|
this.$el.focus()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapGetters({
|
...mapGetters({
|
||||||
elementSelected: 'element/getSelected',
|
elementSelected: 'element/getSelected',
|
||||||
|
@ -213,6 +228,11 @@ export default {
|
||||||
notifyIf(error)
|
notifyIf(error)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
selectParentElement() {
|
||||||
|
if (this.parentElement) {
|
||||||
|
this.actionSelectElement({ element: this.parentElement })
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -15,15 +15,12 @@
|
||||||
<template v-if="childrenInColumn.length > 0">
|
<template v-if="childrenInColumn.length > 0">
|
||||||
<div
|
<div
|
||||||
v-for="(childCurrent, rowIndex) in childrenInColumn"
|
v-for="(childCurrent, rowIndex) in childrenInColumn"
|
||||||
:key="rowIndex"
|
:key="childCurrent.id"
|
||||||
class="column-element__element"
|
class="column-element__element"
|
||||||
>
|
>
|
||||||
<ElementPreview
|
<ElementPreview
|
||||||
v-if="mode === 'editing'"
|
v-if="mode === 'editing'"
|
||||||
class="element"
|
|
||||||
:element="childCurrent"
|
:element="childCurrent"
|
||||||
:active="childCurrent.id === elementSelectedId"
|
|
||||||
:index="rowIndex"
|
|
||||||
:placements="[
|
:placements="[
|
||||||
PLACEMENTS.BEFORE,
|
PLACEMENTS.BEFORE,
|
||||||
PLACEMENTS.AFTER,
|
PLACEMENTS.AFTER,
|
||||||
|
@ -167,10 +164,11 @@ export default {
|
||||||
// the click event select the container because the element is removed from the
|
// the click event select the container because the element is removed from the
|
||||||
// DOM too quickly
|
// DOM too quickly
|
||||||
await flushPromises()
|
await flushPromises()
|
||||||
|
|
||||||
if (placement === PLACEMENTS.AFTER || placement === PLACEMENTS.BEFORE) {
|
if (placement === PLACEMENTS.AFTER || placement === PLACEMENTS.BEFORE) {
|
||||||
this.moveVertical(element, rowIndex, columnIndex, placement)
|
await this.moveVertical(element, rowIndex, columnIndex, placement)
|
||||||
} else {
|
} else {
|
||||||
this.moveHorizontal(element, columnIndex, placement)
|
await this.moveHorizontal(element, columnIndex, placement)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async moveVertical(element, rowIndex, columnIndex, placement) {
|
async moveVertical(element, rowIndex, columnIndex, placement) {
|
||||||
|
|
|
@ -9,6 +9,7 @@ const populateElement = (element) => {
|
||||||
content: [],
|
content: [],
|
||||||
hasNextPage: false,
|
hasNextPage: false,
|
||||||
reset: 0,
|
reset: 0,
|
||||||
|
shouldBeFocused: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
return element
|
return element
|
||||||
|
@ -272,7 +273,7 @@ const actions = {
|
||||||
return elements
|
return elements
|
||||||
},
|
},
|
||||||
async move(
|
async move(
|
||||||
{ dispatch, getters },
|
{ commit, dispatch, getters },
|
||||||
{
|
{
|
||||||
page,
|
page,
|
||||||
elementId,
|
elementId,
|
||||||
|
@ -313,7 +314,7 @@ const actions = {
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async duplicate({ dispatch, getters }, { page, elementId }) {
|
async duplicate({ commit, dispatch, getters }, { page, elementId }) {
|
||||||
const {
|
const {
|
||||||
data: { elements, workflow_actions: workflowActions },
|
data: { elements, workflow_actions: workflowActions },
|
||||||
} = await ElementService(this.$client).duplicate(elementId)
|
} = await ElementService(this.$client).duplicate(elementId)
|
||||||
|
@ -337,7 +338,7 @@ const actions = {
|
||||||
parentId === elementToDuplicate.parent_element_id
|
parentId === elementToDuplicate.parent_element_id
|
||||||
)
|
)
|
||||||
|
|
||||||
dispatch('select', { page, element: elementToSelect })
|
commit('SELECT_ITEM', { element: elementToSelect })
|
||||||
|
|
||||||
return elements
|
return elements
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Reference in a new issue