summaryrefslogtreecommitdiffstats
path: root/install/ui/aci.js
diff options
context:
space:
mode:
authorEndi S. Dewata <edewata@redhat.com>2011-02-02 10:35:23 -0600
committerAdam Young <ayoung@redhat.com>2011-02-02 15:56:50 -0500
commitd389e054f6173194daabc08ad3abd366005048bd (patch)
treeb1f0bf85e7095c6215c8989a8c720da81d46104c /install/ui/aci.js
parent0353a2be677594125892e16fe0cdebe264d2ccb2 (diff)
downloadfreeipa-d389e054f6173194daabc08ad3abd366005048bd.tar.gz
freeipa-d389e054f6173194daabc08ad3abd366005048bd.tar.xz
freeipa-d389e054f6173194daabc08ad3abd366005048bd.zip
Added undo for permission target.
https://fedorahosted.org/freeipa/ticket/885
Diffstat (limited to 'install/ui/aci.js')
-rw-r--r--install/ui/aci.js314
1 files changed, 151 insertions, 163 deletions
diff --git a/install/ui/aci.js b/install/ui/aci.js
index 67c2d5f87..036731237 100644
--- a/install/ui/aci.js
+++ b/install/ui/aci.js
@@ -24,7 +24,7 @@
/* REQUIRES: ipa.js, details.js, search.js, add.js, entity.js */
-IPA.attribute_table_widget = function(spec) {
+IPA.attributes_widget = function(spec) {
spec = spec || {};
@@ -35,38 +35,43 @@ IPA.attribute_table_widget = function(spec) {
var id = spec.name;
var dd_class = "other";
- that.create = function(container){
+ that.create = function(container) {
var dd = $('<dd/>', {
'class': dd_class
}).appendTo(container);
- var span = $('<span/>', {
- name: 'attrs'
- }).appendTo(dd);
-
that.table = $('<table/>', {
id:id,
- 'class':'search-table aci-attribute-table'}).
+ 'class':'search-table aci-attribute-table'
+ }).
append('<thead/>').
- append($('<tbody/>')).
- appendTo(span);
+ append('<tbody/>').
+ appendTo(dd);
var tr = $('<tr></tr>').appendTo($('thead', that.table));
- tr.append($('<th/>',{
+ tr.append($('<th/>', {
style:"height:2em; vertical-align:bottom;",
html:$('<input/>',{
type: "checkbox",
click: function(){
$('.aci-attribute').
attr('checked', $(this).attr('checked'));
- }})
+ },
+ change: function() {
+ that.show_undo();
+ }
+ })
})).
append('<th class="aci-attribute-column">Attribute</th>');
+
+ if (that.undo) {
+ that.create_undo(dd);
+ }
+
if (that.object_type){
that.populate (that.object_type);
}
-
};
that.load = function(record) {
@@ -85,11 +90,11 @@ IPA.attribute_table_widget = function(spec) {
that.update = function() {
that.populate(that.object_type);
- that.checkboxes_update();
that.append();
+ that.checkboxes_update();
};
- that.populate = function(object_type){
+ that.populate = function(object_type) {
$('tbody tr', that.table).remove();
@@ -100,22 +105,21 @@ IPA.attribute_table_widget = function(spec) {
var aciattrs = metadata.aciattrs;
- var attr_per_col = 400;
- var col_span = aciattrs.length / attr_per_col + 1;
-
var tbody = $('tbody', that.table);
- var td;
- for (var a = 0; a < aciattrs.length ; a += 1){
- var value = aciattrs[a].toLowerCase();
- var aci_tr = $('<tr/>').appendTo(tbody);
- td = $('<td/>').appendTo(aci_tr);
+ 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);
td.append($('<input/>',{
type: 'checkbox',
- id: 'aciattr-'+value,
- name: 'attrs',
+ name: that.name,
value: value,
- 'class': 'aci-attribute'
+ 'class': 'aci-attribute',
+ change: function() {
+ that.show_undo();
+ }
}));
td = $('<td/>').appendTo(aci_tr);
td.append($('<label/>',{
@@ -130,14 +134,13 @@ IPA.attribute_table_widget = function(spec) {
var unmatched = [];
for (var i=0; i<that.values.length; i++) {
- var cb = $('#aciattr-'+that.values[i]);
- if (!cb.length){
+ var input = $('input[name="'+that.name+'"][value="'+that.values[i]+'"]', that.container);
+ if (!input.length) {
unmatched.push(that.values[i]);
}
- cb.attr('checked',true);
}
- if (unmatched.length > 0){
+ if (unmatched.length > 0) {
var tbody = $('tbody', that.table);
for (var j=0; j<unmatched.length; j++) {
@@ -147,11 +150,12 @@ IPA.attribute_table_widget = function(spec) {
var td = $('<td/>').appendTo(tr);
td.append($('<input/>', {
type: 'checkbox',
- checked: true,
- id: 'aciattr-'+value,
- name: 'attrs',
+ name: that.name,
value: value,
- 'class': 'aci-attribute'
+ 'class': 'aci-attribute',
+ change: function() {
+ that.show_undo();
+ }
}));
td = $('<td/>').appendTo(tr);
@@ -165,47 +169,24 @@ IPA.attribute_table_widget = function(spec) {
return that;
};
-
-
-IPA.type_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: 'object_type_select'
- }).appendTo(container);
- };
-
- return that;
-};
-
-
-
-IPA.rights_widget = function(spec){
- var rights = ['write','add','delete'];
+IPA.rights_widget = function(spec) {
var that = IPA.checkboxes_widget(spec);
- that.id = spec.id;
+
+ that.rights = ['write', 'add', 'delete'];
that.create = function(container){
- for (var i = 0; i < rights.length; i++){
+ for (var i = 0; i<that.rights.length; i++) {
$('<dd/>').
append($('<input/>', {
type: 'checkbox',
- id: rights[i],
name: that.name,
- value: rights[i],
+ value: that.rights[i],
'class': that.entity_name +'_'+ that.name
})).
append($('<label/>', {
- text: rights[i]
+ text: that.rights[i]
})).
appendTo(container);
}
@@ -220,7 +201,7 @@ IPA.rights_widget = function(spec){
};
-IPA.hidden_widget = function(spec){
+IPA.hidden_widget = function(spec) {
spec.label = '';
var that = IPA.widget(spec);
that.id = spec.id;
@@ -244,7 +225,7 @@ IPA.hidden_widget = function(spec){
};
-IPA.rights_section = function () {
+IPA.rights_section = function() {
var spec = {
'name':'rights',
'label': 'Rights'
@@ -256,20 +237,19 @@ IPA.rights_section = function () {
};
-IPA.target_section = function () {
+IPA.target_section = function(spec) {
- var spec = {
- 'name':'target',
- 'label': 'Target'
- };
+ spec = spec || {};
var that = IPA.details_section(spec);
+ that.undo = typeof spec.undo == 'undefined' ? true : spec.undo;
+
var groupings = ['aci_by_type', 'aci_by_query', 'aci_by_group',
'aci_by_filter' ];
var inputs = ['input', 'select', 'textarea'];
- function disable_inputs(){
+ function disable_inputs() {
for (var g = 0; g < groupings.length; g += 1 ){
for (var t = 0 ; t < inputs.length; t += 1){
$('.' + groupings[g] + ' '+ inputs[t]).
@@ -277,14 +257,14 @@ IPA.target_section = function () {
}
}
}
- function enable_by(grouping){
+ function enable_by(grouping) {
for (var t = 0 ; t < inputs.length; t += 1){
$('.' + grouping + ' '+ inputs[t]).
attr('disabled', '');
}
}
- function display_filter_target(dl){
+ function display_filter_target(dl) {
$('<dt/>').
append($('<input/>', {
type: 'radio',
@@ -297,25 +277,21 @@ IPA.target_section = function () {
})).
appendTo(dl);
- $('<dd/>', {
- 'class': 'aci_by_filter first'
+ var span = $('<span/>', {
+ name: 'filter'
}).
- append(
- $('<span/>', {
- name: 'filter'
- }).
- append(
- $('<input/>', {
- name: 'filter',
- disabled: 'true',
- type: 'text',
- id: 'aci_filter'
- }))).
appendTo(dl);
+
+ var dd = $('<dd/>', {
+ 'class': 'aci_by_filter first'
+ }).
+ appendTo(span);
+
+ that.filter_text.create(dd);
}
- function display_type_target(dl){
+ function display_type_target(dl) {
$('<dt/>').
append($('<input/>', {
type: 'radio',
@@ -338,31 +314,14 @@ IPA.target_section = function () {
that.type_select.create(span);
- var select = that.type_select.select;
- select.change(function() {
- that.attribute_table.object_type = this.options[this.selectedIndex].value;
- that.attribute_table.reset();
- });
-
- select.append($('<option/>', {
- value: '',
- text: ''
- }));
-
- var type_params = IPA.get_param_info('permission', 'type');
- for (var pc =0; pc < type_params.values.length; pc += 1){
- select.append($('<option/>', {
- value: type_params.values[pc],
- text: type_params.values[pc]
- }));
- }
-
- that.attribute_table = that.get_field('attrs');
+ span = $('<span/>', {
+ name: 'attrs'
+ }).appendTo(dl);
- that.attribute_table.create(dl);
+ that.attribute_table.create(span);
}
- function display_query_target(dl){
+ function display_query_target(dl) {
$('<dt/>').
append($('<input/>', {
type: 'radio',
@@ -374,25 +333,19 @@ IPA.target_section = function () {
})).
appendTo(dl);
- $('<dd/>', {
- 'class': 'aci_by_query first'
- }).append(
- $('<span/>', {
- name: 'subtree'
- }).append(
- $('<textarea/>', {
- name: 'subtree',
- id: 'aci_query_text',
- cols: '30',
- rows: '1'
- }))).
- appendTo(dl);
- }
+ var span = $('<span/>', {
+ name: 'subtree'
+ }).appendTo(dl);
- function display_group_target(dl){
+ var dd = $('<dd/>', {
+ 'class': 'aci_by_query first'
+ }).appendTo(span);
+ that.subtree_textarea.create(dd);
+ }
- $('<dt/>' ).
+ function display_group_target(dl) {
+ $('<dt/>').
append($('<input />', {
type: 'radio',
name: 'aci_type',
@@ -403,17 +356,15 @@ IPA.target_section = function () {
})).
appendTo(dl);
-
var span = $('<span/>', {
name: 'targetgroup'
}).appendTo(dl);
- var dd = $('<dd/>', {
+ var dd = $('<dd/>', {
'class': 'aci_by_group first'
}).
appendTo(span);
-
that.group_select.create(dd);
}
@@ -427,22 +378,22 @@ IPA.target_section = function () {
display_group_target(dl);
display_type_target(dl);
- $('#aci_by_filter', dl).click(function (){
+ $('#aci_by_filter', dl).click(function() {
disable_inputs();
enable_by(groupings[3]);
});
- $('#aci_by_type', dl).click(function (){
+ $('#aci_by_type', dl).click(function() {
disable_inputs();
enable_by(groupings[0]);
});
- $('#aci_by_query', dl).click(function (){
+ $('#aci_by_query', dl).click(function() {
disable_inputs();
enable_by(groupings[1]);
});
- $('#aci_by_group', dl).click(function (){
+ $('#aci_by_group', dl).click(function() {
disable_inputs();
enable_by(groupings[2]);
});
@@ -452,6 +403,32 @@ IPA.target_section = function () {
that.setup = function(container) {
that.section_setup(container);
+
+ 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: ''
+ }));
+
+ var type_params = IPA.get_param_info('permission', 'type');
+ 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();
+ };
};
function set_aci_type(record) {
@@ -489,34 +466,43 @@ IPA.target_section = function () {
};
that.init = function() {
- that.add_field(IPA.text_widget({name: 'filter'}));
- that.add_field(IPA.textarea_widget({name: 'subtree'}));
+ that.filter_text = IPA.text_widget({name: 'filter', undo: that.undo});
+ that.add_field(that.filter_text);
+
+ that.subtree_textarea = IPA.textarea_widget({
+ name: 'subtree',
+ cols: 30, rows: 1,
+ undo: that.undo
+ });
+ that.add_field(that.subtree_textarea);
that.group_select = IPA.entity_select_widget(
- {name: 'targetgroup', entity:'group'});
+ {name: 'targetgroup', entity:'group', undo: that.undo});
that.add_field(that.group_select);
- that.type_select = IPA.type_widget({name: 'type'});
+ that.type_select = IPA.select_widget({name: 'type', undo: that.undo});
that.add_field(that.type_select);
- that.attribute_table = IPA.attribute_table_widget({name: 'attrs'});
+ that.attribute_table = IPA.attributes_widget({name: 'attrs', undo: that.undo});
that.add_field(that.attribute_table);
};
- that.save = function (record){
+ that.save = function(record) {
var record_type = $("input[name='aci_type']:checked").attr('id');
- if (record_type === 'aci_by_group'){
+ if (record_type === 'aci_by_group') {
record.targetgroup = that.group_select.save()[0];
- }else if (record_type === 'aci_by_type'){
- record.type = $('#object_type_select option:selected').val();
+
+ } else if (record_type === 'aci_by_type') {
+ record.type = that.type_select.save()[0];
record.attrs = that.attribute_table.save().join(',');
- }else if (record_type === 'aci_by_query'){
- record.subtree = $('#aci_query_text').val();
- }else if (record_type === 'aci_by_filter'){
- var filter = $('#aci_filter').val();
- record.filter = filter;
+
+ } else if (record_type === 'aci_by_query') {
+ record.subtree = that.subtree_textarea.save([0]);
+
+ } else if (record_type === 'aci_by_filter') {
+ record.filter = that.filter_text.save()[0];
}
};
@@ -557,7 +543,7 @@ IPA.permission_details_facet = function(spec) {
return that;
};
-IPA.entity_factories.permission = function () {
+IPA.entity_factories.permission = function() {
return IPA.entity({
'name': 'permission'
@@ -572,7 +558,7 @@ IPA.entity_factories.permission = function () {
undo: false
})).
field(IPA.rights_widget({name: 'permissions', label: 'Permissions', join: true, undo: false})).
- section(IPA.target_section())).
+ section(IPA.target_section({name: 'target', label: 'Target', undo: false}))).
facet(IPA.search_facet().
column({name:'cn'})).
facet(IPA.permission_details_facet({ name: 'details' }).
@@ -580,12 +566,12 @@ IPA.entity_factories.permission = function () {
IPA.stanza({name:'identity', label:'Identity'}).
input({name: 'cn', 'read_only': true})).
section(IPA.rights_section()).
- section(IPA.target_section()));
+ section(IPA.target_section({name: 'target', label: 'Target'})));
};
-IPA.entity_factories.privilege = function() {
+IPA.entity_factories.privilege = function() {
var that = IPA.entity({
'name': 'privilege'
}).
@@ -619,7 +605,7 @@ IPA.entity_factories.privilege = function() {
};
-IPA.entity_factories.role = function() {
+IPA.entity_factories.role = function() {
return IPA.entity({
'name': 'role'
}).
@@ -648,7 +634,7 @@ IPA.entity_factories.role = function() {
};
-IPA.entity_factories.selfservice = function() {
+IPA.entity_factories.selfservice = function() {
return IPA.entity({
'name': 'selfservice'
}).
@@ -659,7 +645,7 @@ IPA.entity_factories.selfservice = function() {
section(
IPA.stanza({name:'general', label:'General'}).
input({name:'aciname'}).
- custom_input(IPA.attribute_table_widget({
+ custom_input(IPA.attributes_widget({
object_type:'user',
name:'attrs'
})))).
@@ -669,14 +655,14 @@ IPA.entity_factories.selfservice = function() {
title: 'Add Self Service Definition'
}).
field(IPA.text_widget({ name: 'aciname', undo: false})).
- field(IPA.attribute_table_widget({
+ field(IPA.attributes_widget({
object_type:'user',
name:'attrs'
})));
};
-IPA.entity_factories.delegation = function() {
+IPA.entity_factories.delegation = function() {
var that = IPA.entity({
'name': 'delegation'
}).facet(
@@ -694,20 +680,22 @@ IPA.entity_factories.delegation = function() {
entity:'group', join: true})).
custom_input(
IPA.rights_widget({name: 'permissions', label: 'Permissions',
- id:'delegation_rights', join: true})).
+ join: true})).
custom_input(
- IPA.attribute_table_widget({
+ IPA.attributes_widget({
name:'attrs', object_type:'user', join: true})))).
add_dialog(IPA.add_dialog({
name: 'add',
- title: 'Add Delegation'
+ title: 'Add Delegation',
+ width: '700px'
}).
- field(IPA.text_widget({ name: 'aciname', undo: false})).
- field(IPA.entity_select_widget({name:'group',
- entity:'group'})).
- field(IPA.entity_select_widget({name:'memberof',
- entity:'group', join: true})).
- field(IPA.attribute_table_widget({ name: 'attrs', object_type:'user', join: true}))).
+ field(IPA.text_widget({ name: 'aciname', undo: false})).
+ field(IPA.entity_select_widget({name:'group',
+ entity:'group', undo: false})).
+ field(IPA.entity_select_widget({name:'memberof', entity:'group',
+ join: true, undo: false})).
+ field(IPA.attributes_widget({ name: 'attrs', object_type:'user',
+ join: true, undo: false}))).
standard_associations();
return that;