Commit 9d3b8679 authored by Stephane Glondu's avatar Stephane Glondu

Disable homomorphic checkbox when NH questions are not allowed

parent a51a270c
Pipeline #74545 passed with stages
in 16 minutes and 56 seconds
......@@ -216,6 +216,8 @@ let rec createQuestionDiv question answers props =
Dom.replaceChild container prop_div_nh prop_div_h
in
cb_type##.onchange := handler f;
if not (Js.to_bool (Js.Unsafe.pure_js_expr "allow_nh")) then
cb_type##.disabled := Js._true;
Dom.appendChild x cb_type;
Dom.appendChild x (document##createTextNode (Js.string "Homomorphic tally"));
(* answers *)
......
......@@ -419,6 +419,14 @@ let get_suitable_group_kind {t_questions; _} =
) t_questions;
!group
let is_group_fixed se =
se.se_public_creds_received
|| se.se_public_keys <> []
|| (match se.se_threshold_trustees with
| Some l -> l <> []
| None -> false
)
let default_contact = "Name <user@example.org>"
let default_questions =
......
......@@ -153,6 +153,7 @@ val webize_trustee_public_key : bool -> 'a trustee_public_key -> 'a web_trustee_
val unwebize_trustee_public_key : 'a web_trustee_public_key -> 'a trustee_public_key
val get_suitable_group_kind : template -> [ `H | `NH ]
val is_group_fixed : draft_election -> bool
val default_contact : string
val default_questions : question array
......
......@@ -685,14 +685,6 @@ let () =
)
)
let is_group_fixed se =
se.se_public_creds_received
|| se.se_public_keys <> []
|| (match se.se_threshold_trustees with
| Some l -> l <> []
| None -> false
)
let () =
Html.register ~service:election_draft_questions
(fun uuid () ->
......
......@@ -932,10 +932,16 @@ let election_draft_questions uuid se () =
div [input ~input_type:`Submit ~value:"Save changes" string]])
uuid
in
let allow_nh =
match get_suitable_group_kind se.se_questions with
| `NH -> true
| `H -> not (is_group_fixed se)
in
let interactivity =
div
~a:[a_id "interactivity"]
[
script (Printf.ksprintf pcdata "var allow_nh = %b;" allow_nh);
script ~a:[a_src (static "sjcl.js")] (pcdata "");
script ~a:[a_src (static "jsbn.js")] (pcdata "");
script ~a:[a_src (static "jsbn2.js")] (pcdata "");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment