Skip to content
Closed
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
7 changes: 7 additions & 0 deletions lib/Db/Option.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
* @method void setReleased(int $value)
* @method int getDeleted()
* @method void setDeleted(int $value)
* @method int getCreated()
* @method void setCreated(int $value)
* @method ?string getDescription()
* @method void setDescription(?string $value)
*
* No magic getters, getters are overwritten for special handling of timestamp and option text
* @method void setOrder(int $value)
Expand Down Expand Up @@ -70,6 +74,7 @@ class Option extends EntityWithUser implements JsonSerializable {
protected int $pollId = 0;
protected string $pollOptionText = '';
protected string $pollOptionHash = '';
protected ?string $description = '';
protected int $timestamp = 0;
protected int $duration = 0;
protected int $order = 0;
Expand All @@ -79,6 +84,7 @@ class Option extends EntityWithUser implements JsonSerializable {
protected string $owner = '';
protected int $released = 0;
protected int $deleted = 0;
protected int $created = 0;

// joined columns
protected ?string $userVoteAnswer = '';
Expand All @@ -104,6 +110,7 @@ public function __construct() {
$this->addType('duration', 'integer');
$this->addType('confirmed', 'integer');
$this->addType('deleted', 'integer');
$this->addType('created', 'integer');

// joined Attributes
$this->addType('optionLimit', 'integer');
Expand Down
2 changes: 2 additions & 0 deletions lib/Migration/V9/TableSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,8 @@ abstract class TableSchema {
'owner' => ['type' => Types::STRING, 'options' => ['notnull' => true, 'default' => '', 'length' => 256]],
'released' => ['type' => Types::BIGINT, 'options' => ['notnull' => true, 'default' => 0, 'length' => 20]],
'deleted' => ['type' => Types::BIGINT, 'options' => ['notnull' => true, 'default' => 0, 'length' => 20]],
'description' => ['type' => Types::TEXT, 'options' => ['notnull' => false, 'default' => null, 'length' => 65535]],
'created' => ['type' => Types::BIGINT, 'options' => ['notnull' => true, 'default' => 0, 'length' => 20]],
],
Vote::TABLE => [
'id' => ['type' => Types::BIGINT, 'options' => ['autoincrement' => true, 'notnull' => true, 'length' => 20]],
Expand Down
68 changes: 68 additions & 0 deletions src/components/VoteTable/VoteTableText.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<!--
- SPDX-FileCopyrightText: 2018 Nextcloud contributors
- SPDX-License-Identifier: AGPL-3.0-or-later
-->

<script setup lang="ts">
import { computed } from 'vue'

import { usePollStore } from '../../stores/poll'
import { useOptionsStore } from '../../stores/options'
import { useVotesStore } from '../../stores/votes'
import Counter from '../Options/Counter.vue'

const pollStore = usePollStore()
const optionsStore = useOptionsStore()
const votesStore = useVotesStore()

const tableStyle = computed(() => ({
'--participants-count': `${votesStore.chunkedParticipants.length}`,
'--options-count': `${optionsStore.options.length}`,
}))
</script>

<template>
<TransitionGroup
id="vote-table-text"
tag="div"
name="list"
:class="pollStore.viewMode"
class="vote-table-text"
:style="tableStyle">
<ul v-for="option in optionsStore.orderedOptions" :key="option.id">
<li class="option">
<div class="option__title">
{{ option.text }}
</div>
<div v-if="option.description" class="option__description">
{{ option.description }}
</div>
<Counter
v-if="pollStore.permissions.seeResults"
:id="`counter-${option.id}`"
:key="`counter-${option.id}`"
:class="{
confirmed: option.confirmed && pollStore.status.isExpired,
}"
:show-maybe="pollStore.configuration.allowMaybe"
:option="option" />
</li>
</ul>
</TransitionGroup>
</template>

<style lang="scss">
li.option {
display: flex;
flex-direction: column;
padding: 0.5em;
border-bottom: 1px solid var(--color-polls-border);
&__title {
font-weight: 500;
}
&__description {
font-size: 0.9em;
color: var(--color-polls-foreground-secondary);
}
}
</style>
4 changes: 1 addition & 3 deletions src/stores/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,7 @@ export const useOptionsStore = defineStore('options', {
try {
const response = await (() => {
if (activeRoute.value.meta.publicPage) {
return PublicAPI.getOptions(
sessionStore.publicToken,
)
return PublicAPI.getOptions(sessionStore.publicToken)
}
if (sessionStore.currentPollId) {
return OptionsAPI.getOptions(sessionStore.currentPollId)
Expand Down
2 changes: 2 additions & 0 deletions src/stores/options.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ export type OptionDto = {
id: number
pollId: number
text: string
description: string
isoTimestamp: string | null | undefined
created: number
deleted: number
order: number
confirmed: number
Expand Down
8 changes: 7 additions & 1 deletion src/views/Vote.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { usePreferencesStore } from '../stores/preferences'
import { useVotesStore } from '../stores/votes'
import type { CollapsibleProps } from '../components/Base/modules/Collapsible.vue'
import { Event } from '../Types'
import VoteTableText from '@/components/VoteTable/VoteTableText.vue'

const pollStore = usePollStore()
const optionsStore = useOptionsStore()
Expand Down Expand Up @@ -202,7 +203,12 @@ const appClass = computed(() => [
v-model="tableObserverVisible" />

<VoteTable
v-show="optionsStore.options.length"
v-show="pollStore.type === 'datePoll' && optionsStore.options.length"
class="area__vote"
:down-page="tableObserverVisible" />

<VoteTableText
v-show="pollStore.type === 'textPoll' && optionsStore.options.length"
class="area__vote"
:down-page="tableObserverVisible" />

Expand Down
Loading