From 7d755d4c8a9061deeaf76228b84e14dc8d8337e6 Mon Sep 17 00:00:00 2001 From: Thomas NOEL Date: Mon, 2 Oct 2017 20:46:47 +0200 Subject: [PATCH] admin: add dynamic-display js possibility for checked widgets (#19153) --- wcs/qommon/static/js/qommon.js | 2 ++ wcs/qommon/templates/qommon/forms/widget.html | 3 +++ 2 files changed, 5 insertions(+) diff --git a/wcs/qommon/static/js/qommon.js b/wcs/qommon/static/js/qommon.js index 6a672335..dc6d6cde 100644 --- a/wcs/qommon/static/js/qommon.js +++ b/wcs/qommon/static/js/qommon.js @@ -5,8 +5,10 @@ $(function() { $('[data-dynamic-display-parent]').off('change keyup').on('change keyup', function() { var sel1 = '[data-dynamic-display-child-of="' + $(this).attr('name') + '"]'; var sel2 = '[data-dynamic-display-value="' + $(this).val() + '"]'; + var sel3 = '[data-dynamic-display-checked="' + $(this).prop('checked') + '"]'; $(sel1).hide(); $(sel1 + sel2).show(); + $(sel1 + sel3).show(); }); $('[data-dynamic-display-child-of]').hide(); $('select[data-dynamic-display-parent]').trigger('change'); diff --git a/wcs/qommon/templates/qommon/forms/widget.html b/wcs/qommon/templates/qommon/forms/widget.html index d33b25b4..c26b715c 100644 --- a/wcs/qommon/templates/qommon/forms/widget.html +++ b/wcs/qommon/templates/qommon/forms/widget.html @@ -14,6 +14,9 @@ {% endif %} {% if "data-dynamic-display-value" in widget.attrs %} data-dynamic-display-value="{{widget.attrs|get:"data-dynamic-display-value"}}" + {% endif %} + {% if "data-dynamic-display-checked" in widget.attrs %} + data-dynamic-display-checked="{{widget.attrs|get:"data-dynamic-display-checked"}}" {% endif %}> {% block widget-title %} {{widget.rendered_title}} -- 2.14.2