diff --git a/src/components/form/ButtonWithConfirm.js b/src/components/form/ButtonWithConfirm.js index e5373a2..7b16ca7 100644 --- a/src/components/form/ButtonWithConfirm.js +++ b/src/components/form/ButtonWithConfirm.js @@ -38,6 +38,7 @@ class ButtonWithConfirm extends Component { type="button" className={classNameForButton} onClick={() => { this._modalConfirm.current.toggle() }} + tabIndex={this.props.tabIndex} >{this.getComponent("button")} diff --git a/src/components/views/CreateElection.js b/src/components/views/CreateElection.js index e60ad27..713fc0a 100644 --- a/src/components/views/CreateElection.js +++ b/src/components/views/CreateElection.js @@ -11,7 +11,8 @@ import { Button } from 'reactstrap'; -import {ToastContainer} from 'react-toastify'; +import {toast, ToastContainer} from 'react-toastify'; +import 'react-toastify/dist/ReactToastify.css'; import HelpButton from "../form/HelpButton"; import {arrayMove, sortableContainer, sortableElement, sortableHandle} from 'react-sortable-hoc'; import ButtonWithConfirm from "../form/ButtonWithConfirm"; @@ -21,6 +22,10 @@ import {faPlus, faTrashAlt, faCheck } from '@fortawesome/free-solid-svg-icons'; +//TOOD : variable de config dans un fichier à part (avec les mentions, le min/max de mentions, le nombre max de candidats, les maxlength,l'url api, etc ...) +const mentions = ["Excellent","Trés Bien","Bien","Assez Bien","Passable","Insuffisant","A Rejeter"]; + + const DragHandle = sortableHandle(({children}) => {children}); const SortableCandidate = sortableElement(({candidate, sortIndex, form}) =>
  • @@ -71,8 +76,11 @@ class CreateElection extends Component { super(props); this.state = { candidates:[{label:""},{label:""}], + nbCandidatesWithLabel:0, title:null, - isVisibleTipsDragAndDropCandidate:true + isVisibleTipsDragAndDropCandidate:true, + nbMentions:7 + }; this.candidateInputs = []; @@ -109,8 +117,14 @@ class CreateElection extends Component { editCandidateLabel = (event, index) => { let candidates = this.state.candidates; + let nbLabels = 0; candidates[index].label = event.currentTarget.value; - this.setState({candidates: candidates}); + candidates.map((candidate,i)=>{ + if(candidate.label!==""){ + nbLabels++; + } + }); + this.setState({candidates: candidates, nbCandidatesWithLabel:nbLabels}); }; @@ -137,14 +151,23 @@ class CreateElection extends Component { event.preventDefault(); }; + handleChangeNbMentions= (event) => { + this.setState({nbMentions: event.target.value}); + }; + componentWillMount() { const params = new URLSearchParams(this.props.location.search); this.setState({title:params.get("title")?params.get("title"):""}); - } + }; - render(){ + handleSendWithoutCandidate = () => { + toast.error("Vous devez saisir au moins deux candidats !", { + position: toast.POSITION.TOP_CENTER + }); + }; + render(){ const params = new URLSearchParams(this.props.location.search); return( @@ -187,35 +210,64 @@ class CreateElection extends Component { + + + + + + + + + + Vous pouvez choisir ici le nombre de mentions pour votre vote +
    Par exemple : 5 = Excellent, Très bien, bien, assez bien, passable +
    + + + { mentions.map((mention,i) => { + return {mention} + }) + } + + +

    - + {this.state.nbCandidatesWithLabel>=2?
    Valider
    -
    Confirmation
    +
    Confirmez votre vote
    -
    Voici votre vote :
    -
    -

    {this.state.title}

    -
      +
      +
      Question du vote :
      +
      {this.state.title}
      +
      Candidats/Propositions :
      +
        { - this.state.candidates.map((candidate,i) => { if(candidate.label!==""){ - return
      • {candidate.label}
      • + return
      • {candidate.label}
      • }else{ return
      • } }) } -
      +
    +
    Mentions :
    +
    { mentions.map((mention,i) => { + return (i{mention}: + }) + }
    -

    Une fois validé, vous ne pourrez plus le modifier, souhaitez-vous continuer ?

    -
    {}}>Oui
    -
    Non
    -
    +
    {}}>Lancer le vote
    +
    Annuler
    +
    :}