Skip to content

Commit

Permalink
move some ctas from vote page to cards
Browse files Browse the repository at this point in the history
Signed-off-by: dartcafe <github@dartcafe.de>
  • Loading branch information
dartcafe committed Oct 15, 2023
1 parent 6c5d591 commit cccae7c
Show file tree
Hide file tree
Showing 4 changed files with 137 additions and 140 deletions.
2 changes: 1 addition & 1 deletion src/js/components/Actions/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export { default as ActionChangeView } from './modules/ActionChangeView.vue'
export { default as ActionDelete } from './modules/ActionDelete.vue'
export { default as ActionSendConfirmedOptions } from './modules/ActionSendConfirmedOptions.vue'
export { default as ActionSendConfirmed } from './modules/ActionSendConfirmed.vue'
export { default as ActionSortOptions } from './modules/ActionSortOptions.vue'
export { default as ActionToggleSidebar } from './modules/ActionToggleSidebar.vue'
113 changes: 113 additions & 0 deletions src/js/components/Actions/modules/ActionSendConfirmed.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
<!--
- @copyright Copyright (c) 2021 René Gieling <github@dartcafe.de>
-
- @author René Gieling <github@dartcafe.de>
-
- @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/>.
-
-->

<template>
<div class="action send-confirmations">
<NcButton v-tooltip="sendButtonCaption"
type="primary"
:aria-label="sendButtonCaption"
:disabled="disableButton"
@click="clickAction()">
<template #icon>
<EmailCheckIcon />
</template>
<template #default>
{{ t('polls', 'Send confirmation emails') }}
</template>
</NcButton>

<NcModal :show.sync="showModal"
:title="t('polls', 'Result of sent confirmation mails')"
size="small">
<div class="modal-confirmation-result">
<div v-if="confirmations?.countSentMails > 0" class="sent-confirmations">
<h2>{{ n('polls', '%n confirmation has been sent', '%n confirmations have been sent', confirmations.countSentMails) }}</h2>
<ul>
<li v-for="(item) in confirmations.sentMails" :key="item.displayName">
{{ item.displayName }} &lt;{{ item.emailAddress }}&gt;
</li>
</ul>
</div>
<div v-if="confirmations?.countAbortedMails > 0" class="error-confirmations">
<h2>{{ n('polls', '%n confirmation could not be sent', '%n confirmations could not be sent:', confirmations.countAbortedMails) }}</h2>
<ul>
<li v-for="(item) in confirmations.abortedMails" :key="item.displayName">
{{ item.displayName }} ({{ item.reason === 'InvalidMail' ? t('polls', 'No valid email address') : t('polls', 'Unknown error') }})
</li>
</ul>
</div>
</div>
</NcModal>
</div>
</template>

<script>
import { NcButton, NcModal } from '@nextcloud/vue'
import EmailCheckIcon from 'vue-material-design-icons/EmailCheck.vue' // view-comfy-outline
import { PollsAPI } from '../../../Api/index.js'

export default {
name: 'ActionSendConfirmed',

components: {
EmailCheckIcon,
NcButton,
NcModal,
},

data() {
return {
showModal: false,
sendButtonCaption: t('polls', 'Send information about confirmed options by email'),
confirmations: null,
disableButton: false,
}
},

methods: {
async clickAction() {
try {
this.disableButton = true
const result = await PollsAPI.sendConfirmation(this.$route.params.id)
this.disableButton = false
this.confirmations = result.data.confirmations
this.showModal = true
} catch (e) {
console.error(e)
}
},
},
}
</script>

<style lang="scss">
.modal-confirmation-result {
padding: 24px;
ul {
list-style: initial;
}

.sent-confirmations, .error-confirmations {
padding: 12px;
}
}
</style>
129 changes: 0 additions & 129 deletions src/js/components/Actions/modules/ActionSendConfirmedOptions.vue

This file was deleted.

33 changes: 23 additions & 10 deletions src/js/views/Vote.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,28 @@
</template>
</CardDiv>

<CardDiv v-if="closed" type="warning">
<CardDiv v-if="acl.allowAddOptions && proposalsOpen && !closed" type="success">
{{ t('polls', 'You are asked to propose more options. ') }}
<p v-if="proposalsExpirySet && !proposalsExpired">
{{ t('polls', 'The proposal period ends {timeRelative}', { timeRelative: proposalsExpireRelative }) }}
</p>
<OptionProposals v-if="poll.type === 'textPoll'" />
<template #button>
<OptionProposals v-if="poll.type === 'datePoll'" />
</template>
</CardDiv>

<CardDiv v-if="closed && !showConfirmationMail" type="warning">
{{ t('polls', 'This poll is closed. No further action is possible.') }}
</CardDiv>

<CardDiv v-else-if="showConfirmationMail" type="success">
{{ t('polls', 'You have confirmed options. Inform your participants about the result via email.') }}
<template #button>
<ActionSendConfirmed />
</template>
</CardDiv>

<CardDiv v-else-if="share.locked" type="warning">
{{ lockedShareCardCaption }}
</CardDiv>
Expand All @@ -55,13 +73,6 @@
<MarkUpDescription />
</div>

<div v-if="acl.allowAddOptions && proposalsOpen && !closed" class="area__proposal">
<OptionProposals />
</div>
<div v-if="showConfirmationMail" class="area__confirmation">
<ActionSendConfirmedOptions />
</div>

<div class="area__main" :class="viewMode">
<VoteTable v-show="options.length" :view-mode="viewMode" />

Expand Down Expand Up @@ -115,12 +126,12 @@ import PollHeaderButtons from '../components/Poll/PollHeaderButtons.vue'
import { CardDiv, HeaderBar } from '../components/Base/index.js'
import DatePollIcon from 'vue-material-design-icons/CalendarBlank.vue'
import TextPollIcon from 'vue-material-design-icons/FormatListBulletedSquare.vue'
import { ActionSendConfirmedOptions } from '../components/Actions/index.js'
import { ActionSendConfirmed } from '../components/Actions/index.js'

export default {
name: 'Vote',
components: {
ActionSendConfirmedOptions,
ActionSendConfirmed,
NcAppContent,
NcButton,
NcEmptyContent,
Expand Down Expand Up @@ -159,6 +170,8 @@ export default {
viewMode: 'poll/viewMode',
proposalsAllowed: 'poll/proposalsAllowed',
proposalsOpen: 'poll/proposalsOpen',
proposalsExpirySet: 'poll/proposalsExpirySet',
proposalsExpireRelative: 'poll/proposalsExpireRelative',
countHiddenParticipants: 'poll/countHiddenParticipants',
safeTable: 'poll/safeTable',
confirmedOptions: 'options/confirmed',
Expand Down

0 comments on commit cccae7c

Please sign in to comment.