pik-gane / vodle

We develop an interactive, consensus-oriented group decision app
https://twitter.com/vodle_it
GNU Affero General Public License v3.0
25 stars 16 forks source link

require options to be unique within same poll #181

Closed wjk36 closed 2 years ago

wjk36 commented 2 years ago

Currently user can enter the same option twice for the same poll. Maybe display a warning and disable 'ready' button when two options are non-unique.

Screen Shot 2022-08-13 at 8 14 50 PM
mensch72 commented 2 years ago

Thank you @wjk36, this is an obvious bug I should have seen earlier! To fix it, we need to add another validator in the respective forms in the draftpoll and addoption-dialog components, plus corresponding error messages.

semla commented 2 years ago

It is a start; added a custom validator, in its own file since it should be used in the addoption-dialog too. But haven't wrapped my head around that component, when is it used?

Other opinions?

Edit: saw that the addoption-dialog is for adding options after the poll has started. Unfortunately this component seems to not know about the added options array.

mensch72 commented 2 years ago

I managed to add the validator also to addoption-dialog now, using: unique_name_validator$(of(this.p.oids.map(oid => this.p.options[oid].name)))