mostly: https://fedorahosted.org/freeipa/ticket/4254
but also some fixes for little regressions
== [PATCH] 703 webui: reflect readonly state ==
Separate update of read-only state from update of value.
It should be possible to switch from read-only UI to editable UI without
value change.
https://fedorahosted.org/freeipa/ticket/4254
== [PATCH] 704 webui: fix add of input group class ==
The input-group class was added based on visibility of child elements.
This failed when it had to be determined *before* displaying the widget.
Now it's added if the buttons are not hidden by `display: none` CSS rule.
== [PATCH] 705 webui: show managed fields as readonly and not disabled ==
Visible read-only fields are no longer displayed as disabled in
permission details facet.
https://fedorahosted.org/freeipa/ticket/4254
== [PATCH] 706 webui: fix selection of empty value in a select widget ==
Little regression - select widget could not handle empty or no array as
an input value.
It broke 'undo' operation in Permissions' 'Type' attribute while switching
between '' and some value.
== [PATCH] 707 webui: disable ipapermbindruletype if permission in a
privilege ==
User is not able to change Bind Rule Type if permission is already
member of a privilege. Let's disable it and don't confuse user.
--
Petr Vobornik
From 854ff710b08f7b5e699be3b65b2919471ad250c6 Mon Sep 17 00:00:00 2001
From: Petr Vobornik <pvobo...@redhat.com>
Date: Mon, 7 Jul 2014 17:45:50 +0200
Subject: [PATCH] webui: disable ipapermbindruletype if permission in a
privilege
User is not able to change Bind Rule Type if permission is already
member of a privilege. Let's disable it and don't confuse user.
---
install/ui/src/freeipa/aci.js | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/install/ui/src/freeipa/aci.js b/install/ui/src/freeipa/aci.js
index 21254a1334aeda00bfb1ace740226ac1a1955e47..c78204f79f5e102812036b1b8cb3ef3f6a8cfa1c 100644
--- a/install/ui/src/freeipa/aci.js
+++ b/install/ui/src/freeipa/aci.js
@@ -1041,7 +1041,9 @@ aci.permission_managed_policy = function (spec) {
var that = IPA.facet_policy();
that.post_load = function(data) {
- var permtype = data.result.result.ipapermissiontype;
+
+ var result = data.result.result;
+ var permtype = result.ipapermissiontype;
var managed = permtype && permtype.indexOf("MANAGED") > -1;
var system = permtype && permtype.indexOf("SYSTEM") > -1 && permtype.length === 1;
var m_section = that.container.widgets.get_widget("managed");
@@ -1054,6 +1056,13 @@ aci.permission_managed_policy = function (spec) {
var managed_f = aci.managed_fields.indexOf(field.name) > -1;
field.set_writable(!system && !(managed_f && managed) && field.writable);
}
+
+ // Bind rule type cannot be changed if permission is in a privilege
+ var privileges = result.member_privilege;
+ if (privileges && privileges.length > 0) {
+ var f = that.container.fields.get_field('ipapermbindruletype');
+ f.set_writable(false);
+ }
};
return that;
--
1.9.3
From 06b2be47237a1352ae298a64cfffb140beb30577 Mon Sep 17 00:00:00 2001
From: Petr Vobornik <pvobo...@redhat.com>
Date: Mon, 7 Jul 2014 16:54:54 +0200
Subject: [PATCH] webui: fix selection of empty value in a select widget
Little regression - select widget could not handle empty or no array as an
input value.
It broke 'undo' operation in Permissions' 'Type' attribute while switching
between '' and some value.
---
install/ui/src/freeipa/widget.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/install/ui/src/freeipa/widget.js b/install/ui/src/freeipa/widget.js
index c0c580062643857614f47862e73255131b4abbfd..79f814552f450645681dfc35c2ad1fe00433d4d0 100644
--- a/install/ui/src/freeipa/widget.js
+++ b/install/ui/src/freeipa/widget.js
@@ -1981,7 +1981,7 @@ IPA.select_widget = function(spec) {
that.update = function(values) {
var old = that.save()[0];
- var value = values[0];
+ var value = values[0] || "";
var option = $('option[value="'+value+'"]', that.select);
if (option.length) {
option.prop('selected', true);
--
1.9.3
From 76c7887f3846ab61aedc91e4e86750e66c9d0170 Mon Sep 17 00:00:00 2001
From: Petr Vobornik <pvobo...@redhat.com>
Date: Mon, 7 Jul 2014 15:51:29 +0200
Subject: [PATCH] webui: show managed fields as readonly and not disabled
Visible read-only fields are no longer displayed as disabled in
permission details facet.
https://fedorahosted.org/freeipa/ticket/4254
---
install/ui/src/freeipa/aci.js | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/install/ui/src/freeipa/aci.js b/install/ui/src/freeipa/aci.js
index c79af2cb079a8dddc905eef7c15442082f546914..21254a1334aeda00bfb1ace740226ac1a1955e47 100644
--- a/install/ui/src/freeipa/aci.js
+++ b/install/ui/src/freeipa/aci.js
@@ -972,9 +972,7 @@ aci.permission_target_policy = function (spec) {
var widget = that.permission_target.widgets.get_widget(target_info.name);
var field = that.container.fields.get_field(target_info.name);
that.permission_target.set_row_visible(target_info.name, visible);
- var managed_f = aci.managed_fields.indexOf(target_info.name) > -1;
- var enabled = !(managed_f && that.managed) && visible && !that.system;
- field.set_enabled(enabled);
+ field.set_enabled(visible);
field.set_required(visible && target_info.required);
widget.set_visible(visible);
};
@@ -1054,7 +1052,7 @@ aci.permission_managed_policy = function (spec) {
var field = fields[i];
if (field.read_only) continue;
var managed_f = aci.managed_fields.indexOf(field.name) > -1;
- field.set_enabled(!system && !(managed_f && managed));
+ field.set_writable(!system && !(managed_f && managed) && field.writable);
}
};
--
1.9.3
From 06dec9d88a647160e59b2cd0bd149cad69831b11 Mon Sep 17 00:00:00 2001
From: Petr Vobornik <pvobo...@redhat.com>
Date: Mon, 7 Jul 2014 15:38:44 +0200
Subject: [PATCH] webui: fix add of input group class
The input-group class was added based on visibility of child elements.
This failed when it had to be determined *before* displaying the widget.
Now it's added if the buttons are not hidden by `display: none` CSS rule.
---
install/ui/src/freeipa/widget.js | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/install/ui/src/freeipa/widget.js b/install/ui/src/freeipa/widget.js
index 302b466b59d6ab6df7f68b96592da7a368997605..c0c580062643857614f47862e73255131b4abbfd 100644
--- a/install/ui/src/freeipa/widget.js
+++ b/install/ui/src/freeipa/widget.js
@@ -834,7 +834,10 @@ IPA.text_widget = function(spec) {
* visible content.
*/
that.update_input_group_state = function() {
- var visible = $(':visible', that.input_group_btn).length > 0;
+ var children = that.input_group_btn.children();
+ var visible = $.grep(children, function(el, i) {
+ return $(el).css('display') !== 'none';
+ }).length > 0;
that.input_group.toggleClass('input-group', visible);
};
--
1.9.3
From 7e6d858fcfa82c15eb63ca2f0e8793f430127917 Mon Sep 17 00:00:00 2001
From: Petr Vobornik <pvobo...@redhat.com>
Date: Mon, 7 Jul 2014 15:38:01 +0200
Subject: [PATCH] webui: reflect readonly state
Separate update of read-only state from update of value.
It should be possible to switch from read-only UI to editable UI without
value change.
https://fedorahosted.org/freeipa/ticket/4254
---
install/ui/src/freeipa/widget.js | 149 ++++++++++++++++++++++++++++++---------
1 file changed, 116 insertions(+), 33 deletions(-)
diff --git a/install/ui/src/freeipa/widget.js b/install/ui/src/freeipa/widget.js
index c12115592c2303236b38ae3534c352e7a3b6be9c..302b466b59d6ab6df7f68b96592da7a368997605 100644
--- a/install/ui/src/freeipa/widget.js
+++ b/install/ui/src/freeipa/widget.js
@@ -569,6 +569,7 @@ IPA.input_widget = function(spec) {
var changed = writable !== that.writable;
that.writable = writable;
+ that.update_read_only();
if (changed) {
that.emit('writable-change', { source: that, writable: writable });
@@ -585,6 +586,7 @@ IPA.input_widget = function(spec) {
var changed = read_only !== that.read_only;
that.read_only = read_only;
+ that.update_read_only();
if (changed) {
that.emit('readonly-change', { source: that, read_only: read_only });
@@ -592,6 +594,18 @@ IPA.input_widget = function(spec) {
};
/**
+ * Update widget's HTML based on `read_only` and `writable` properties
+ * @protected
+ */
+ that.update_read_only = function() {
+ var input = that.get_input();
+ if (input) {
+ var ro = that.is_writable();
+ input.prop('readOnly', !ro);
+ }
+ };
+
+ /**
* Focus input element
* @abstract
*/
@@ -636,6 +650,8 @@ IPA.input_widget = function(spec) {
that.widget_set_valid = that.set_valid;
that.widget_hide_undo = that.hide_undo;
that.widget_show_undo = that.show_undo;
+ that.widget_set_writable = that.set_writable;
+ that.widget_set_read_only = that.set_read_only;
return that;
};
@@ -737,6 +753,7 @@ IPA.text_widget = function(spec) {
that.create_error_link(container);
that.set_enabled(that.enabled);
+ that.update_read_only();
that.update_input_group_state();
};
@@ -745,18 +762,23 @@ IPA.text_widget = function(spec) {
*/
that.update = function(values) {
var value = values && values.length ? values[0] : '';
+ that.display_control.text(value);
+ that.input.val(value);
+ that.on_value_changed();
+ };
+ /**
+ * @inheritDoc
+ */
+ that.update_read_only = function() {
+ if (!that.input) return;
if (!that.is_writable()) {
- that.display_control.text(value);
that.display_control.css('display', '');
that.input_group.css('display', 'none');
} else {
- that.input.val(value);
that.display_control.css('display', 'none');
that.input_group.css('display', '');
}
-
- that.on_value_changed();
};
/**
@@ -1183,7 +1205,13 @@ IPA.multivalued_widget = function(spec) {
that.on_value_changed();
};
+ /** @inheritDoc */
+ that.update_read_only = function() {
+ that.update_add_link_visibility();
+ };
+
that.update_add_link_visibility = function() {
+ if (!that.add_link) return;
var visible = that.is_writable() && that.enabled;
if (visible) {
that.add_link.css('display', '');
@@ -1192,28 +1220,52 @@ IPA.multivalued_widget = function(spec) {
}
};
- that.set_enabled = function(enabled) {
+ that.update_row_buttons = function(row) {
- that.widget_set_enabled(enabled);
- that.update_add_link_visibility();
-
- for (var i=0,l=that.rows.length; i<l; i++) {
- var row = that.rows[i];
- row.widget.set_enabled(enabled);
-
- if (!enabled) {
- row.widget.hide_undo();
+ var w = that.is_writable();
+ if (!that.enabled || !w) {
+ row.widget.hide_undo();
+ that.toggle_remove_link(row, false);
+ } else {
+ if (row.is_new || that.test_dirty_row(row)) {
+ row.widget.show_undo();
that.toggle_remove_link(row, false);
} else {
- if (row.is_new || that.test_dirty_row(row)) {
- row.widget.show_undo();
- } else if (that.is_writable()) {
- that.toggle_remove_link(row, true);
- }
+ that.toggle_remove_link(row, w);
}
}
};
+ that.set_writable = function(writable) {
+ that.widget_set_writable(writable);
+ for (var i=0,l=that.rows.length; i<l; i++) {
+ var row = that.rows[i];
+ row.widget.set_writable(writable);
+ that.update_row_buttons(row);
+ }
+ };
+
+ that.set_read_only = function(read_only) {
+ that.widget_set_read_only(read_only);
+ for (var i=0,l=that.rows.length; i<l; i++) {
+ var row = that.rows[i];
+ row.widget.set_read_only(read_only);
+ that.update_row_buttons(row);
+ }
+ };
+
+ that.set_enabled = function(enabled) {
+
+ that.widget_set_enabled(enabled);
+ that.update_add_link_visibility();
+
+ for (var i=0,l=that.rows.length; i<l; i++) {
+ var row = that.rows[i];
+ row.widget.set_enabled(enabled);
+ that.update_row_buttons(row);
+ }
+ };
+
return that;
};
@@ -1655,6 +1707,12 @@ IPA.option_widget_base = function(spec, that) {
}
};
+ that.update_read_only = function() {
+ // a little hack
+ var enabled = that.is_writable() && that.enabled;
+ that.update_enabled(enabled);
+ };
+
that.clear = function() {
@@ -1858,6 +1916,12 @@ IPA.select_widget = function(spec) {
that.widget_create(container);
+ that.display_control = $('<p/>', {
+ name: that.name,
+ 'class': 'form-control-static',
+ style: 'display: none;'
+ }).appendTo(container);
+
that.select = $('<select/>', {
name: that.name,
'class':'form-control',
@@ -1918,6 +1982,7 @@ IPA.select_widget = function(spec) {
var option = $('option[value="'+value+'"]', that.select);
if (option.length) {
option.prop('selected', true);
+ that.display_control.text(option.text());
} else {
// default was selected instead of supplied value, hence notify
util.emit_delayed(that,'value-change', { source: that });
@@ -1925,6 +1990,17 @@ IPA.select_widget = function(spec) {
that.on_value_changed();
};
+ that.update_read_only = function() {
+ if (!that.select) return;
+ if (!that.is_writable()) {
+ that.display_control.css('display', '');
+ that.select.css('display', 'none');
+ } else {
+ that.display_control.css('display', 'none');
+ that.select.css('display', '');
+ }
+ };
+
that.empty = function() {
$('option', that.select).remove();
};
@@ -2028,12 +2104,16 @@ IPA.textarea_widget = function (spec) {
};
that.update = function(values) {
+
+ var value = values && values.length ? values[0] : '';
+ that.input.val(value);
+ that.on_value_changed();
+ };
+
+ that.update_read_only = function() {
+ if (!that.input) return;
var read_only = !that.is_writable();
that.input.prop('readOnly', read_only);
-
- var value = values && values.length ? values[0] : '';
- that.input.val(value);
- that.on_value_changed();
};
that.clear = function() {
@@ -3692,16 +3772,6 @@ IPA.combobox_widget = function(spec) {
that.update = function(values) {
that.close();
- if (that.writable) {
- that.text.css('display', 'none');
- that.input.css('display', 'inline');
- that.open_button.css('display', 'inline');
- } else {
- that.text.css('display', 'inline');
- that.input.css('display', 'none');
- that.open_button.css('display', 'none');
- }
-
if (that.searchable) {
that.filter.empty();
}
@@ -3728,6 +3798,19 @@ IPA.combobox_widget = function(spec) {
that.on_value_changed();
};
+ that.update_read_only = function() {
+ if (!that.input) return;
+ if (that.is_writable()) {
+ that.text.css('display', 'none');
+ that.input.css('display', 'inline');
+ that.open_button.css('display', 'inline');
+ } else {
+ that.text.css('display', 'inline');
+ that.input.css('display', 'none');
+ that.open_button.css('display', 'none');
+ }
+ };
+
that.set_value = function(value) {
that.text.text(value);
that.input.val(value);
--
1.9.3
_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel