mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Added attrs to permission when target is group or filter
Option to set attributes in permission was missing for target 'group' and 'filter'. Attribute_table_widget with type=group is shown for target=group. For target=filter a multivalued textbox is shown. This is because UI can't predict what type will the result of the filter be. In future it can be extended by interactive attribute selector to help user find what he wants to enter. Mutlivalued widget was modified to show undo button for new entries even if show_undo is false. It is useful in adder dialog to indicate that user added something and to enable it reversal. https://fedorahosted.org/freeipa/ticket/2372
This commit is contained in:
parent
885ffe5a3e
commit
37cdbae234
@ -52,7 +52,8 @@ IPA.aci.permission_entity = function(spec) {
|
||||
{
|
||||
type: 'select',
|
||||
name: 'target',
|
||||
widget: 'target.target'
|
||||
widget: 'target.target',
|
||||
enabled: false
|
||||
},
|
||||
{
|
||||
name: 'filter',
|
||||
@ -62,7 +63,8 @@ IPA.aci.permission_entity = function(spec) {
|
||||
{
|
||||
type: 'entity_select',
|
||||
name: 'memberof',
|
||||
widget: 'target.memberof'
|
||||
widget: 'target.memberof',
|
||||
enabled: false
|
||||
},
|
||||
{
|
||||
name: 'subtree',
|
||||
@ -85,6 +87,13 @@ IPA.aci.permission_entity = function(spec) {
|
||||
name: 'attrs',
|
||||
widget: 'target.attrs',
|
||||
enabled: false
|
||||
},
|
||||
{
|
||||
name: 'attrs_multi',
|
||||
param: 'attrs',
|
||||
type: 'multivalued',
|
||||
widget: 'target.attrs_multi',
|
||||
enabled: false
|
||||
}
|
||||
],
|
||||
widgets: [
|
||||
@ -139,7 +148,8 @@ IPA.aci.permission_entity = function(spec) {
|
||||
{
|
||||
type: 'select',
|
||||
name: 'target',
|
||||
widget: 'target.target'
|
||||
widget: 'target.target',
|
||||
enabled: false
|
||||
},
|
||||
{
|
||||
name: 'filter',
|
||||
@ -149,7 +159,8 @@ IPA.aci.permission_entity = function(spec) {
|
||||
{
|
||||
type: 'entity_select',
|
||||
name: 'memberof',
|
||||
widget: 'target.memberof'
|
||||
widget: 'target.memberof',
|
||||
enabled: false
|
||||
},
|
||||
{
|
||||
name: 'subtree',
|
||||
@ -172,6 +183,13 @@ IPA.aci.permission_entity = function(spec) {
|
||||
name: 'attrs',
|
||||
widget: 'target.attrs',
|
||||
enabled: false
|
||||
},
|
||||
{
|
||||
name: 'attrs_multi',
|
||||
type: 'multivalued',
|
||||
param: 'attrs',
|
||||
widget: 'target.attrs_multi',
|
||||
enabled: false
|
||||
}
|
||||
],
|
||||
widgets: [
|
||||
@ -702,6 +720,14 @@ IPA.permission_target_widget = function(spec) {
|
||||
});
|
||||
|
||||
that.widgets.add_widget(that.attribute_table);
|
||||
|
||||
that.attribute_multivalued = IPA.multivalued_widget({
|
||||
entity: that.entity,
|
||||
name: 'attrs_multi',
|
||||
hidden: true
|
||||
});
|
||||
|
||||
that.widgets.add_widget(that.attribute_multivalued);
|
||||
};
|
||||
|
||||
init();
|
||||
@ -725,34 +751,41 @@ IPA.permission_target_policy = function (widget_name) {
|
||||
});
|
||||
|
||||
var type_select = widgets.get_widget('type');
|
||||
var attribute_table = widgets.get_widget('attrs');
|
||||
var attribute_field = that.container.fields.get_field('attrs');
|
||||
|
||||
type_select.value_changed.attach(function() {
|
||||
var type = type_select.save()[0];
|
||||
attribute_table.object_type = type;
|
||||
attribute_field.reset();
|
||||
that.set_attrs_type(type);
|
||||
});
|
||||
};
|
||||
|
||||
that.set_attrs_type = function(type) {
|
||||
var attribute_field = that.container.fields.get_field('attrs');
|
||||
var attribute_table = that.permission_target.widgets.get_widget('attrs');
|
||||
attribute_table.object_type = type;
|
||||
attribute_field.reset();
|
||||
};
|
||||
|
||||
that.post_create = function() {
|
||||
that.select_target(that.permission_target.targets[0]);
|
||||
};
|
||||
|
||||
that.post_load = function(data) {
|
||||
|
||||
var targets = that.permission_target.targets;
|
||||
var displayed_target;
|
||||
|
||||
that.set_target_visible_core('memberof', false);
|
||||
for (var target in that.target_mapping) {
|
||||
|
||||
for (var i=0; i<targets.length; i++) {
|
||||
var target = targets[i];
|
||||
|
||||
if(data.result.result[target]) {
|
||||
that.select_target(target);
|
||||
if (data.result.result[target]) {
|
||||
displayed_target = target;
|
||||
} else {
|
||||
that.set_target_visible(target, false);
|
||||
}
|
||||
}
|
||||
|
||||
if (displayed_target) {
|
||||
that.permission_target.target = displayed_target;
|
||||
that.set_target_visible(displayed_target, true);
|
||||
}
|
||||
};
|
||||
|
||||
that.select_target = function(target) {
|
||||
@ -763,27 +796,71 @@ IPA.permission_target_policy = function (widget_name) {
|
||||
|
||||
that.set_target_visible = function(target, visible) {
|
||||
|
||||
that.set_target_visible_core(target, visible);
|
||||
|
||||
if (target === 'type') {
|
||||
that.set_target_visible_core('attrs', visible);
|
||||
} else {
|
||||
var field = that.container.fields.get_field(target);
|
||||
field.set_required(visible);
|
||||
}
|
||||
|
||||
if (visible) {
|
||||
var member_of_visible = target === 'type' || target === 'subtree';
|
||||
that.set_target_visible_core('memberof', member_of_visible);
|
||||
}
|
||||
var target_info = that.target_mapping[target];
|
||||
that.set_target_visible_core(target_info, visible);
|
||||
};
|
||||
|
||||
that.set_target_visible_core = function(target, visible) {
|
||||
var widget = that.permission_target.widgets.get_widget(target);
|
||||
var field = that.container.fields.get_field(target);
|
||||
that.permission_target.set_row_visible(target, visible);
|
||||
that.set_target_visible_core = function(target_info, visible) {
|
||||
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);
|
||||
field.enabled = visible;
|
||||
field.set_required(visible && target_info.required);
|
||||
widget.hidden = !visible;
|
||||
|
||||
if (target_info.additional) {
|
||||
for (var i=0; i<target_info.additional.length; i++) {
|
||||
var nested_info = target_info.additional[i];
|
||||
that.set_target_visible_core(nested_info, visible);
|
||||
}
|
||||
}
|
||||
|
||||
if (target_info.action) target_info.action();
|
||||
};
|
||||
|
||||
|
||||
that.target_mapping = {
|
||||
filter: {
|
||||
name: 'filter',
|
||||
required: true,
|
||||
additional: [
|
||||
{
|
||||
name: 'attrs_multi'
|
||||
}
|
||||
]
|
||||
},
|
||||
subtree: {
|
||||
name: 'subtree',
|
||||
required: true,
|
||||
additional: [
|
||||
{
|
||||
name: 'memberof'
|
||||
}
|
||||
]
|
||||
},
|
||||
targetgroup: {
|
||||
name: 'targetgroup',
|
||||
required: true,
|
||||
additional: [
|
||||
{
|
||||
name: 'attrs'
|
||||
}
|
||||
],
|
||||
action: function() {
|
||||
that.set_attrs_type('group');
|
||||
}
|
||||
},
|
||||
type: {
|
||||
name: 'type',
|
||||
additional: [
|
||||
{
|
||||
name: 'memberof'
|
||||
},
|
||||
{
|
||||
name: 'attrs'
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
@ -41,7 +41,8 @@ module('aci', {
|
||||
{
|
||||
type: 'select',
|
||||
name: 'target',
|
||||
widget: 'target.target'
|
||||
widget: 'target.target',
|
||||
enabled: false
|
||||
},
|
||||
{
|
||||
name: 'filter',
|
||||
@ -51,7 +52,8 @@ module('aci', {
|
||||
{
|
||||
type: 'entity_select',
|
||||
name: 'memberof',
|
||||
widget: 'target.memberof'
|
||||
widget: 'target.memberof',
|
||||
enabled: false
|
||||
},
|
||||
{
|
||||
name: 'subtree',
|
||||
@ -74,6 +76,13 @@ module('aci', {
|
||||
name: 'attrs',
|
||||
widget: 'target.attrs',
|
||||
enabled: false
|
||||
},
|
||||
{
|
||||
name: 'attrs_multi',
|
||||
param: 'attrs',
|
||||
type: 'multivalued',
|
||||
widget: 'target.attrs_multi',
|
||||
enabled: false
|
||||
}
|
||||
],
|
||||
widgets: [
|
||||
@ -203,7 +212,7 @@ test("Testing aci grouptarget.", function() {
|
||||
same(target_widget.target, 'targetgroup' , 'group control selected');
|
||||
|
||||
|
||||
same(get_visible_rows(target_widget), ['targetgroup'],
|
||||
same(get_visible_rows(target_widget), ['targetgroup', 'attrs'],
|
||||
'group select row visible');
|
||||
|
||||
ok ($('option', target_widget.group_select.container).length > 2,
|
||||
@ -252,7 +261,7 @@ test("Testing filter target.", function() {
|
||||
|
||||
same(target_widget.target, 'filter', 'filter selected');
|
||||
|
||||
same(get_visible_rows(target_widget), ['filter'], 'filter row visible');
|
||||
same(get_visible_rows(target_widget), ['filter', 'attrs_multi'], 'filter row visible');
|
||||
|
||||
ok(record.filter[0], data.result.result.filter, 'filter set correctly');
|
||||
});
|
||||
|
@ -436,7 +436,7 @@ IPA.multivalued_widget = function(spec) {
|
||||
|
||||
row.widget = that.widget_factory({
|
||||
name: that.name+'-'+row_index,
|
||||
undo: that.undo,
|
||||
undo: that.undo || row.is_new,
|
||||
read_only: that.read_only,
|
||||
writable: that.writable
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user