205stelzear / elections

Website / Webapp to create and view elections for any Scout group
https://205stelzear-elections.v-ed.ca/
MIT License
0 stars 0 forks source link

Add possibility to delete selected candidate instead of only the last one inserted #67

Closed V-ed closed 4 years ago

V-ed commented 4 years ago

I can see this being useful in a case where one of the candidates decides at the last second to not be a candidate anymore. Kids can change their mind after all!

I would put an x button next to each candidate text field which would allow to delete this one.

On mobile, it would probably also be on the same line - or should it be next to the label? I'll try few designs for the mobile version, we'll see how it goes

The issue I foresee is the way I will remove the divs from the code, as each candidate field as its own id associated with it : what I may do might be a trickery instead :

  1. Get a map of all the candidates added below the one selected to be deleted
  2. Set each fields (starting from the candidate to be deleted) to the map gotten at step one, going down. At this point, the last candidate shown will be seen twice;
  3. remove the last field, therefore removing the now duplicated last candidate.
  4. trigger all validations? dunno if that step will be needed, I'll see
  5. ???
  6. Profit.

The problem with removing the selected div directly is also that the "Candidat #" label won't be updated, so it'll jump for example from Candidat 1 to Candidat 3.

Finally, I'll remove the "Delete last candidate" button, as it won't be useful anymore after that. This change may also fix a little accessibility issue with the remove last candidate button, as currently, it is on the right in the >= md version, while being on the left in the sm version... I originally did so because it is easier with the right hand thumb to press "Add candidate" if it's on the right instead of the left, but this problem isn't there on wider screen.

V-ed commented 4 years ago

Finally, I'll remove the "Delete last candidate" button, as it won't be useful anymore after that.

While true, it could be changed to "Delete all candidates" instead, which would be quite better. A confirmation would definitely required to perform that action though.