From aadde0f849bc7f129ef5bfdd96391ebeee273829 Mon Sep 17 00:00:00 2001 From: Petr Vobornik Date: Fri, 14 Feb 2014 18:55:26 +0100 Subject: webui: replace widget's hidden property with visible Hidden was used only in ACI. There is no reason to have two properties which are negations of each other. Reviewed-By: Adam Misnyovszki --- install/ui/src/freeipa/aci.js | 14 +++++++------- install/ui/src/freeipa/widget.js | 42 ++++++++++++++++++++++++++++++---------- 2 files changed, 39 insertions(+), 17 deletions(-) diff --git a/install/ui/src/freeipa/aci.js b/install/ui/src/freeipa/aci.js index 0615184c0..e26ecd27d 100644 --- a/install/ui/src/freeipa/aci.js +++ b/install/ui/src/freeipa/aci.js @@ -756,7 +756,7 @@ aci.permission_target_widget = function(spec) { that.type_select = IPA.select_widget({ entity: that.entity, name: 'type', - hidden: true, + visible: false, options: types }); that.widgets.add_widget(that.type_select); @@ -764,21 +764,21 @@ aci.permission_target_widget = function(spec) { that.ipapermlocation_text = IPA.text_widget({ entity: that.entity, name: 'ipapermlocation', - hidden: true + visible: false }); that.widgets.add_widget(that.ipapermlocation_text); that.extratargetfilter_text = IPA.multivalued_widget({ entity: that.entity, name: 'extratargetfilter', - hidden: true + visible: false }); that.widgets.add_widget(that.extratargetfilter_text); that.ipapermtarget_text = IPA.text_widget({ entity: that.entity, name: 'ipapermtarget', - hidden: true + visible: false }); that.widgets.add_widget(that.ipapermtarget_text); @@ -799,14 +799,14 @@ aci.permission_target_widget = function(spec) { entity: that.entity, name: 'attrs', object_type: types[0].name, - hidden: true + visible: false }); that.widgets.add_widget(that.attribute_table); that.attribute_multivalued = IPA.multivalued_widget({ entity: that.entity, name: 'attrs_multi', - hidden: true + visible: false }); that.widgets.add_widget(that.attribute_multivalued); }; @@ -941,7 +941,7 @@ aci.permission_target_policy = function (spec) { var enabled = !(managed_f && that.managed) && visible && !that.system; field.set_enabled(enabled); field.set_required(visible && target_info.required); - widget.hidden = !visible; + widget.set_visible(visible); }; that.target_mapping = { diff --git a/install/ui/src/freeipa/widget.js b/install/ui/src/freeipa/widget.js index 9b04acc91..ecac43645 100644 --- a/install/ui/src/freeipa/widget.js +++ b/install/ui/src/freeipa/widget.js @@ -135,6 +135,12 @@ IPA.widget = function(spec) { */ that.show_errors = spec.show_errors === undefined ? true : spec.show_errors; + /** + * Facet should be visible + * @property {boolean} + */ + that.visible = spec.visible === undefined ? true : spec.visible; + /** * Create HTML representation of a widget. * @method @@ -169,18 +175,27 @@ IPA.widget = function(spec) { * @param {boolean} value - True - visible; False - hidden */ that.set_visible = function(visible) { - var changed = visible !== that.container.is(':visible'); + var changed = visible !== that.visible; + that.visible = visible; if (visible) { - that.container.show(); + that.show(); } else { - that.container.hide(); + that.hide(); } if (changed) { that.emit('visible-change', { source: that, visible: visible }); } }; + that.hide = function() { + that.container.hide(); + }; + + that.show = function() { + that.container.show(); + }; + /** * Utility method. Build widget based on spec with this widget's context. * @param {boolean} spec - Widget specification object @@ -273,11 +288,7 @@ IPA.input_widget = function(spec) { */ that.read_only = spec.read_only; - /** - * Mark the widget to be hidden (form or dialog may not display it). - * @property {boolean} - */ - that.hidden = spec.hidden; + //events //each widget can contain several events @@ -4213,7 +4224,7 @@ IPA.table_layout = function(spec) { var tr = $(''); that.rows.put(widget.name, tr); - if (widget.hidden) { + if (!widget.visible) { tr.css('display', 'none'); } @@ -4299,7 +4310,7 @@ exp.fluid_layout = IPA.fluid_layout = function(spec) { var group = $('
', { 'class': that.group_cls }); that.rows.put(widget.name, group); - if (widget.hidden) { + if (!widget.visible) { group.css('display', 'none'); } @@ -4353,6 +4364,7 @@ exp.fluid_layout = IPA.fluid_layout = function(spec) { on(widget, 'writable-change', that.on_require_change); on(widget, 'error-show', that.on_error_show); on(widget, 'error-hide', that.on_error_hide); + on(widget, 'visible-change', that.on_visible_change); }; that.on_enabled_change = function(event) { @@ -4383,6 +4395,16 @@ exp.fluid_layout = IPA.fluid_layout = function(spec) { row.toggleClass('error', false); }; + that.on_visible_change = function(event) { + + var row = that._get_row(event); + if (event.visible) { + row.css('display', ''); + } else { + row.css('display', 'none'); + } + }; + that.update_state = function(row, widget) { row.toggleClass('disabled', !widget.enabled); row.toggleClass('required', !!widget.required && widget.is_writable()); -- cgit