Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 31 additions & 21 deletions src/components/textBlocks/TextBlockModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
- SPDX-License-Identifier: AGPL-3.0-or-later
-->
<template>
<NcDialog id="text-block-picker" :name="t('mail', 'Text blocks')" @closing="handleClose">
<NcDialog
v-if="hasTextBlockes"
id="text-block-picker"
:name="t('mail', 'Text blocks')"
:buttons="saveButtons"
@closing="handleClose">
<p>{{ t('mail', 'Choose a text block to insert at the cursor') }}</p>
<ListItem
v-for="textBlock in getMyTextBlocks()"
Expand All @@ -20,22 +25,20 @@
:is-view-mode="true"
:picked="textBlock.id === picked?.id"
@click="handleClick" />
<NcButton
class="insert-button"
:disabled="!picked"
@click="$emit('insert', picked)">
{{ t('mail', 'Insert') }}
<template #icon>
<IconCheck :size="20" :name="t('mail', 'Insert text block')" />
</template>
</NcButton>
</NcDialog>
<NcDialog
v-else
id="text-block-picker"
:name="t('mail', 'Text blocks')"
:message="t('mail', 'Text blocks are reusable pieces of text that can be inserted in messages. Visit the Settings panel to create your owns.')"
@closing="handleClose">
</NcDialog>
</template>

<script>
import { NcButton, NcDialog } from '@nextcloud/vue'
import IconCheck from '@mdi/svg/svg/check.svg'
import { NcDialog } from '@nextcloud/vue'
import { mapState } from 'pinia'
import IconCheck from 'vue-material-design-icons/Check.vue'
import ListItem from './ListItem.vue'
import useMainStore from '../../store/mainStore.js'

Expand All @@ -44,8 +47,6 @@ export default {
components: {
ListItem,
NcDialog,
NcButton,
IconCheck,
},

data() {
Expand All @@ -56,6 +57,22 @@ export default {

computed: {
...mapState(useMainStore, ['getMyTextBlocks', 'getSharedTextBlocks']),

hasTextBlockes() {
return this.getMyTextBlocks().length > 0 || this.getSharedTextBlocks().length > 0
},

saveButtons() {
return [
{
variant: 'primary',
disabled: !this.picked,
callback: () => this.$emit('insert', this.picked),
label: t('mail', 'Insert'),
icon: IconCheck,
},
]
},
},

methods: {
Expand All @@ -69,10 +86,3 @@ export default {
},
}
</script>

<style lang="scss" scoped>
.insert-button {
justify-self: end;
margin-bottom: calc( var(--default-grid-baseline) * 2) ;
}
</style>
Loading