-
Notifications
You must be signed in to change notification settings - Fork 505
feat(poll): improve poll card and dialog UI #16137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
DorraJaouad
wants to merge
1
commit into
main
Choose a base branch
from
feat/noid/enhance-poll-layout
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,14 +11,45 @@ | |
| @close="dismissModal"> | ||
| <div v-if="poll" class="poll-modal"> | ||
| <div class="poll-modal__header"> | ||
| <IconPoll :size="20" /> | ||
| <IconPoll :size="25" /> | ||
| <span :id="dialogHeaderId" role="heading" aria-level="2"> | ||
| {{ name }} | ||
| </span> | ||
| </div> | ||
| <p class="poll-modal__summary"> | ||
| {{ pollSummaryText }} | ||
| </p> | ||
| <div class="poll-modal__summary"> | ||
| <div class="poll-modal__summary-details"> | ||
| <span> | ||
| {{ pollSummaryText }} | ||
| </span> | ||
| <NcPopover | ||
| v-if="!isPollPublic" | ||
| placement="bottom" | ||
| :triggers="['hover']"> | ||
| <template #trigger> | ||
| <NcButton variant="tertiary-no-background" :aria-label="t('spreed', 'Anonymous poll information')"> | ||
| <template #icon> | ||
| <IconInformationOutline :size="16" /> | ||
| </template> | ||
| </NcButton> | ||
| </template> | ||
| <template #default> | ||
| <span class="poll-popover__text"> | ||
| {{ t('spreed', 'This poll is anonymous, identities of voters are hidden from everyone.') }} | ||
| </span> | ||
| </template> | ||
| </NcPopover> | ||
| </div> | ||
| <div | ||
| v-if="isPollOpen" | ||
| class="poll-modal__hint"> | ||
| <span v-if="!isMultipleAnswers"> | ||
| {{ t('spreed', 'You can select only one answer') }} | ||
| </span> | ||
| <span v-else> | ||
| {{ t('spreed', 'You can select multiple answers') }} | ||
| </span> | ||
| </div> | ||
| </div> | ||
|
|
||
| <!-- options --> | ||
| <div v-if="modalPage === 'voting'" class="poll-modal__options"> | ||
|
|
@@ -68,18 +99,10 @@ | |
| <div v-if="isPollOpen" class="poll-modal__actions"> | ||
| <!-- Submit vote button--> | ||
| <NcButton | ||
| v-if="modalPage === 'voting'" | ||
| variant="primary" | ||
| :disabled="disabled" | ||
| @click="submitVote"> | ||
| {{ t('spreed', 'Submit vote') }} | ||
| </NcButton> | ||
| <!-- Vote again--> | ||
| <NcButton | ||
| v-else | ||
| variant="secondary" | ||
| @click="modalPage = 'voting'"> | ||
| {{ t('spreed', 'Change your vote') }} | ||
| {{ !selfHasVoted ? t('spreed', 'Submit vote') : t('spreed', 'Change your vote') }} | ||
| </NcButton> | ||
| <NcActions v-if="canEndPoll" force-menu> | ||
| <NcActionButton v-if="supportPollDrafts && isModerator" @click="createPollDraft"> | ||
|
|
@@ -134,11 +157,13 @@ import NcCheckboxRadioSwitch from '@nextcloud/vue/components/NcCheckboxRadioSwit | |
| import NcIconSvgWrapper from '@nextcloud/vue/components/NcIconSvgWrapper' | ||
| import NcLoadingIcon from '@nextcloud/vue/components/NcLoadingIcon' | ||
| import NcModal from '@nextcloud/vue/components/NcModal' | ||
| import NcPopover from '@nextcloud/vue/components/NcPopover' | ||
| import NcProgressBar from '@nextcloud/vue/components/NcProgressBar' | ||
| import IconPoll from 'vue-material-design-icons/ChartBoxOutline.vue' | ||
| import IconCheck from 'vue-material-design-icons/Check.vue' | ||
| import IconFileEditOutline from 'vue-material-design-icons/FileEditOutline.vue' | ||
| import IconFileLockOutline from 'vue-material-design-icons/FileLockOutline.vue' | ||
| import IconPoll from 'vue-material-design-icons/Poll.vue' | ||
| import IconInformationOutline from 'vue-material-design-icons/InformationOutline.vue' | ||
| import PollVotersDetails from './PollVotersDetails.vue' | ||
| import IconFileDownload from '../../../img/material-icons/file-download.svg?raw' | ||
| import { useIsInCall } from '../../composables/useIsInCall.js' | ||
|
|
@@ -162,13 +187,15 @@ export default { | |
| NcModal, | ||
| NcButton, | ||
| NcIconSvgWrapper, | ||
| NcPopover, | ||
| NcProgressBar, | ||
| PollVotersDetails, | ||
| // icons | ||
| IconCheck, | ||
| IconFileLockOutline, | ||
| IconFileEditOutline, | ||
| IconPoll, | ||
| IconInformationOutline, | ||
| }, | ||
|
|
||
| setup() { | ||
|
|
@@ -210,6 +237,7 @@ export default { | |
| supportPollDrafts, | ||
| exportPollURI, | ||
| exportPollFileName, | ||
| POLL, | ||
| } | ||
| }, | ||
|
|
||
|
|
@@ -245,7 +273,14 @@ export default { | |
| }, | ||
|
|
||
| disabled() { | ||
| return this.loading || this.voteToSubmit.length === 0 | ||
| return (this.loading || this.voteToSubmit.length === 0 // no option is selected or it is loading | ||
| || (this.selfHasVoted && this.isSameVote)) // user has voted and did not change the vote | ||
| && (this.modalPage !== 'results' || !this.isPollPublic) // if results are shown, allow changing vote for public polls | ||
| }, | ||
|
|
||
| isSameVote() { | ||
| return this.voteToSubmit.length === this.poll?.votedSelf.length | ||
| && this.voteToSubmit.every((val) => this.poll?.votedSelf.includes(+val)) | ||
| }, | ||
|
|
||
| isModerator() { | ||
|
|
@@ -259,18 +294,14 @@ export default { | |
|
|
||
| pollSummaryText() { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe don't change these strings? They feel more confusing to me
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what do you mean confusing? |
||
| if (this.isPollClosed) { | ||
| return n('spreed', 'Poll results • %n vote', 'Poll results • %n votes', this.poll?.numVoters) | ||
| } | ||
|
|
||
| if (this.isPollPublic && (this.selfIsOwnerOrModerator || this.selfHasVoted)) { | ||
| return n('spreed', 'Open poll • %n vote', 'Open poll • %n votes', this.poll?.numVoters) | ||
| return n('spreed', 'Final results • %n vote', 'Final results • %n votes', this.poll?.numVoters) | ||
| } | ||
|
|
||
| if (!this.isPollPublic && this.selfHasVoted) { | ||
| return t('spreed', 'Open poll • You voted already') | ||
| if (this.selfIsOwnerOrModerator || (this.selfHasVoted && this.isPollPublic)) { | ||
Antreesy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return n('spreed', 'Poll open • %n vote', 'Poll open • %n votes', this.poll?.numVoters) | ||
| } | ||
|
|
||
| return t('spreed', 'Open poll') | ||
| return 'Poll open' | ||
| }, | ||
|
|
||
| canEndPoll() { | ||
|
|
@@ -309,7 +340,7 @@ export default { | |
| handler(value) { | ||
| if (!value) { | ||
| this.modalPage = '' | ||
| } else if (this.selfHasVoted || this.isPollClosed) { | ||
| } else if (this.isPollClosed || (this.isPollPublic && this.selfHasVoted)) { | ||
| this.modalPage = 'results' | ||
| } else { | ||
| this.modalPage = 'voting' | ||
|
|
@@ -358,17 +389,23 @@ export default { | |
| }, | ||
|
|
||
| async submitVote() { | ||
| if (this.modalPage !== 'voting') { | ||
| this.modalPage = 'voting' | ||
| return | ||
| } | ||
|
|
||
| this.loading = true | ||
| try { | ||
| await this.pollsStore.submitVote({ | ||
| token: this.token, | ||
| pollId: this.id, | ||
| optionIds: this.voteToSubmit.map((element) => +element), | ||
| }) | ||
| this.modalPage = 'results' | ||
| if (this.isPollPublic) { | ||
| this.modalPage = 'results' | ||
| } | ||
| } catch (error) { | ||
| console.error(error) | ||
| this.modalPage = 'voting' | ||
| } | ||
| this.loading = false | ||
| }, | ||
|
|
@@ -408,7 +445,7 @@ export default { | |
| <style lang="scss" scoped> | ||
| .poll-modal { | ||
| position: relative; | ||
| padding: 20px; | ||
| padding: calc(3 * var(--default-grid-baseline)); | ||
|
|
||
| &__header { | ||
| display: flex; | ||
|
|
@@ -419,15 +456,17 @@ export default { | |
| font-size: 18px; | ||
| white-space: normal; | ||
| word-wrap: anywhere; | ||
|
|
||
| :deep(.material-design-icon) { | ||
| margin-bottom: auto; | ||
| } | ||
| } | ||
|
|
||
| &__summary { | ||
| color: var(--color-text-maxcontrast); | ||
| margin-bottom: 16px; | ||
|
|
||
| &-details { | ||
| display: flex; | ||
| align-items: center; | ||
| gap: var(--default-grid-baseline); | ||
| } | ||
| } | ||
|
|
||
| &__options { | ||
|
|
@@ -450,6 +489,12 @@ export default { | |
| &__loading { | ||
| height: 200px; | ||
| } | ||
|
|
||
| &__hint { | ||
| display: flex; | ||
| align-items: center; | ||
| gap: var(--default-grid-baseline); | ||
| } | ||
| } | ||
|
|
||
| .results__options { | ||
|
|
@@ -463,9 +508,11 @@ export default { | |
| .results__option { | ||
| display: flex; | ||
| flex-direction: column; | ||
| padding: var(--default-grid-baseline); | ||
| border-radius: var(--border-radius-large); | ||
|
|
||
| &:not(:last-child) { | ||
| border-bottom: 1px solid var(--color-border); | ||
| &:hover { | ||
| background-color: var(--color-background-hover); | ||
| } | ||
|
|
||
| &__details { | ||
|
|
@@ -496,6 +543,14 @@ export default { | |
| } | ||
| } | ||
|
|
||
| .poll-popover__text { | ||
| display: block; | ||
| padding: calc(var(--default-grid-baseline) / 2); | ||
| max-width: 250px; | ||
| text-align: center; | ||
| color: var(--color-text-maxcontrast); | ||
| } | ||
|
|
||
| .critical :deep(.action-button) { | ||
| color: var(--color-text-error) !important; | ||
| } | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.