From 2257f12652eb67ab9ece1f1aa79aa9f784adfb05 Mon Sep 17 00:00:00 2001 From: Petr Vobornik Date: Thu, 24 Jul 2014 12:56:14 +0200 Subject: webui: display fields based on otp token type - in adder dialog https://fedorahosted.org/freeipa/ticket/4402 Reviewed-By: Endi Sukma Dewata --- install/ui/src/freeipa/otptoken.js | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/install/ui/src/freeipa/otptoken.js b/install/ui/src/freeipa/otptoken.js index 5e395e4a1..e19c7e1d3 100644 --- a/install/ui/src/freeipa/otptoken.js +++ b/install/ui/src/freeipa/otptoken.js @@ -19,6 +19,7 @@ */ define([ + 'dojo/on', './ipa', './jquery', './menu', @@ -30,7 +31,7 @@ define([ './text', './search', './entity'], - function(IPA, $, menu, phases, reg, mod_details, mod_facet, QRCode, text) { + function(on, IPA, $, menu, phases, reg, mod_details, mod_facet, QRCode, text) { /** * OTP tokens module * @class @@ -222,6 +223,9 @@ return { $post_ops: [ otptoken.adder_dialog_qrcode_post_op ], + policies: [ + { $factory: otptoken.adder_policy } + ], fields: [ { $type: 'radio', @@ -293,6 +297,23 @@ return { } };}; +otptoken.adder_policy = function(spec) { + var that = IPA.facet_policy(spec); + that.init = function() { + var type_f = that.container.fields.get_field('type'); + on(type_f, 'value-change', that.on_type_change); + }; + that.on_type_change = function(args) { + var step_f = that.container.fields.get_field('ipatokentotptimestep'); + if (!step_f) return; + var step_w = step_f.widget; + var is_totp = args.value[0] === 'totp'; + step_f.set_enabled(is_totp); + step_w.set_visible(is_totp); + }; + return that; +}; + /** * OTP adder dialog pre-op. * -- cgit