mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
use entity select widget for permissions
https://fedorahosted.org/freeipa/ticket/879
This commit is contained in:
parent
5c6232e24d
commit
ec59e618da
@ -165,56 +165,7 @@ IPA.attribute_table_widget = function(spec) {
|
||||
return that;
|
||||
};
|
||||
|
||||
IPA.targetgroup_widget = function(spec) {
|
||||
|
||||
spec = spec || {};
|
||||
|
||||
var that = IPA.select_widget(spec);
|
||||
|
||||
that.filter = spec.filter || '';
|
||||
|
||||
that.create = function(container) {
|
||||
that.select = $('<select/>', {
|
||||
name: that.name,
|
||||
id: 'aci_target_group_select'
|
||||
}).appendTo(container);
|
||||
};
|
||||
|
||||
that.load = function(record) {
|
||||
|
||||
that.empty();
|
||||
|
||||
that.select.append($('<option/>', {
|
||||
text: '',
|
||||
value: ''
|
||||
}));
|
||||
|
||||
var command = IPA.command({
|
||||
method: 'group_find',
|
||||
args: [that.filter],
|
||||
options: {}
|
||||
});
|
||||
|
||||
command.on_success = function(data, text_status, xhr) {
|
||||
|
||||
var groups = data.result.result;
|
||||
|
||||
for (var i=0; i<data.result.count; i++) {
|
||||
var option = groups[i].cn[0];
|
||||
that.select.append($('<option/>', {
|
||||
text: groups[i].cn[0],
|
||||
value: groups[i].cn[0]
|
||||
}));
|
||||
}
|
||||
|
||||
that.select_load(record);
|
||||
};
|
||||
|
||||
command.execute();
|
||||
};
|
||||
|
||||
return that;
|
||||
};
|
||||
|
||||
IPA.type_widget = function(spec) {
|
||||
|
||||
@ -234,96 +185,7 @@ IPA.type_widget = function(spec) {
|
||||
return that;
|
||||
};
|
||||
|
||||
IPA.entity_select_widget = function(spec){
|
||||
|
||||
var that = IPA.widget(spec);
|
||||
var entity = spec.entity || 'group';
|
||||
|
||||
function populate_select(value){
|
||||
function find_success(result){
|
||||
$('option', that.entity_select).remove();
|
||||
var entities = result.result.result;
|
||||
for (var i =0; i < result.result.count; i +=1){
|
||||
var option =
|
||||
$('<option/>',{
|
||||
text:entities[i].cn[0],
|
||||
value:entities[i].cn[0]
|
||||
}).
|
||||
appendTo(that.entity_select);
|
||||
if (value === entities[i].cn[0]){
|
||||
option.attr('selected','selected');
|
||||
}
|
||||
}
|
||||
}
|
||||
function find_error(err){
|
||||
}
|
||||
IPA.command({
|
||||
method: entity+'_find',
|
||||
args:[that.entity_filter.val()],
|
||||
options:{},
|
||||
on_success:find_success,
|
||||
on_error:find_error
|
||||
}).execute();
|
||||
}
|
||||
|
||||
that.create = function(container){
|
||||
var dd = $('<dd/>').appendTo(container);
|
||||
|
||||
that.entity_select = $('<select/>', {
|
||||
id: that.name + '-entity-select',
|
||||
change: function(){
|
||||
|
||||
}
|
||||
}).appendTo(dd);
|
||||
|
||||
|
||||
that.entity_filter = $('<input/>',{
|
||||
size:10,
|
||||
type: 'text',
|
||||
id: 'entity_filter',
|
||||
style: 'display: none;',
|
||||
keypress: function(){
|
||||
populate_select();
|
||||
}
|
||||
}).appendTo(dd);
|
||||
|
||||
$('<a />',{
|
||||
href:"",
|
||||
text: 'add ' +entity + ' filter: ',
|
||||
click:function(){
|
||||
that.entity_filter.css('display','inline');
|
||||
$(this).css('display','none');
|
||||
return false;
|
||||
}
|
||||
}).appendTo(dd);
|
||||
populate_select();
|
||||
};
|
||||
that.reset = function(){
|
||||
that.entity_filter.val(that.values[0]);
|
||||
populate_select(that.values[0]);
|
||||
|
||||
};
|
||||
|
||||
that.is_dirty = function(){
|
||||
return (that.save()[0] !== that.values[0]);
|
||||
};
|
||||
|
||||
that.load = function(record){
|
||||
var value = record[that.name];
|
||||
if (value instanceof Array) {
|
||||
that.values = value;
|
||||
} else {
|
||||
that.values = value ? [value] : [''];
|
||||
}
|
||||
that.reset();
|
||||
};
|
||||
|
||||
that.save = function(){
|
||||
return [$('option:selected', that.entity_select).val()];
|
||||
};
|
||||
|
||||
return that;
|
||||
};
|
||||
|
||||
IPA.rights_widget = function(spec){
|
||||
var rights = ['write','add','delete'];
|
||||
@ -528,6 +390,8 @@ IPA.target_section = function () {
|
||||
}
|
||||
|
||||
function display_group_target(dl){
|
||||
|
||||
|
||||
$('<dt/>' ).
|
||||
append($('<input />', {
|
||||
type: 'radio',
|
||||
@ -539,24 +403,16 @@ IPA.target_section = function () {
|
||||
})).
|
||||
appendTo(dl);
|
||||
|
||||
that.group_filter = $('<input/>',{
|
||||
type: 'text',
|
||||
id: 'group_filter' });
|
||||
|
||||
var span = $('<span/>', {
|
||||
name: 'targetgroup'
|
||||
}).appendTo(dl);
|
||||
|
||||
$('<dd/>', {
|
||||
var dd = $('<dd/>', {
|
||||
'class': 'aci_by_group first'
|
||||
}).
|
||||
append(that.group_filter).
|
||||
append($('<label>Group Filter</label>')).
|
||||
appendTo(span);
|
||||
|
||||
var dd = $('<dd/>', {
|
||||
'class': 'aci_by_group other'
|
||||
}).appendTo(span);
|
||||
|
||||
that.group_select.create(dd);
|
||||
}
|
||||
@ -619,7 +475,6 @@ IPA.target_section = function () {
|
||||
that.load = function(record) {
|
||||
|
||||
set_aci_type(record);
|
||||
that.group_select.filter = that.group_filter.val();
|
||||
that.attribute_table.object_type = record.type;
|
||||
|
||||
that.section_load(record);
|
||||
@ -637,7 +492,8 @@ IPA.target_section = function () {
|
||||
that.add_field(IPA.text_widget({name: 'filter'}));
|
||||
that.add_field(IPA.textarea_widget({name: 'subtree'}));
|
||||
|
||||
that.group_select = IPA.targetgroup_widget({name: 'targetgroup'});
|
||||
that.group_select = IPA.entity_select_widget(
|
||||
{name: 'targetgroup', entity:'group'});
|
||||
that.add_field(that.group_select);
|
||||
|
||||
that.type_select = IPA.type_widget({name: 'type'});
|
||||
|
@ -50,7 +50,7 @@ test("Testing aci grouptarget.", function() {
|
||||
var sample_data_filter_only = {"targetgroup":"ipausers"};
|
||||
target_section.load(sample_data_filter_only);
|
||||
ok($('#aci_by_group')[0].checked, 'aci_by_group control selected');
|
||||
ok ($('#aci_target_group_select option').length > 2,'group select populated');
|
||||
ok ($('#targetgroup-entity-select option').length > 2,'group select populated');
|
||||
|
||||
});
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
/*jsl:import ipa.js */
|
||||
/* Authors:
|
||||
* Endi Sukma Dewata <edewata@redhat.com>
|
||||
* Adam Young <ayoung@redhat.com>
|
||||
*
|
||||
* Copyright (C) 2010 Red Hat
|
||||
* see file 'COPYING' for use and warranty information
|
||||
@ -1061,3 +1062,93 @@ IPA.table_widget = function (spec) {
|
||||
|
||||
return that;
|
||||
};
|
||||
IPA.entity_select_widget = function(spec){
|
||||
|
||||
var that = IPA.widget(spec);
|
||||
var entity = spec.entity || 'group';
|
||||
|
||||
function populate_select(value){
|
||||
function find_success(result){
|
||||
$('option', that.entity_select).remove();
|
||||
var entities = result.result.result;
|
||||
for (var i =0; i < result.result.count; i +=1){
|
||||
var option =
|
||||
$('<option/>',{
|
||||
text:entities[i].cn[0],
|
||||
value:entities[i].cn[0]
|
||||
}).
|
||||
appendTo(that.entity_select);
|
||||
if (value === entities[i].cn[0]){
|
||||
option.attr('selected','selected');
|
||||
}
|
||||
}
|
||||
}
|
||||
function find_error(err){
|
||||
}
|
||||
IPA.command({
|
||||
method: entity+'_find',
|
||||
args:[that.entity_filter.val()],
|
||||
options:{},
|
||||
on_success:find_success,
|
||||
on_error:find_error
|
||||
}).execute();
|
||||
}
|
||||
|
||||
that.create = function(container){
|
||||
var dd = $('<dd/>').appendTo(container);
|
||||
|
||||
that.entity_select = $('<select/>', {
|
||||
id: that.name + '-entity-select',
|
||||
change: function(){
|
||||
|
||||
}
|
||||
}).appendTo(dd);
|
||||
|
||||
|
||||
that.entity_filter = $('<input/>',{
|
||||
size:10,
|
||||
type: 'text',
|
||||
id: 'entity_filter',
|
||||
style: 'display: none;',
|
||||
keypress: function(){
|
||||
populate_select();
|
||||
}
|
||||
}).appendTo(dd);
|
||||
|
||||
$('<a />',{
|
||||
href:"",
|
||||
text: 'add ' +entity + ' filter: ',
|
||||
click:function(){
|
||||
that.entity_filter.css('display','inline');
|
||||
$(this).css('display','none');
|
||||
return false;
|
||||
}
|
||||
}).appendTo(dd);
|
||||
populate_select();
|
||||
};
|
||||
that.reset = function(){
|
||||
that.entity_filter.val(that.values[0]);
|
||||
populate_select(that.values[0]);
|
||||
|
||||
};
|
||||
|
||||
that.is_dirty = function(){
|
||||
return (that.save()[0] !== that.values[0]);
|
||||
};
|
||||
|
||||
that.load = function(record){
|
||||
var value = record[that.name];
|
||||
if (value instanceof Array) {
|
||||
that.values = value;
|
||||
} else {
|
||||
that.values = value ? [value] : [''];
|
||||
}
|
||||
that.reset();
|
||||
};
|
||||
|
||||
that.save = function(){
|
||||
return [$('option:selected', that.entity_select).val()];
|
||||
};
|
||||
|
||||
return that;
|
||||
};
|
Loading…
Reference in New Issue
Block a user