Skip to content

Commit b58292b

Browse files
author
philippe lhardy
committed
support nullable chosenRank
- don't parse chosenRank for non generic variant - delegate to existing getChosenRank of getters - set default table column chosen_rank to null - set default chosenRank to json empty array Signed-off-by: philippe lhardy <[email protected]>
1 parent fb374d1 commit b58292b

File tree

4 files changed

+5
-4
lines changed

4 files changed

+5
-4
lines changed

lib/Db/Poll.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ class Poll extends EntityWithUser implements JsonSerializable {
151151
protected string $access = '';
152152
protected int $anonymous = 0;
153153
protected int $allowMaybe = 0;
154-
protected string $chosenRank = '';
154+
protected string $chosenRank = '[]';
155155
protected string $allowProposals = '';
156156
protected int $proposalsExpire = 0;
157157
protected int $voteLimit = 0;

lib/Migration/V2/TableSchema.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ abstract class TableSchema {
247247
'access' => ['type' => Types::STRING, 'options' => ['notnull' => true, 'default' => 'private', 'length' => 1024]],
248248
'anonymous' => ['type' => Types::BIGINT, 'options' => ['notnull' => true, 'default' => 0, 'length' => 20]],
249249
'allow_maybe' => ['type' => Types::BIGINT, 'options' => ['notnull' => true, 'default' => 1, 'length' => 20]],
250-
'chosen_rank' => ['type' => Types::TEXT, 'options' => ['notnull' => false, 'default' => '', 'length' => 200]],
250+
'chosen_rank' => ['type' => Types::TEXT, 'options' => ['notnull' => false, 'default' => null, 'length' => 200]],
251251
'allow_proposals' => ['type' => Types::STRING, 'options' => ['notnull' => true, 'default' => 'disallow', 'length' => 64]],
252252
'proposals_expire' => ['type' => Types::BIGINT, 'options' => ['notnull' => true, 'default' => 0, 'length' => 20]],
253253
'vote_limit' => ['type' => Types::BIGINT, 'options' => ['notnull' => true, 'default' => 0, 'length' => 20]],

src/components/VoteTable/VoteButton.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ const vote = computed(() =>
4848
}),
4949
)
5050
51-
const chosenRank = JSON.parse(pollStore.configuration.chosenRank)
51+
const chosenRank =
52+
pollStore.votingVariant === 'generic' ? pollStore.getChosenRank : null
5253
5354
const nextAnswer = computed<richAnswer>(() => {
5455
if (['no', ''].includes(vote.value.answer)) {

src/stores/poll.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ export const usePollStore = defineStore('poll', {
151151
getChosenRank(): string[] {
152152
try {
153153
const parsed = JSON.parse(this.configuration.chosenRank || '[]')
154-
return Array.isArray(parsed) ? parsed : []
154+
return Array.isArray(parsed) ? parsed : DEFAULT_CHOSEN_RANK
155155
} catch {
156156
return DEFAULT_CHOSEN_RANK
157157
}

0 commit comments

Comments
 (0)