Skip to content
Merged
Show file tree
Hide file tree
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
10 changes: 10 additions & 0 deletions lib/Db/Poll.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ public function getConfigurationArray(): array {
'allowProposals' => $this->getAllowProposals(),
'anonymous' => boolval($this->getAnonymous()),
'autoReminder' => $this->getAutoReminder(),
'collapseDescription' => $this->getCollapseDescription(),
'description' => $this->getDescription(),
'expire' => $this->getExpire(),
'hideBookedUp' => boolval($this->getHideBookedUp()),
Expand Down Expand Up @@ -322,6 +323,7 @@ public function deserializeArray(array $pollConfiguration): self {
$this->setAllowProposals($pollConfiguration['allowProposals'] ?? $this->getAllowProposals());
$this->setAnonymousSafe($pollConfiguration['anonymous'] ?? $this->getAnonymous());
$this->setAutoReminder($pollConfiguration['autoReminder'] ?? $this->getAutoReminder());
$this->setCollapseDescription($pollConfiguration['collapseDescription'] ?? $this->getCollapseDescription());
$this->setExpire($pollConfiguration['expire'] ?? $this->getExpire());
$this->setHideBookedUp($pollConfiguration['hideBookedUp'] ?? $this->getHideBookedUp());
$this->setProposalsExpire($pollConfiguration['proposalsExpire'] ?? $this->getProposalsExpire());
Expand Down Expand Up @@ -389,10 +391,18 @@ private function setAutoReminder(bool|int $value): void {
$this->setMiscSettingsByKey('autoReminder', (bool)$value);
}

private function setCollapseDescription(bool|int $value): void {
$this->setMiscSettingsByKey('collapseDescription', (bool)$value);
}

private function getAutoReminder(): bool {
return $this->getMiscSettingsArray()['autoReminder'] ?? false;
}

private function getCollapseDescription(): bool {
return $this->getMiscSettingsArray()['collapseDescription'] ?? true;
}

// alias of getId()
public function getPollId(): int {
return $this->getId();
Expand Down
8 changes: 7 additions & 1 deletion lib/Model/UserBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,13 @@ public function getIsGuest(): bool {
* used for telling internal from guest users
*/
public function getSimpleType(): string {
return in_array($this->type, [User::TYPE, Admin::TYPE]) ? self::TYPE_USER : self::TYPE_GUEST;
if (in_array($this->type, [User::TYPE, Admin::TYPE])) {
return self::TYPE_USER;
} elseif ($this->type === Ghost::TYPE) {
return self::TYPE_GHOST;
}

return self::TYPE_GUEST;
}

public function getLanguageCode(): string {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Actions/modules/ActionAddOption.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import NcButton from '@nextcloud/vue/components/NcButton'
import AddDateIcon from 'vue-material-design-icons/CalendarPlus.vue'
import { Event } from '../../../Types'

const caption = defineProps<{ caption?: string }>()
const { caption } = defineProps<{ caption?: string }>()
const buttonAriaLabel = computed(() => caption ?? t('polls', 'Add option'))

async function clickAction() {
Expand Down
36 changes: 12 additions & 24 deletions src/components/Base/modules/Collapsible.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,76 +4,63 @@
-->

<script setup lang="ts">
import { t } from '@nextcloud/l10n'
import { ref } from 'vue'

interface Props {
initialCollapsed?: boolean
noCollapse?: boolean
showMoreCaption?: string
closeCaption?: string
}
const {
initialCollapsed = false,
noCollapse = false,
showMoreCaption = t('polls', 'Show more'),
closeCaption = t('polls', 'Collapse'),
} = defineProps<Props>()
const { initialCollapsed = false, noCollapse = false } = defineProps<Props>()

const showMore = ref(!initialCollapsed || noCollapse)
</script>

<template>
<div class="collapsible">
<div
v-show="!noCollapse"
:class="['collapsible-toggle', { open: showMore }]"
@click="showMore = !showMore"></div>
<div
id="collapsible_container"
:class="['collapsible_container', { open: showMore || noCollapse }]">
<slot />
</div>
<div
v-show="!noCollapse"
:class="['collapsible-toggle', { open: showMore }]"
@click="showMore = !showMore">
{{ showMore ? closeCaption : showMoreCaption }}
</div>
</div>
</template>

<style lang="scss">
.collapsible {
overflow: hidden;
display: flex;

.collapsible-toggle {
cursor: pointer;
position: relative;
line-height: 2rem;
font-weight: bold;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 100%;
background-color: var(--color-background-plain);
color: var(--color-primary-element-text);
border-radius: var(--border-radius-element);
padding: 0.5rem 1rem;

&::before {
content: '\25B8';
font-size: 1.5rem;
margin: 0 0.3em;
display: inline-block;
transform: rotate(90deg);
transition: transform 0.3s ease-in-out;
}
&.open {
&::before {
transform: rotate(-90deg);
transform: rotate(90deg);
}
}
}

.collapsible_container {
transition: max-height 0.3s ease-in-out;
overflow: auto;
max-height: 0;
max-height: 6rem;
overflow: hidden;

background:
/* Shadow covers */
Expand Down Expand Up @@ -137,6 +124,7 @@ const showMore = ref(!initialCollapsed || noCollapse)

&.open {
max-height: max(51vh, 6rem);
overflow: auto;
}
}
}
Expand Down
8 changes: 8 additions & 0 deletions src/components/Configuration/ConfigDescription.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
-->

<script setup lang="ts">
import { NcCheckboxRadioSwitch } from '@nextcloud/vue'
import { usePollStore } from '../../stores/poll.ts'
import { t } from '@nextcloud/l10n'
const pollStore = usePollStore()
</script>

Expand All @@ -13,6 +15,12 @@ const pollStore = usePollStore()
v-model="pollStore.configuration.description"
class="edit-description"
@change="pollStore.write()" />
<NcCheckboxRadioSwitch
v-model="pollStore.configuration.collapseDescription"
type="switch"
@update:model-value="pollStore.write()">
{{ t('polls', 'Collapse long descriptions') }}
</NcCheckboxRadioSwitch>
</template>

<style lang="scss">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,13 @@ const pollStore = usePollStore()
<!-- eslint-disable vue/no-v-html -->
<div
ref="desc"
class="markup-description"
v-html="pollStore.descriptionMarkUp" />
class="markdown-description"
v-html="pollStore.descriptionMarkDown" />
<!-- eslint-enable vue/no-v-html -->
</template>

<style lang="scss">
.markup-description {
padding: 0.5rem;
margin: 0.25rem;
.markdown-description {
overflow: auto;

* {
Expand All @@ -29,9 +27,7 @@ const pollStore = usePollStore()
text-decoration: revert;
list-style: inside;
}
}

.markup-description {
table {
border-spacing: 2px;
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/Shares/SharesList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import ShareItem from './ShareItem.vue'
import UserSearch from '../User/UserSearch.vue'
import SharePublicAdd from './SharePublicAdd.vue'
import ShareItemAllUsers from './ShareItemAllUsers.vue'
import MarkUpDescription from '../Poll/MarkUpDescription.vue'
import MarkDownDescription from '../Poll/MarkDownDescription.vue'

import { usePollStore } from '../../stores/poll.ts'
import { useSharesStore, Share } from '../../stores/shares.ts'
Expand Down Expand Up @@ -91,7 +91,7 @@ async function addShare(user: User) {
:encode-text="qrText"
class="modal__content">
<template #description>
<MarkUpDescription />
<MarkDownDescription />
</template>
</QrModal>
</NcModal>
Expand Down
13 changes: 4 additions & 9 deletions src/components/SideBar/SideBarTabConfiguration.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,12 @@ const votesStore = useVotesStore()

<template>
<div>
<CardDiv v-if="votesStore.hasVotes" type="warning">
{{
t(
'polls',
'Please be careful when changing options, because it can affect existing votes in an unwanted manner.',
)
}}
<CardDiv v-if="!pollStore.currentUserStatus.isOwner" type="success">
{{ t('polls', 'Administrative rights are delegated to you.') }}
</CardDiv>

<CardDiv v-if="!pollStore.currentUserStatus.isOwner" type="success">
{{ t('polls', 'As an admin you may edit this poll') }}
<CardDiv v-if="votesStore.hasVotes" type="warning">
{{ t('polls', 'Changes may affect existing votes.') }}
</CardDiv>

<ConfigBox :name="t('polls', 'Title')">
Expand Down
2 changes: 1 addition & 1 deletion src/components/User/UserSearch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ interface Props {

const emit = defineEmits(['userSelected'])

const modelValue = defineModel<User | null>({ required: true })
const modelValue = defineModel<User | null>()

const {
placeholder = t('polls', 'Type to start searching ...'),
Expand Down
4 changes: 3 additions & 1 deletion src/stores/poll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export type PollConfiguration = {
allowProposals: AllowProposals
anonymous: boolean
autoReminder: boolean
collapseDescription: boolean
description: string
expire: number
hideBookedUp: boolean
Expand Down Expand Up @@ -178,6 +179,7 @@ export const usePollStore = defineStore('poll', {
allowProposals: AllowProposals.Disallow,
anonymous: false,
autoReminder: false,
collapseDescription: true,
expire: 0,
hideBookedUp: false,
proposalsExpire: 0,
Expand Down Expand Up @@ -374,7 +376,7 @@ export const usePollStore = defineStore('poll', {
return this.countParticipants * optionsStore.count
},

descriptionMarkUp(): string {
descriptionMarkDown(): string {
marked.use(gfmHeadingId(markedPrefix))
return DOMPurify.sanitize(
marked.parse(this.configuration.description).toString(),
Expand Down
19 changes: 13 additions & 6 deletions src/views/Vote.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import DatePollIcon from 'vue-material-design-icons/CalendarBlank.vue'
import TextPollIcon from 'vue-material-design-icons/FormatListBulletedSquare.vue'

import { useHandleScroll } from '../composables/handleScroll.ts'
import MarkUpDescription from '../components/Poll/MarkUpDescription.vue'
import MarkDownDescription from '../components/Poll/MarkDownDescription.vue'
import ActionAddOption from '../components/Actions/modules/ActionAddOption.vue'
import PollInfoLine from '../components/Poll/PollInfoLine.vue'
import PollHeaderButtons from '../components/Poll/PollHeaderButtons.vue'
Expand All @@ -32,7 +32,7 @@ import {

import { usePollStore, PollType } from '../stores/poll.ts'
import { useOptionsStore } from '../stores/options.ts'
import { usePreferencesStore } from '../stores/preferences.ts'
import { usePreferencesStore, ViewMode } from '../stores/preferences.ts'
import { Event } from '../Types/index.ts'
import Collapsible from '../components/Base/modules/Collapsible.vue'

Expand Down Expand Up @@ -115,10 +115,13 @@ onUnmounted(() => {
<div class="vote_main">
<Collapsible
v-if="pollStore.configuration.description"
:show-more-caption="pollStore.configuration.description"
:no-collapse="isShortDescription"
:show-more-caption="t('polls', 'Show full description')"
:no-collapse="
isShortDescription
|| !pollStore.configuration.collapseDescription
"
:initial-collapsed="!!pollStore.currentUserStatus.countVotes">
<MarkUpDescription />
<MarkDownDescription />
</Collapsible>

<VoteInfoCards />
Expand All @@ -141,7 +144,11 @@ onUnmounted(() => {
</NcEmptyContent>

<div class="area__footer">
<CardHiddenParticipants v-if="pollStore.countHiddenParticipants" />
<CardHiddenParticipants
v-if="
pollStore.countHiddenParticipants
&& pollStore.viewMode !== ViewMode.ListView
" />
<CardAnonymousPollHint v-if="pollStore.status.isAnonymous" />
</div>
</div>
Expand Down