mirror of
https://github.com/siv-org/siv.git
synced 2026-05-03 03:00:59 -04:00
vote: RCV should never allow more rankings than options
This commit is contained in:
@@ -3,7 +3,7 @@ import { useRouter } from 'next/router'
|
||||
import { Fragment, useEffect, useState } from 'react'
|
||||
import { CipherStrings } from 'src/crypto/stringify-shuffle'
|
||||
import { EncryptedVote } from 'src/protocol/EncryptedVote'
|
||||
import { defaultRankingsAllowed } from 'src/vote/RankedChoiceItem'
|
||||
import { defaultRankingsAllowed } from 'src/vote/Ballot'
|
||||
|
||||
import { Item } from '../vote/storeElectionInfo'
|
||||
import { TotalVotesCast } from './TotalVotesCast'
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { orderBy } from 'lodash-es'
|
||||
import { flatten } from 'lodash-es'
|
||||
import { defaultRankingsAllowed } from 'src/vote/RankedChoiceItem'
|
||||
import { defaultRankingsAllowed } from 'src/vote/Ballot'
|
||||
|
||||
import { unTruncateSelection } from './un-truncate-selection'
|
||||
import { useDecryptedVotes } from './use-decrypted-votes'
|
||||
|
||||
@@ -11,6 +11,7 @@ import { State } from './vote-state'
|
||||
// Calculate maximum write-in string length
|
||||
const verification_num_length = 15
|
||||
export const max_string_length = maxLength - verification_num_length
|
||||
export const defaultRankingsAllowed = 3
|
||||
|
||||
export const Ballot = ({
|
||||
dispatch,
|
||||
@@ -64,6 +65,7 @@ export const Ballot = ({
|
||||
{...{
|
||||
...item,
|
||||
dispatch,
|
||||
rankings_allowed: Math.min(defaultRankingsAllowed, max_options),
|
||||
state,
|
||||
}}
|
||||
key={index}
|
||||
|
||||
@@ -6,21 +6,19 @@ import { Label, TitleDescriptionQuestion } from './Item'
|
||||
import { Item as ItemType } from './storeElectionInfo'
|
||||
import { State } from './vote-state'
|
||||
|
||||
export const defaultRankingsAllowed = 3
|
||||
|
||||
export const RankedChoiceItem = ({
|
||||
description,
|
||||
dispatch,
|
||||
id = 'vote',
|
||||
options,
|
||||
question,
|
||||
rankings_allowed = defaultRankingsAllowed,
|
||||
rankings_allowed,
|
||||
state,
|
||||
title,
|
||||
}: ItemType & {
|
||||
dispatch: Dispatch<Record<string, string>>
|
||||
election_id?: string
|
||||
rankings_allowed?: number
|
||||
rankings_allowed: number
|
||||
state: State
|
||||
}): JSX.Element => {
|
||||
// console.log(state.plaintext)
|
||||
|
||||
@@ -3,7 +3,7 @@ import { flatten } from 'lodash-es'
|
||||
import Link from 'next/link'
|
||||
import { useEffect } from 'react'
|
||||
|
||||
import { defaultRankingsAllowed } from '../RankedChoiceItem'
|
||||
import { defaultRankingsAllowed } from '../Ballot'
|
||||
import { State } from '../vote-state'
|
||||
import { DetailedEncryptionReceipt } from './DetailedEncryptionReceipt'
|
||||
import { EncryptedVote } from './EncryptedVote'
|
||||
|
||||
Reference in New Issue
Block a user