2011-01-14 11:16:25 -06:00
|
|
|
/*jsl:import ipa.js */
|
|
|
|
|
2010-10-25 18:55:57 -05:00
|
|
|
/* Authors:
|
|
|
|
* Adam Young <ayoung@redhat.com>
|
2011-01-29 14:25:56 -06:00
|
|
|
* Endi S. Dewata <edewata@redhat.com>
|
2010-10-25 18:55:57 -05:00
|
|
|
*
|
|
|
|
* Copyright (C) 2010 Red Hat
|
|
|
|
* see file 'COPYING' for use and warranty information
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation; version 2 only
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* REQUIRES: ipa.js, details.js, search.js, add.js, entity.js */
|
|
|
|
|
2011-03-18 15:43:54 -05:00
|
|
|
IPA.entity_factories.permission = function() {
|
|
|
|
|
|
|
|
return IPA.entity_builder().
|
|
|
|
entity('permission').
|
2011-08-05 10:15:53 -05:00
|
|
|
facet_groups([ 'privilege' , 'settings' ]).
|
2011-03-18 15:43:54 -05:00
|
|
|
search_facet({
|
2011-04-18 10:59:50 -05:00
|
|
|
columns:['cn']
|
|
|
|
}).
|
2011-03-31 14:32:29 -05:00
|
|
|
details_facet({sections:[
|
2011-03-18 15:43:54 -05:00
|
|
|
{
|
2011-03-31 14:32:29 -05:00
|
|
|
name:'identity',
|
2011-03-18 15:43:54 -05:00
|
|
|
fields: [{
|
|
|
|
factory: IPA.text_widget,
|
|
|
|
name: 'cn',
|
|
|
|
read_only: true
|
|
|
|
}]
|
|
|
|
},
|
|
|
|
{
|
2011-03-31 14:32:29 -05:00
|
|
|
name:'rights',
|
2011-03-18 15:43:54 -05:00
|
|
|
factory:IPA.rights_section
|
|
|
|
},
|
|
|
|
{
|
2011-03-31 14:32:29 -05:00
|
|
|
name:'target',
|
2011-03-18 15:43:54 -05:00
|
|
|
factory:IPA.target_section,
|
|
|
|
label: IPA.messages.objects.permission.target
|
2011-03-31 14:32:29 -05:00
|
|
|
}]}).
|
2011-08-05 10:15:53 -05:00
|
|
|
association_facet({
|
|
|
|
name: 'member_privilege',
|
|
|
|
facet_group: 'privilege'
|
|
|
|
}).
|
2011-04-18 10:59:50 -05:00
|
|
|
adder_dialog({
|
2011-07-15 12:18:59 -05:00
|
|
|
width: 500,
|
|
|
|
height: 400,
|
2011-04-18 10:59:50 -05:00
|
|
|
fields:[
|
|
|
|
'cn',
|
|
|
|
{
|
|
|
|
factory:IPA.rights_widget,
|
|
|
|
name: 'permissions',
|
|
|
|
join: true, undo: false
|
|
|
|
},
|
|
|
|
{
|
|
|
|
factory: IPA.target_section,
|
|
|
|
name: 'target',
|
|
|
|
label: IPA.messages.objects.permission.target,
|
|
|
|
undo: false
|
|
|
|
}]
|
|
|
|
}).
|
2011-03-18 15:43:54 -05:00
|
|
|
build();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
IPA.entity_factories.privilege = function() {
|
|
|
|
return IPA.entity_builder().
|
|
|
|
entity('privilege').
|
2011-08-05 10:15:53 -05:00
|
|
|
facet_groups([ 'role', 'settings', 'permission' ]).
|
2011-03-18 15:43:54 -05:00
|
|
|
search_facet({
|
2011-04-18 10:59:50 -05:00
|
|
|
columns:['cn','description']}).
|
2011-03-31 14:32:29 -05:00
|
|
|
details_facet({
|
|
|
|
sections:
|
|
|
|
[{
|
|
|
|
name:'identity',
|
2011-03-18 15:43:54 -05:00
|
|
|
label: IPA.messages.details.identity,
|
|
|
|
fields:['cn','description']
|
2011-03-31 14:32:29 -05:00
|
|
|
}]}).
|
2011-03-18 15:43:54 -05:00
|
|
|
association_facet({
|
|
|
|
name: 'member_role',
|
2011-08-05 10:15:53 -05:00
|
|
|
facet_group: 'role',
|
2011-03-18 15:43:54 -05:00
|
|
|
add_method: 'add_privilege',
|
|
|
|
remove_method: 'remove_privilege',
|
|
|
|
associator: IPA.serial_associator
|
|
|
|
}).
|
|
|
|
association_facet({
|
|
|
|
name: 'memberof_permission',
|
2011-08-05 10:15:53 -05:00
|
|
|
facet_group: 'permission',
|
2011-03-18 15:43:54 -05:00
|
|
|
add_method: 'add_permission',
|
|
|
|
remove_method: 'remove_permission'
|
|
|
|
}).
|
2011-03-31 14:32:29 -05:00
|
|
|
standard_association_facets().
|
2011-04-18 10:59:50 -05:00
|
|
|
adder_dialog({
|
|
|
|
fields:['cn', 'description']
|
|
|
|
}).
|
2011-03-18 15:43:54 -05:00
|
|
|
build();
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
IPA.entity_factories.role = function() {
|
|
|
|
return IPA.entity_builder().
|
|
|
|
entity('role').
|
2011-08-05 10:15:53 -05:00
|
|
|
facet_groups([ 'member', 'settings', 'privilege' ]).
|
2011-03-18 15:43:54 -05:00
|
|
|
search_facet({
|
2011-04-18 10:59:50 -05:00
|
|
|
columns:['cn','description']}).
|
2011-03-31 14:32:29 -05:00
|
|
|
details_facet({sections:[
|
2011-03-18 15:43:54 -05:00
|
|
|
{
|
2011-03-31 14:32:29 -05:00
|
|
|
name:'identity',
|
2011-03-18 15:43:54 -05:00
|
|
|
label:IPA.messages.objects.role.identity,
|
2011-03-31 14:32:29 -05:00
|
|
|
fields:['cn','description']}]}).
|
2011-03-18 15:43:54 -05:00
|
|
|
association_facet({
|
|
|
|
name: 'memberof_privilege',
|
2011-08-05 10:15:53 -05:00
|
|
|
facet_group: 'privilege',
|
2011-03-18 15:43:54 -05:00
|
|
|
add_method: 'add_privilege',
|
|
|
|
remove_method: 'remove_privilege'
|
|
|
|
}).
|
2011-03-31 14:32:29 -05:00
|
|
|
standard_association_facets().
|
2011-04-18 10:59:50 -05:00
|
|
|
adder_dialog({
|
|
|
|
fields:['cn', 'description']
|
|
|
|
}).
|
2011-03-18 15:43:54 -05:00
|
|
|
build();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
IPA.entity_factories.selfservice = function() {
|
|
|
|
return IPA.entity_builder().
|
|
|
|
entity('selfservice').
|
|
|
|
search_facet({
|
2011-04-18 10:59:50 -05:00
|
|
|
columns:['aciname']}).
|
2011-03-31 14:32:29 -05:00
|
|
|
details_facet({
|
|
|
|
sections:[{
|
|
|
|
name:'general',
|
2011-03-18 15:43:54 -05:00
|
|
|
label: IPA.messages.details.general,
|
|
|
|
fields: [
|
|
|
|
'aciname',
|
|
|
|
{
|
|
|
|
factory:IPA.attributes_widget,
|
|
|
|
object_type:'user',
|
|
|
|
name:'attrs'
|
2011-03-31 14:32:29 -05:00
|
|
|
}]}]}).
|
2011-04-18 10:59:50 -05:00
|
|
|
adder_dialog({
|
|
|
|
fields:[
|
|
|
|
'aciname',
|
|
|
|
{factory:IPA.attributes_widget,
|
|
|
|
object_type:'user',
|
|
|
|
name:'attrs',
|
|
|
|
undo: false
|
|
|
|
}]
|
|
|
|
}).
|
2011-03-18 15:43:54 -05:00
|
|
|
build();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
IPA.entity_factories.delegation = function() {
|
|
|
|
return IPA.entity_builder().
|
|
|
|
entity('delegation').
|
|
|
|
search_facet({
|
2011-04-18 10:59:50 -05:00
|
|
|
columns:['aciname']}).
|
2011-03-31 14:32:29 -05:00
|
|
|
details_facet({sections:[
|
2011-03-18 15:43:54 -05:00
|
|
|
{
|
2011-03-31 14:32:29 -05:00
|
|
|
name:'general',
|
2011-03-18 15:43:54 -05:00
|
|
|
label: IPA.messages.details.general,
|
|
|
|
fields:[
|
|
|
|
'aciname',
|
|
|
|
{
|
2011-07-15 12:18:59 -05:00
|
|
|
factory: IPA.entity_select_widget,
|
|
|
|
name: 'group',
|
|
|
|
other_entity: 'group',
|
|
|
|
other_field: 'cn'
|
2011-03-18 15:43:54 -05:00
|
|
|
},
|
|
|
|
{
|
2011-07-15 12:18:59 -05:00
|
|
|
factory: IPA.entity_select_widget,
|
|
|
|
name: 'memberof',
|
|
|
|
other_entity: 'group',
|
|
|
|
other_field: 'cn',
|
2011-03-18 15:43:54 -05:00
|
|
|
join: true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
factory:IPA.attributes_widget,
|
|
|
|
name: 'attrs', object_type: 'user',
|
|
|
|
join: true
|
2011-03-31 14:32:29 -05:00
|
|
|
}]}]}).
|
|
|
|
standard_association_facets().
|
2011-04-18 10:59:50 -05:00
|
|
|
adder_dialog({
|
|
|
|
fields:[
|
|
|
|
'aciname',
|
|
|
|
{
|
2011-07-15 12:18:59 -05:00
|
|
|
factory: IPA.entity_select_widget,
|
|
|
|
name: 'group',
|
|
|
|
other_entity: 'group',
|
|
|
|
other_field: 'cn',
|
|
|
|
undo: false
|
2011-04-18 10:59:50 -05:00
|
|
|
},
|
|
|
|
{
|
2011-07-15 12:18:59 -05:00
|
|
|
factory: IPA.entity_select_widget,
|
|
|
|
name: 'memberof',
|
|
|
|
other_entity: 'group',
|
|
|
|
other_field: 'cn',
|
|
|
|
join: true,
|
|
|
|
undo: false
|
2011-04-18 10:59:50 -05:00
|
|
|
},
|
|
|
|
{
|
|
|
|
factory:IPA.attributes_widget,
|
|
|
|
name: 'attrs', object_type: 'user',
|
|
|
|
join: true, undo: false
|
|
|
|
}]
|
|
|
|
}).
|
2011-03-18 15:43:54 -05:00
|
|
|
build();
|
|
|
|
};
|
|
|
|
|
2010-10-25 18:55:57 -05:00
|
|
|
|
2011-02-02 10:35:23 -06:00
|
|
|
IPA.attributes_widget = function(spec) {
|
2010-10-25 18:55:57 -05:00
|
|
|
|
2011-01-29 14:25:56 -06:00
|
|
|
spec = spec || {};
|
2010-10-25 18:55:57 -05:00
|
|
|
|
2011-01-29 14:25:56 -06:00
|
|
|
var that = IPA.checkboxes_widget(spec);
|
2010-10-25 18:55:57 -05:00
|
|
|
|
2011-01-29 14:25:56 -06:00
|
|
|
that.object_type = spec.object_type;
|
2010-10-25 18:55:57 -05:00
|
|
|
|
|
|
|
var id = spec.name;
|
|
|
|
|
2011-02-02 10:35:23 -06:00
|
|
|
that.create = function(container) {
|
2011-02-07 22:02:43 -06:00
|
|
|
that.container = container;
|
2010-10-25 18:55:57 -05:00
|
|
|
|
2011-01-29 14:25:56 -06:00
|
|
|
that.table = $('<table/>', {
|
2010-10-25 18:55:57 -05:00
|
|
|
id:id,
|
2011-02-02 10:35:23 -06:00
|
|
|
'class':'search-table aci-attribute-table'
|
|
|
|
}).
|
2010-10-25 18:55:57 -05:00
|
|
|
append('<thead/>').
|
2011-02-02 10:35:23 -06:00
|
|
|
append('<tbody/>').
|
2011-02-03 21:42:50 -06:00
|
|
|
appendTo(container);
|
2010-10-25 18:55:57 -05:00
|
|
|
|
2011-01-29 14:25:56 -06:00
|
|
|
var tr = $('<tr></tr>').appendTo($('thead', that.table));
|
2011-02-16 12:46:59 -06:00
|
|
|
|
2011-02-02 10:35:23 -06:00
|
|
|
tr.append($('<th/>', {
|
2011-01-24 21:21:31 -06:00
|
|
|
style:"height:2em; vertical-align:bottom;",
|
|
|
|
html:$('<input/>',{
|
|
|
|
type: "checkbox",
|
|
|
|
click: function(){
|
2011-02-07 22:02:43 -06:00
|
|
|
$('.aci-attribute', that.table).
|
2011-01-24 21:21:31 -06:00
|
|
|
attr('checked', $(this).attr('checked'));
|
2011-06-16 14:37:27 -05:00
|
|
|
that.set_dirty(that.test_dirty());
|
2011-02-02 10:35:23 -06:00
|
|
|
}
|
|
|
|
})
|
2011-02-16 12:46:59 -06:00
|
|
|
})).append($('<th/>', {
|
|
|
|
'class': 'aci-attribute-column',
|
|
|
|
html: IPA.messages.objects.aci.attribute
|
|
|
|
}));
|
2011-02-02 10:35:23 -06:00
|
|
|
|
|
|
|
if (that.undo) {
|
2011-02-03 21:42:50 -06:00
|
|
|
that.create_undo(container);
|
2011-02-07 22:02:43 -06:00
|
|
|
that.get_undo().click(function(){
|
|
|
|
that.reset();
|
|
|
|
});
|
2011-02-02 10:35:23 -06:00
|
|
|
}
|
|
|
|
|
2011-01-29 21:08:27 -06:00
|
|
|
if (that.object_type){
|
|
|
|
that.populate (that.object_type);
|
|
|
|
}
|
2010-10-25 18:55:57 -05:00
|
|
|
};
|
|
|
|
|
2011-01-29 14:25:56 -06:00
|
|
|
that.load = function(record) {
|
2011-01-28 09:36:25 -06:00
|
|
|
|
2011-01-29 14:25:56 -06:00
|
|
|
that.record = record;
|
|
|
|
that.values = [];
|
2011-01-28 09:36:25 -06:00
|
|
|
|
2011-01-29 14:25:56 -06:00
|
|
|
var values = record[that.name] || [];
|
|
|
|
for (var i=0; i<values.length; i++) {
|
|
|
|
var value = values[i].toLowerCase();
|
|
|
|
that.values.push(value);
|
2010-10-25 18:55:57 -05:00
|
|
|
}
|
|
|
|
|
2011-01-29 14:25:56 -06:00
|
|
|
that.reset();
|
|
|
|
};
|
|
|
|
|
|
|
|
that.update = function() {
|
|
|
|
that.populate(that.object_type);
|
|
|
|
that.append();
|
2011-02-02 10:35:23 -06:00
|
|
|
that.checkboxes_update();
|
2011-01-29 14:25:56 -06:00
|
|
|
};
|
|
|
|
|
2011-02-02 10:35:23 -06:00
|
|
|
that.populate = function(object_type) {
|
2011-01-29 14:25:56 -06:00
|
|
|
|
|
|
|
$('tbody tr', that.table).remove();
|
|
|
|
|
|
|
|
if (!object_type || object_type === '') return;
|
|
|
|
|
2011-02-16 12:46:59 -06:00
|
|
|
var metadata = IPA.metadata.objects[object_type];
|
2011-01-29 14:25:56 -06:00
|
|
|
if (!metadata) return;
|
|
|
|
|
|
|
|
var aciattrs = metadata.aciattrs;
|
|
|
|
|
|
|
|
var tbody = $('tbody', that.table);
|
|
|
|
|
2011-02-02 10:35:23 -06:00
|
|
|
for (var i=0; i<aciattrs.length ; i++){
|
|
|
|
var value = aciattrs[i].toLowerCase();
|
|
|
|
var aci_tr = $('<tr/>').appendTo(tbody);
|
|
|
|
|
|
|
|
var td = $('<td/>').appendTo(aci_tr);
|
2011-01-29 14:25:56 -06:00
|
|
|
td.append($('<input/>',{
|
|
|
|
type: 'checkbox',
|
2011-02-02 10:35:23 -06:00
|
|
|
name: that.name,
|
2011-01-29 14:25:56 -06:00
|
|
|
value: value,
|
2011-02-02 10:35:23 -06:00
|
|
|
'class': 'aci-attribute',
|
2011-02-07 22:02:43 -06:00
|
|
|
click: function() {
|
2011-06-16 14:37:27 -05:00
|
|
|
that.set_dirty(that.test_dirty());
|
2011-02-02 10:35:23 -06:00
|
|
|
}
|
2011-01-29 14:25:56 -06:00
|
|
|
}));
|
|
|
|
td = $('<td/>').appendTo(aci_tr);
|
|
|
|
td.append($('<label/>',{
|
|
|
|
text:value}));
|
|
|
|
}
|
2011-01-12 13:47:29 -06:00
|
|
|
};
|
2010-10-25 18:55:57 -05:00
|
|
|
|
2011-01-29 14:25:56 -06:00
|
|
|
that.append = function() {
|
|
|
|
|
|
|
|
if (!that.values) return;
|
|
|
|
|
|
|
|
var unmatched = [];
|
|
|
|
|
|
|
|
for (var i=0; i<that.values.length; i++) {
|
2011-02-07 22:02:43 -06:00
|
|
|
var input = $('input[name="'+that.name+'"]'+
|
|
|
|
'[value="'+that.values[i]+'"]', that.container);
|
2011-02-02 10:35:23 -06:00
|
|
|
if (!input.length) {
|
2011-01-29 14:25:56 -06:00
|
|
|
unmatched.push(that.values[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-02 10:35:23 -06:00
|
|
|
if (unmatched.length > 0) {
|
2011-01-29 14:25:56 -06:00
|
|
|
var tbody = $('tbody', that.table);
|
|
|
|
|
|
|
|
for (var j=0; j<unmatched.length; j++) {
|
|
|
|
var value = unmatched[j].toLowerCase();
|
|
|
|
var tr = $('<tr/>').appendTo(tbody);
|
|
|
|
|
|
|
|
var td = $('<td/>').appendTo(tr);
|
|
|
|
td.append($('<input/>', {
|
|
|
|
type: 'checkbox',
|
2011-02-02 10:35:23 -06:00
|
|
|
name: that.name,
|
2011-01-29 14:25:56 -06:00
|
|
|
value: value,
|
2011-02-02 10:35:23 -06:00
|
|
|
'class': 'aci-attribute',
|
|
|
|
change: function() {
|
2011-06-16 14:37:27 -05:00
|
|
|
that.set_dirty(that.test_dirty());
|
2011-02-02 10:35:23 -06:00
|
|
|
}
|
2011-01-29 14:25:56 -06:00
|
|
|
}));
|
|
|
|
|
|
|
|
td = $('<td/>').appendTo(tr);
|
|
|
|
td.append($('<label/>', {
|
|
|
|
text: value
|
|
|
|
}));
|
|
|
|
}
|
2010-10-25 18:55:57 -05:00
|
|
|
}
|
2011-01-12 13:47:29 -06:00
|
|
|
};
|
2010-10-25 18:55:57 -05:00
|
|
|
|
2011-01-29 14:25:56 -06:00
|
|
|
return that;
|
|
|
|
};
|
|
|
|
|
2011-02-02 10:35:23 -06:00
|
|
|
IPA.rights_widget = function(spec) {
|
2010-10-25 18:55:57 -05:00
|
|
|
|
2011-01-31 16:29:25 -06:00
|
|
|
var that = IPA.checkboxes_widget(spec);
|
2011-02-02 10:35:23 -06:00
|
|
|
|
|
|
|
that.rights = ['write', 'add', 'delete'];
|
removing setters setup and init
change widget and widget unit tests to hold on to entity, not entity name.
Replacing entity_name with entity.name in most places.
The one exception is columns for table_widget.
Widgets that refer to other entities have to have late resolution of the entity object, due to circular dependencies.
cleanup entity assignment.
removed template and layout,
merged setup into create
adder dialogs adjust height for external
removed init from widget, isection, association, facet, host and service
Make unit tests use factory.
fix functional tests to click find link correctly.
tweak to activation test, but still broken.
moved initialization code to the end
use --all for hbacrule find, so the type shows up now
fixed dns exception code and exception handling for get_entity
replace metadata look up with value from entity.
fixed author lines
removed duplicate columns in managed by facets.
tweak to nav fix in order to initialize tab.
more defensive code
update metadata for true false
one line init for entity_name in widget
move init code to end of constructor functions
moved constants to start of function for adder_dialog
external fields for dialogs initialized at dialog creation
sudo sections: move add fields and columns to widget definition.
The parameter validation in IPA.column ...This is precondition checking. Note that it merely throws an exception if the entity_name is not set. I want this stuff at the top of the function so that it is obvious to people looking to use them what is required. I added a comment to make this clear, but I'd like to keep precondition checking at the top of the function.
decreased the scope of the pkey_name and moved the initiailzation fof columns into the setup_column function for association_tables
return false at the end of click handler
removed blank labels in sudo command section
fix radio buttons for sudo category
fixed table side for adder dialogs with external fields
comments for future direction with add_columns
https://fedorahosted.org/freeipa/ticket/1451
https://fedorahosted.org/freeipa/ticket/1462
https://fedorahosted.org/freeipa/ticket/1493
https://fedorahosted.org/freeipa/ticket/1497
https://fedorahosted.org/freeipa/ticket/1532
https://fedorahosted.org/freeipa/ticket/1534
2011-07-25 11:15:14 -05:00
|
|
|
for (var i=0; i<that.rights.length; i++) {
|
|
|
|
var right = that.rights[i];
|
|
|
|
that.add_option({label: right, value: right});
|
|
|
|
}
|
2010-10-25 18:55:57 -05:00
|
|
|
|
|
|
|
return that;
|
2011-01-12 13:47:29 -06:00
|
|
|
};
|
2010-10-25 18:55:57 -05:00
|
|
|
|
2011-01-14 11:16:25 -06:00
|
|
|
|
removing setters setup and init
change widget and widget unit tests to hold on to entity, not entity name.
Replacing entity_name with entity.name in most places.
The one exception is columns for table_widget.
Widgets that refer to other entities have to have late resolution of the entity object, due to circular dependencies.
cleanup entity assignment.
removed template and layout,
merged setup into create
adder dialogs adjust height for external
removed init from widget, isection, association, facet, host and service
Make unit tests use factory.
fix functional tests to click find link correctly.
tweak to activation test, but still broken.
moved initialization code to the end
use --all for hbacrule find, so the type shows up now
fixed dns exception code and exception handling for get_entity
replace metadata look up with value from entity.
fixed author lines
removed duplicate columns in managed by facets.
tweak to nav fix in order to initialize tab.
more defensive code
update metadata for true false
one line init for entity_name in widget
move init code to end of constructor functions
moved constants to start of function for adder_dialog
external fields for dialogs initialized at dialog creation
sudo sections: move add fields and columns to widget definition.
The parameter validation in IPA.column ...This is precondition checking. Note that it merely throws an exception if the entity_name is not set. I want this stuff at the top of the function so that it is obvious to people looking to use them what is required. I added a comment to make this clear, but I'd like to keep precondition checking at the top of the function.
decreased the scope of the pkey_name and moved the initiailzation fof columns into the setup_column function for association_tables
return false at the end of click handler
removed blank labels in sudo command section
fix radio buttons for sudo category
fixed table side for adder dialogs with external fields
comments for future direction with add_columns
https://fedorahosted.org/freeipa/ticket/1451
https://fedorahosted.org/freeipa/ticket/1462
https://fedorahosted.org/freeipa/ticket/1493
https://fedorahosted.org/freeipa/ticket/1497
https://fedorahosted.org/freeipa/ticket/1532
https://fedorahosted.org/freeipa/ticket/1534
2011-07-25 11:15:14 -05:00
|
|
|
IPA.rights_section = function(spec) {
|
2011-02-16 12:46:59 -06:00
|
|
|
|
removing setters setup and init
change widget and widget unit tests to hold on to entity, not entity name.
Replacing entity_name with entity.name in most places.
The one exception is columns for table_widget.
Widgets that refer to other entities have to have late resolution of the entity object, due to circular dependencies.
cleanup entity assignment.
removed template and layout,
merged setup into create
adder dialogs adjust height for external
removed init from widget, isection, association, facet, host and service
Make unit tests use factory.
fix functional tests to click find link correctly.
tweak to activation test, but still broken.
moved initialization code to the end
use --all for hbacrule find, so the type shows up now
fixed dns exception code and exception handling for get_entity
replace metadata look up with value from entity.
fixed author lines
removed duplicate columns in managed by facets.
tweak to nav fix in order to initialize tab.
more defensive code
update metadata for true false
one line init for entity_name in widget
move init code to end of constructor functions
moved constants to start of function for adder_dialog
external fields for dialogs initialized at dialog creation
sudo sections: move add fields and columns to widget definition.
The parameter validation in IPA.column ...This is precondition checking. Note that it merely throws an exception if the entity_name is not set. I want this stuff at the top of the function so that it is obvious to people looking to use them what is required. I added a comment to make this clear, but I'd like to keep precondition checking at the top of the function.
decreased the scope of the pkey_name and moved the initiailzation fof columns into the setup_column function for association_tables
return false at the end of click handler
removed blank labels in sudo command section
fix radio buttons for sudo category
fixed table side for adder dialogs with external fields
comments for future direction with add_columns
https://fedorahosted.org/freeipa/ticket/1451
https://fedorahosted.org/freeipa/ticket/1462
https://fedorahosted.org/freeipa/ticket/1493
https://fedorahosted.org/freeipa/ticket/1497
https://fedorahosted.org/freeipa/ticket/1532
https://fedorahosted.org/freeipa/ticket/1534
2011-07-25 11:15:14 -05:00
|
|
|
spec = spec || {};
|
|
|
|
|
|
|
|
spec.name = 'rights';
|
|
|
|
spec.label = IPA.messages.objects.permission.rights;
|
2011-02-16 12:46:59 -06:00
|
|
|
|
2011-01-12 18:51:22 -06:00
|
|
|
var that = IPA.details_section(spec);
|
2011-02-16 12:46:59 -06:00
|
|
|
|
|
|
|
that.add_field(IPA.rights_widget({
|
removing setters setup and init
change widget and widget unit tests to hold on to entity, not entity name.
Replacing entity_name with entity.name in most places.
The one exception is columns for table_widget.
Widgets that refer to other entities have to have late resolution of the entity object, due to circular dependencies.
cleanup entity assignment.
removed template and layout,
merged setup into create
adder dialogs adjust height for external
removed init from widget, isection, association, facet, host and service
Make unit tests use factory.
fix functional tests to click find link correctly.
tweak to activation test, but still broken.
moved initialization code to the end
use --all for hbacrule find, so the type shows up now
fixed dns exception code and exception handling for get_entity
replace metadata look up with value from entity.
fixed author lines
removed duplicate columns in managed by facets.
tweak to nav fix in order to initialize tab.
more defensive code
update metadata for true false
one line init for entity_name in widget
move init code to end of constructor functions
moved constants to start of function for adder_dialog
external fields for dialogs initialized at dialog creation
sudo sections: move add fields and columns to widget definition.
The parameter validation in IPA.column ...This is precondition checking. Note that it merely throws an exception if the entity_name is not set. I want this stuff at the top of the function so that it is obvious to people looking to use them what is required. I added a comment to make this clear, but I'd like to keep precondition checking at the top of the function.
decreased the scope of the pkey_name and moved the initiailzation fof columns into the setup_column function for association_tables
return false at the end of click handler
removed blank labels in sudo command section
fix radio buttons for sudo category
fixed table side for adder dialogs with external fields
comments for future direction with add_columns
https://fedorahosted.org/freeipa/ticket/1451
https://fedorahosted.org/freeipa/ticket/1462
https://fedorahosted.org/freeipa/ticket/1493
https://fedorahosted.org/freeipa/ticket/1497
https://fedorahosted.org/freeipa/ticket/1532
https://fedorahosted.org/freeipa/ticket/1534
2011-07-25 11:15:14 -05:00
|
|
|
entity: that.entity,
|
2011-02-16 12:46:59 -06:00
|
|
|
name: 'permissions',
|
|
|
|
join: true
|
|
|
|
}));
|
2010-10-25 18:55:57 -05:00
|
|
|
|
|
|
|
return that;
|
2011-01-14 11:16:25 -06:00
|
|
|
};
|
|
|
|
|
2010-10-25 18:55:57 -05:00
|
|
|
|
2011-02-02 10:35:23 -06:00
|
|
|
IPA.target_section = function(spec) {
|
2011-01-28 15:46:19 -06:00
|
|
|
|
2011-02-02 10:35:23 -06:00
|
|
|
spec = spec || {};
|
2010-10-25 18:55:57 -05:00
|
|
|
|
2011-01-12 18:51:22 -06:00
|
|
|
var that = IPA.details_section(spec);
|
2011-06-27 11:10:32 -05:00
|
|
|
that.section = true;
|
2011-02-02 10:35:23 -06:00
|
|
|
that.undo = typeof spec.undo == 'undefined' ? true : spec.undo;
|
|
|
|
|
removing setters setup and init
change widget and widget unit tests to hold on to entity, not entity name.
Replacing entity_name with entity.name in most places.
The one exception is columns for table_widget.
Widgets that refer to other entities have to have late resolution of the entity object, due to circular dependencies.
cleanup entity assignment.
removed template and layout,
merged setup into create
adder dialogs adjust height for external
removed init from widget, isection, association, facet, host and service
Make unit tests use factory.
fix functional tests to click find link correctly.
tweak to activation test, but still broken.
moved initialization code to the end
use --all for hbacrule find, so the type shows up now
fixed dns exception code and exception handling for get_entity
replace metadata look up with value from entity.
fixed author lines
removed duplicate columns in managed by facets.
tweak to nav fix in order to initialize tab.
more defensive code
update metadata for true false
one line init for entity_name in widget
move init code to end of constructor functions
moved constants to start of function for adder_dialog
external fields for dialogs initialized at dialog creation
sudo sections: move add fields and columns to widget definition.
The parameter validation in IPA.column ...This is precondition checking. Note that it merely throws an exception if the entity_name is not set. I want this stuff at the top of the function so that it is obvious to people looking to use them what is required. I added a comment to make this clear, but I'd like to keep precondition checking at the top of the function.
decreased the scope of the pkey_name and moved the initiailzation fof columns into the setup_column function for association_tables
return false at the end of click handler
removed blank labels in sudo command section
fix radio buttons for sudo category
fixed table side for adder dialogs with external fields
comments for future direction with add_columns
https://fedorahosted.org/freeipa/ticket/1451
https://fedorahosted.org/freeipa/ticket/1462
https://fedorahosted.org/freeipa/ticket/1493
https://fedorahosted.org/freeipa/ticket/1497
https://fedorahosted.org/freeipa/ticket/1532
https://fedorahosted.org/freeipa/ticket/1534
2011-07-25 11:15:14 -05:00
|
|
|
that.filter_text = IPA.text_widget({
|
|
|
|
name: 'filter',
|
|
|
|
undo: that.undo,
|
|
|
|
entity: spec.entity
|
|
|
|
});
|
2011-02-07 22:02:43 -06:00
|
|
|
that.subtree_textarea = IPA.textarea_widget({
|
removing setters setup and init
change widget and widget unit tests to hold on to entity, not entity name.
Replacing entity_name with entity.name in most places.
The one exception is columns for table_widget.
Widgets that refer to other entities have to have late resolution of the entity object, due to circular dependencies.
cleanup entity assignment.
removed template and layout,
merged setup into create
adder dialogs adjust height for external
removed init from widget, isection, association, facet, host and service
Make unit tests use factory.
fix functional tests to click find link correctly.
tweak to activation test, but still broken.
moved initialization code to the end
use --all for hbacrule find, so the type shows up now
fixed dns exception code and exception handling for get_entity
replace metadata look up with value from entity.
fixed author lines
removed duplicate columns in managed by facets.
tweak to nav fix in order to initialize tab.
more defensive code
update metadata for true false
one line init for entity_name in widget
move init code to end of constructor functions
moved constants to start of function for adder_dialog
external fields for dialogs initialized at dialog creation
sudo sections: move add fields and columns to widget definition.
The parameter validation in IPA.column ...This is precondition checking. Note that it merely throws an exception if the entity_name is not set. I want this stuff at the top of the function so that it is obvious to people looking to use them what is required. I added a comment to make this clear, but I'd like to keep precondition checking at the top of the function.
decreased the scope of the pkey_name and moved the initiailzation fof columns into the setup_column function for association_tables
return false at the end of click handler
removed blank labels in sudo command section
fix radio buttons for sudo category
fixed table side for adder dialogs with external fields
comments for future direction with add_columns
https://fedorahosted.org/freeipa/ticket/1451
https://fedorahosted.org/freeipa/ticket/1462
https://fedorahosted.org/freeipa/ticket/1493
https://fedorahosted.org/freeipa/ticket/1497
https://fedorahosted.org/freeipa/ticket/1532
https://fedorahosted.org/freeipa/ticket/1534
2011-07-25 11:15:14 -05:00
|
|
|
entity: spec.entity,
|
2011-02-07 22:02:43 -06:00
|
|
|
name: 'subtree',
|
|
|
|
cols: 30, rows: 1,
|
|
|
|
undo: that.undo
|
|
|
|
});
|
2011-07-15 12:18:59 -05:00
|
|
|
that.group_select = IPA.entity_select_widget({
|
|
|
|
name: 'targetgroup',
|
|
|
|
other_entity: 'group',
|
|
|
|
other_field: 'cn',
|
|
|
|
undo: that.undo
|
|
|
|
});
|
removing setters setup and init
change widget and widget unit tests to hold on to entity, not entity name.
Replacing entity_name with entity.name in most places.
The one exception is columns for table_widget.
Widgets that refer to other entities have to have late resolution of the entity object, due to circular dependencies.
cleanup entity assignment.
removed template and layout,
merged setup into create
adder dialogs adjust height for external
removed init from widget, isection, association, facet, host and service
Make unit tests use factory.
fix functional tests to click find link correctly.
tweak to activation test, but still broken.
moved initialization code to the end
use --all for hbacrule find, so the type shows up now
fixed dns exception code and exception handling for get_entity
replace metadata look up with value from entity.
fixed author lines
removed duplicate columns in managed by facets.
tweak to nav fix in order to initialize tab.
more defensive code
update metadata for true false
one line init for entity_name in widget
move init code to end of constructor functions
moved constants to start of function for adder_dialog
external fields for dialogs initialized at dialog creation
sudo sections: move add fields and columns to widget definition.
The parameter validation in IPA.column ...This is precondition checking. Note that it merely throws an exception if the entity_name is not set. I want this stuff at the top of the function so that it is obvious to people looking to use them what is required. I added a comment to make this clear, but I'd like to keep precondition checking at the top of the function.
decreased the scope of the pkey_name and moved the initiailzation fof columns into the setup_column function for association_tables
return false at the end of click handler
removed blank labels in sudo command section
fix radio buttons for sudo category
fixed table side for adder dialogs with external fields
comments for future direction with add_columns
https://fedorahosted.org/freeipa/ticket/1451
https://fedorahosted.org/freeipa/ticket/1462
https://fedorahosted.org/freeipa/ticket/1493
https://fedorahosted.org/freeipa/ticket/1497
https://fedorahosted.org/freeipa/ticket/1532
https://fedorahosted.org/freeipa/ticket/1534
2011-07-25 11:15:14 -05:00
|
|
|
that.type_select = IPA.select_widget({
|
|
|
|
name: 'type',
|
|
|
|
undo: that.undo
|
|
|
|
});
|
2011-02-07 22:02:43 -06:00
|
|
|
that.attribute_table = IPA.attributes_widget({
|
removing setters setup and init
change widget and widget unit tests to hold on to entity, not entity name.
Replacing entity_name with entity.name in most places.
The one exception is columns for table_widget.
Widgets that refer to other entities have to have late resolution of the entity object, due to circular dependencies.
cleanup entity assignment.
removed template and layout,
merged setup into create
adder dialogs adjust height for external
removed init from widget, isection, association, facet, host and service
Make unit tests use factory.
fix functional tests to click find link correctly.
tweak to activation test, but still broken.
moved initialization code to the end
use --all for hbacrule find, so the type shows up now
fixed dns exception code and exception handling for get_entity
replace metadata look up with value from entity.
fixed author lines
removed duplicate columns in managed by facets.
tweak to nav fix in order to initialize tab.
more defensive code
update metadata for true false
one line init for entity_name in widget
move init code to end of constructor functions
moved constants to start of function for adder_dialog
external fields for dialogs initialized at dialog creation
sudo sections: move add fields and columns to widget definition.
The parameter validation in IPA.column ...This is precondition checking. Note that it merely throws an exception if the entity_name is not set. I want this stuff at the top of the function so that it is obvious to people looking to use them what is required. I added a comment to make this clear, but I'd like to keep precondition checking at the top of the function.
decreased the scope of the pkey_name and moved the initiailzation fof columns into the setup_column function for association_tables
return false at the end of click handler
removed blank labels in sudo command section
fix radio buttons for sudo category
fixed table side for adder dialogs with external fields
comments for future direction with add_columns
https://fedorahosted.org/freeipa/ticket/1451
https://fedorahosted.org/freeipa/ticket/1462
https://fedorahosted.org/freeipa/ticket/1493
https://fedorahosted.org/freeipa/ticket/1497
https://fedorahosted.org/freeipa/ticket/1532
https://fedorahosted.org/freeipa/ticket/1534
2011-07-25 11:15:14 -05:00
|
|
|
entity: spec.entity,
|
|
|
|
name: 'attrs',
|
|
|
|
undo: that.undo
|
|
|
|
});
|
2011-02-07 22:02:43 -06:00
|
|
|
|
|
|
|
that.add_field(that.filter_text);
|
|
|
|
that.add_field(that.subtree_textarea);
|
|
|
|
that.add_field(that.group_select );
|
|
|
|
that.add_field(that.type_select);
|
|
|
|
that.add_field(that.attribute_table);
|
|
|
|
|
|
|
|
|
2011-02-10 15:48:17 -06:00
|
|
|
/*TODO these next two functions are work arounds for missing attribute
|
|
|
|
permissions for the filter text. Remove them once that has been fixed */
|
2011-02-07 22:02:43 -06:00
|
|
|
that.filter_text.update = function(){
|
|
|
|
var value = that.filter_text.values && that.filter_text.values.length ?
|
|
|
|
that.filter_text.values[0] : '';
|
2011-02-10 15:48:17 -06:00
|
|
|
$('input[name="'+that.filter_text.name+'"]',
|
|
|
|
that.filter_text.container).val(value);
|
2011-02-07 22:02:43 -06:00
|
|
|
|
|
|
|
var label = $('label[name="'+that.filter_text.name+'"]',
|
|
|
|
that.filter_text.container);
|
|
|
|
var input = $('input[name="'+that.filter_text.name+'"]',
|
|
|
|
that.filter_text.container);
|
2011-02-10 15:48:17 -06:00
|
|
|
label.css('display', 'none');
|
|
|
|
input.css('display', 'inline');
|
2011-02-07 22:02:43 -06:00
|
|
|
};
|
2010-10-25 18:55:57 -05:00
|
|
|
|
2011-02-10 15:48:17 -06:00
|
|
|
that.filter_text.save = function(){
|
|
|
|
var input = $('input[name="'+that.filter_text.name+'"]',
|
|
|
|
that.filter_text.container);
|
2011-03-29 06:24:06 -05:00
|
|
|
var value = input.val();
|
2011-02-10 15:48:17 -06:00
|
|
|
return value === '' ? [] : [value];
|
|
|
|
};
|
2011-01-29 14:25:56 -06:00
|
|
|
|
2011-02-07 22:02:43 -06:00
|
|
|
var target_types = [
|
|
|
|
{
|
|
|
|
name:'filter',
|
|
|
|
create: function(dl){
|
|
|
|
|
|
|
|
$('<dt/>').
|
|
|
|
append($('<label/>', {
|
2011-02-16 12:46:59 -06:00
|
|
|
text: IPA.messages.objects.permission.filter+':'
|
2011-02-07 22:02:43 -06:00
|
|
|
})).
|
|
|
|
appendTo(dl);
|
|
|
|
|
|
|
|
var dd = $('<dd/>', {
|
|
|
|
'class': 'aci_by_filter first'
|
|
|
|
}).appendTo(dl);
|
|
|
|
|
|
|
|
var span = $('<span/>', {
|
|
|
|
name: 'filter'
|
|
|
|
}).appendTo(dd);
|
|
|
|
|
|
|
|
that.filter_text.create(span);
|
|
|
|
},
|
|
|
|
load: function(record){
|
|
|
|
that.filter_text.load(record);
|
|
|
|
},
|
|
|
|
save: function(record){
|
|
|
|
record.filter = that.filter_text.save()[0];
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name:'subtree',
|
|
|
|
create:function(dl) {
|
|
|
|
$('<dt/>').
|
|
|
|
append($('<label/>', {
|
2011-02-16 12:46:59 -06:00
|
|
|
text: IPA.messages.objects.permission.subtree+':'
|
2011-02-07 22:02:43 -06:00
|
|
|
})).
|
|
|
|
appendTo(dl);
|
|
|
|
var dd = $('<dd/>', {
|
|
|
|
'class': 'aci_by_query first'
|
|
|
|
}).appendTo(dl);
|
|
|
|
var span = $('<span/>', {
|
|
|
|
name: 'subtree'
|
|
|
|
}).appendTo(dd);
|
|
|
|
that.subtree_textarea.create(span);
|
|
|
|
},
|
|
|
|
load: function(record){
|
|
|
|
that.subtree_textarea.load(record);
|
|
|
|
},
|
|
|
|
save: function(record){
|
|
|
|
record.subtree = that.subtree_textarea.save()[0];
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name:'targetgroup',
|
|
|
|
create: function (dl) {
|
|
|
|
$('<dt/>').
|
|
|
|
append($('<label/>', {
|
2011-02-16 12:46:59 -06:00
|
|
|
text: IPA.messages.objects.permission.targetgroup+':'
|
2011-02-07 22:02:43 -06:00
|
|
|
})).
|
|
|
|
appendTo(dl);
|
|
|
|
var dd = $('<dd/>', {
|
|
|
|
'class': 'aci_by_group first'
|
|
|
|
}).appendTo(dl);
|
|
|
|
var span = $('<span/>', {
|
|
|
|
name: 'targetgroup'
|
|
|
|
}).appendTo(dd);
|
|
|
|
that.group_select.create(span);
|
|
|
|
},
|
|
|
|
load: function(record){
|
2011-07-15 12:18:59 -05:00
|
|
|
that.group_select.list.val(record.targetgroup);
|
2011-02-07 22:02:43 -06:00
|
|
|
},
|
|
|
|
save: function(record){
|
|
|
|
record.targetgroup = that.group_select.save()[0];
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name:'type',
|
|
|
|
create: function(dl) {
|
|
|
|
$('<dt/>').
|
|
|
|
append($('<label/>', {
|
2011-02-16 12:46:59 -06:00
|
|
|
text: IPA.messages.objects.permission.type+':'
|
2011-02-07 22:02:43 -06:00
|
|
|
})).
|
|
|
|
appendTo(dl);
|
|
|
|
var dd = $('<dd/>', {
|
|
|
|
'class': 'aci_by_type first'
|
|
|
|
}).appendTo(dl);
|
|
|
|
var span = $('<span/>', {
|
|
|
|
name: 'type'
|
|
|
|
}).appendTo(dd);
|
|
|
|
that.type_select.create(span);
|
removing setters setup and init
change widget and widget unit tests to hold on to entity, not entity name.
Replacing entity_name with entity.name in most places.
The one exception is columns for table_widget.
Widgets that refer to other entities have to have late resolution of the entity object, due to circular dependencies.
cleanup entity assignment.
removed template and layout,
merged setup into create
adder dialogs adjust height for external
removed init from widget, isection, association, facet, host and service
Make unit tests use factory.
fix functional tests to click find link correctly.
tweak to activation test, but still broken.
moved initialization code to the end
use --all for hbacrule find, so the type shows up now
fixed dns exception code and exception handling for get_entity
replace metadata look up with value from entity.
fixed author lines
removed duplicate columns in managed by facets.
tweak to nav fix in order to initialize tab.
more defensive code
update metadata for true false
one line init for entity_name in widget
move init code to end of constructor functions
moved constants to start of function for adder_dialog
external fields for dialogs initialized at dialog creation
sudo sections: move add fields and columns to widget definition.
The parameter validation in IPA.column ...This is precondition checking. Note that it merely throws an exception if the entity_name is not set. I want this stuff at the top of the function so that it is obvious to people looking to use them what is required. I added a comment to make this clear, but I'd like to keep precondition checking at the top of the function.
decreased the scope of the pkey_name and moved the initiailzation fof columns into the setup_column function for association_tables
return false at the end of click handler
removed blank labels in sudo command section
fix radio buttons for sudo category
fixed table side for adder dialogs with external fields
comments for future direction with add_columns
https://fedorahosted.org/freeipa/ticket/1451
https://fedorahosted.org/freeipa/ticket/1462
https://fedorahosted.org/freeipa/ticket/1493
https://fedorahosted.org/freeipa/ticket/1497
https://fedorahosted.org/freeipa/ticket/1532
https://fedorahosted.org/freeipa/ticket/1534
2011-07-25 11:15:14 -05:00
|
|
|
|
2011-02-07 22:02:43 -06:00
|
|
|
|
|
|
|
span = $('<dd/>', {
|
|
|
|
name: 'attrs',
|
|
|
|
'class':'other'
|
|
|
|
}).appendTo(dl);
|
|
|
|
|
|
|
|
that.attribute_table.create(span);
|
|
|
|
|
|
|
|
var select = that.type_select.select;
|
|
|
|
|
|
|
|
select.change(function() {
|
|
|
|
that.attribute_table.object_type =
|
|
|
|
that.type_select.save()[0];
|
|
|
|
that.attribute_table.reset();
|
|
|
|
});
|
|
|
|
select.append($('<option/>', {
|
|
|
|
value: '',
|
|
|
|
text: ''
|
|
|
|
}));
|
2011-02-16 12:46:59 -06:00
|
|
|
var type_params = IPA.get_entity_param('permission', 'type');
|
2011-02-07 22:02:43 -06:00
|
|
|
for (var i=0; i<type_params.values.length; i++){
|
|
|
|
select.append($('<option/>', {
|
|
|
|
value: type_params.values[i],
|
|
|
|
text: type_params.values[i]
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
that.type_select.update = function() {
|
|
|
|
that.type_select.select_update();
|
|
|
|
that.attribute_table.object_type =
|
|
|
|
that.type_select.save()[0];
|
|
|
|
that.attribute_table.reset();
|
|
|
|
};
|
|
|
|
},
|
|
|
|
load: function(record){
|
|
|
|
that.type_select.load(record);
|
|
|
|
that.attribute_table.object_type = record.type;
|
|
|
|
that.attribute_table.reset();
|
|
|
|
},
|
|
|
|
save: function(record){
|
|
|
|
record.type = that.type_select.save()[0];
|
|
|
|
record.attrs = that.attribute_table.save().join(',');
|
|
|
|
}
|
|
|
|
}] ;
|
2011-02-01 12:06:58 -06:00
|
|
|
|
2011-02-07 22:02:43 -06:00
|
|
|
var target_type = target_types[0];
|
2011-02-03 21:42:50 -06:00
|
|
|
|
2011-08-31 17:27:32 -05:00
|
|
|
function show_target_type(type_to_show) {
|
|
|
|
for (var i=0; i<target_types.length; i++) {
|
|
|
|
if (target_types[i].name === type_to_show) {
|
2011-02-07 22:02:43 -06:00
|
|
|
target_type = target_types[i];
|
|
|
|
target_type.container.css('display', 'block');
|
2011-08-31 17:27:32 -05:00
|
|
|
} else {
|
2011-02-07 22:02:43 -06:00
|
|
|
target_types[i].container.css('display', 'none');
|
|
|
|
}
|
|
|
|
}
|
2010-10-25 18:55:57 -05:00
|
|
|
}
|
2011-08-31 17:27:32 -05:00
|
|
|
|
2010-10-25 18:55:57 -05:00
|
|
|
that.create = function(container) {
|
2011-02-07 22:02:43 -06:00
|
|
|
|
2011-01-29 14:25:56 -06:00
|
|
|
var dl = $('<dl/>', {
|
|
|
|
'class': 'aci-target'
|
|
|
|
}).appendTo(container);
|
2011-02-07 22:02:43 -06:00
|
|
|
$('<dt>Target:</dt>').appendTo(dl);
|
2011-01-29 14:25:56 -06:00
|
|
|
|
2011-02-07 22:02:43 -06:00
|
|
|
if (that.undo){
|
|
|
|
dl.css('display','none');
|
|
|
|
}
|
|
|
|
that.target_type_select = $('<select></select>',{
|
|
|
|
change:function(){
|
|
|
|
show_target_type(this.value);
|
|
|
|
}});
|
|
|
|
|
|
|
|
$('<dd/>',
|
|
|
|
{"class":"first"}).
|
|
|
|
append(that.target_type_select).appendTo(dl);
|
|
|
|
|
|
|
|
for (var i = 0 ; i < target_types.length; i += 1){
|
|
|
|
target_type = target_types[i];
|
|
|
|
dl = $('<dl/>', {
|
|
|
|
'class': 'aci-target' ,
|
|
|
|
id: target_type.name,
|
|
|
|
style: 'display:none'
|
|
|
|
}).appendTo(container);
|
|
|
|
|
|
|
|
that.target_type_select.append($('<option/>',{
|
|
|
|
text: target_type.name,
|
|
|
|
value : target_type.name
|
2011-02-02 10:35:23 -06:00
|
|
|
}));
|
2011-02-07 22:02:43 -06:00
|
|
|
target_type.create(dl);
|
|
|
|
target_type.container = dl;
|
2011-02-02 10:35:23 -06:00
|
|
|
}
|
2011-01-12 13:47:29 -06:00
|
|
|
};
|
2010-10-25 18:55:57 -05:00
|
|
|
|
2011-08-31 17:27:32 -05:00
|
|
|
function reset_target_widgets() {
|
2011-02-07 22:02:43 -06:00
|
|
|
that.filter_text.record = null;
|
|
|
|
that.subtree_textarea.record = null;
|
|
|
|
that.group_select.record = null;
|
|
|
|
that.type_select.record = null;
|
|
|
|
that.attribute_table.record = null;
|
|
|
|
|
|
|
|
that.filter_text.reset();
|
|
|
|
that.subtree_textarea.reset();
|
|
|
|
that.group_select.reset();
|
|
|
|
that.type_select.reset();
|
|
|
|
that.attribute_table.reset();
|
|
|
|
}
|
2011-01-29 14:25:56 -06:00
|
|
|
|
2011-02-07 22:02:43 -06:00
|
|
|
function set_target_type(record) {
|
2011-01-29 14:25:56 -06:00
|
|
|
|
2011-02-07 22:02:43 -06:00
|
|
|
reset_target_widgets();
|
2011-01-29 14:25:56 -06:00
|
|
|
|
2011-02-07 22:02:43 -06:00
|
|
|
var target_type_name ;
|
|
|
|
for (var i = 0 ; i < target_types.length; i += 1){
|
|
|
|
target_type = target_types[i];
|
|
|
|
if (record[target_type.name]){
|
|
|
|
target_type_name = target_type.name;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!target_type_name){
|
2011-02-16 12:46:59 -06:00
|
|
|
alert(IPA.messages.objects.permission.invalid_target);
|
2011-02-07 22:02:43 -06:00
|
|
|
return;
|
2010-10-25 18:55:57 -05:00
|
|
|
}
|
2011-01-29 14:25:56 -06:00
|
|
|
|
2011-08-31 17:27:32 -05:00
|
|
|
that.target_type_select.val(target_type_name);
|
|
|
|
show_target_type(target_type_name);
|
2011-02-07 22:02:43 -06:00
|
|
|
target_type.load(record);
|
|
|
|
}
|
2011-08-31 17:27:32 -05:00
|
|
|
|
2011-02-07 22:02:43 -06:00
|
|
|
that.load = function(record){
|
2011-01-29 14:25:56 -06:00
|
|
|
that.section_load(record);
|
2011-02-07 22:02:43 -06:00
|
|
|
that.reset();
|
2011-01-29 14:25:56 -06:00
|
|
|
};
|
2011-08-31 17:27:32 -05:00
|
|
|
|
2011-01-29 14:25:56 -06:00
|
|
|
that.reset = function() {
|
|
|
|
that.section_reset();
|
2011-02-02 10:35:23 -06:00
|
|
|
|
2011-08-31 17:27:32 -05:00
|
|
|
if (that.record) {
|
2011-02-07 22:02:43 -06:00
|
|
|
set_target_type(that.record);
|
|
|
|
that.attribute_table.object_type = that.record.type;
|
2011-08-31 17:27:32 -05:00
|
|
|
|
|
|
|
} else {
|
2011-02-07 22:02:43 -06:00
|
|
|
reset_target_widgets();
|
2011-08-31 17:27:32 -05:00
|
|
|
show_target_type(target_types[0].name);
|
2011-02-07 22:02:43 -06:00
|
|
|
}
|
2011-01-28 15:46:19 -06:00
|
|
|
};
|
|
|
|
|
2011-02-02 10:35:23 -06:00
|
|
|
that.save = function(record) {
|
2011-02-07 22:02:43 -06:00
|
|
|
target_type.save(record);
|
2011-01-12 13:47:29 -06:00
|
|
|
};
|
2011-01-29 13:24:00 -06:00
|
|
|
|
2010-10-25 18:55:57 -05:00
|
|
|
return that;
|
2011-01-14 11:16:25 -06:00
|
|
|
};
|
2010-10-25 18:55:57 -05:00
|
|
|
|
2011-01-29 14:25:56 -06:00
|
|
|
IPA.permission_details_facet = function(spec) {
|
|
|
|
|
|
|
|
spec = spec || {};
|
|
|
|
|
|
|
|
var that = IPA.details_facet(spec);
|
|
|
|
|
2010-10-25 18:55:57 -05:00
|
|
|
return that;
|
2011-01-19 20:10:18 -06:00
|
|
|
};
|