Skip to content

Commit

Permalink
feat: delete poll drafts
Browse files Browse the repository at this point in the history
Signed-off-by: Maksim Sukharev <[email protected]>
  • Loading branch information
Antreesy committed Oct 18, 2024
1 parent d07fc91 commit 72b5efb
Showing 1 changed file with 32 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,22 @@
<!-- Poll card -->
<div v-if="draft" class="poll-card" @click="openDraft">
<span class="poll-card__header">
<PollIcon :size="20" />
<IconPoll :size="20" />
<span>{{ name }}</span>
</span>
<span class="poll-card__footer">
{{ pollFooterText }}
</span>

<NcButton class="poll-card__delete-draft"
type="tertiary"
:title="t('spreed', 'Delete poll draft')"
:aria-label="t('spreed', 'Delete poll draft')"
@click.stop="deleteDraft">
<template #icon>
<IconDelete :size="20" />
</template>
</NcButton>
</div>
<a v-else-if="!showAsButton"
v-intersection-observer="getPollData"
Expand All @@ -21,7 +31,7 @@
role="button"
@click="openPoll">
<span class="poll-card__header">
<PollIcon :size="20" />
<IconPoll :size="20" />
<span>{{ name }}</span>
</span>
<span class="poll-card__footer">
Expand All @@ -41,7 +51,8 @@
<script>
import { vIntersectionObserver as IntersectionObserver } from '@vueuse/components'

import PollIcon from 'vue-material-design-icons/Poll.vue'
import IconDelete from 'vue-material-design-icons/Delete.vue'
import IconPoll from 'vue-material-design-icons/Poll.vue'

import { t, n } from '@nextcloud/l10n'

Expand All @@ -55,7 +66,8 @@ export default {

components: {
NcButton,
PollIcon,
IconDelete,
IconPoll,
},

directives: {
Expand Down Expand Up @@ -135,6 +147,13 @@ export default {
this.$emit('click', this.id)
},

deleteDraft() {
this.pollsStore.deletePollDraft({
token: this.token,
pollId: this.id,
})
},

openPoll() {
this.pollsStore.setActivePoll({
token: this.token,
Expand All @@ -148,9 +167,10 @@ export default {

<style lang="scss" scoped>
.poll-card {
position: relative;
display: block;
max-width: 300px;
padding: 16px;
padding: calc(3 * var(--default-grid-baseline)) calc(2 * var(--default-grid-baseline));
border: 2px solid var(--color-border);
border-radius: var(--border-radius-large);
background: var(--color-main-background);
Expand All @@ -171,6 +191,7 @@ export default {
font-weight: bold;
white-space: normal;
word-wrap: anywhere;
margin-right: var(--default-clickable-area);

:deep(.material-design-icon) {
margin-bottom: auto;
Expand All @@ -181,6 +202,12 @@ export default {
color: var(--color-text-maxcontrast);
white-space: normal;
}

& &__delete-draft {
position: absolute;
top: var(--default-grid-baseline);
right: var(--default-grid-baseline);
}
}

.poll-closed {
Expand Down

0 comments on commit 72b5efb

Please sign in to comment.