Fixed URL parameter parsing.

The $.bbq.getState() invocations have been modified not to coerce
URL parameter values to avoid parsing error.

Ticket #1208
This commit is contained in:
Endi S. Dewata 2011-05-23 17:48:37 -05:00 committed by Adam Young
parent ac23fa7e54
commit 58c1950566
10 changed files with 71 additions and 74 deletions

View File

@ -527,7 +527,7 @@ IPA.association_table_widget = function (spec) {
};
that.create_add_dialog = function() {
var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
var pkey = $.bbq.getState(that.entity_name+'-pkey');
var label = IPA.metadata.objects[that.other_entity].label;
var title = IPA.messages.association.add;
@ -575,7 +575,7 @@ IPA.association_table_widget = function (spec) {
that.add = function(values, on_success, on_error) {
var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
var pkey = $.bbq.getState(that.entity_name+'-pkey');
var command = IPA.command({
entity: that.entity_name,
@ -600,7 +600,7 @@ IPA.association_table_widget = function (spec) {
return;
}
var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
var pkey = $.bbq.getState(that.entity_name+'-pkey');
var label = IPA.metadata.objects[that.other_entity].label;
var title = IPA.messages.association.remove;
@ -638,7 +638,7 @@ IPA.association_table_widget = function (spec) {
that.remove = function(values, on_success, on_error) {
var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
var pkey = $.bbq.getState(that.entity_name+'-pkey');
var command = IPA.command({
entity: that.entity_name,
@ -653,6 +653,29 @@ IPA.association_table_widget = function (spec) {
command.execute();
};
that.refresh = function() {
function on_success(data, text_status, xhr) {
that.load(data.result.result);
}
function on_error(xhr, text_status, error_thrown) {
var summary = $('span[name=summary]', that.tfoot).empty();
summary.append('<p>Error: '+error_thrown.name+'</p>');
summary.append('<p>'+error_thrown.message+'</p>');
}
var pkey = $.bbq.getState(that.entity_name+'-pkey');
IPA.command({
entity: that.entity_name,
method: 'show',
args: [pkey],
options: {'all': true, 'rights': true},
on_success: on_success,
on_error: on_error
}).execute();
};
// methods that should be invoked by subclasses
that.association_table_widget_init = that.init;
@ -787,7 +810,7 @@ IPA.association_facet = function (spec) {
};
that.is_dirty = function() {
var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
var pkey = $.bbq.getState(that.entity_name+'-pkey');
return pkey != that.pkey;
};
@ -795,7 +818,7 @@ IPA.association_facet = function (spec) {
that.facet_create_header(container);
that.pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
that.pkey = $.bbq.getState(that.entity_name+'-pkey');
var other_label = IPA.metadata.objects[that.other_entity].label;
var title = that.title;
@ -845,7 +868,7 @@ IPA.association_facet = function (spec) {
that.show = function() {
that.facet_show();
that.pkey = $.bbq.getState(that.entity_name+'-pkey', true) || '';
that.pkey = $.bbq.getState(that.entity_name+'-pkey');
that.entity.header.set_pkey(that.pkey);
that.entity.header.back_link.css('visibility', 'visible');
@ -854,7 +877,7 @@ IPA.association_facet = function (spec) {
that.show_add_dialog = function() {
var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
var pkey = $.bbq.getState(that.entity_name+'-pkey');
var label = IPA.metadata.objects[that.other_entity] ? IPA.metadata.objects[that.other_entity].label : that.other_entity;
var title = IPA.messages.association.add;
@ -877,7 +900,7 @@ IPA.association_facet = function (spec) {
dialog.execute = function() {
var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
var pkey = $.bbq.getState(that.entity_name+'-pkey');
var associator = that.associator({
'entity_name': that.entity_name,
@ -915,7 +938,7 @@ IPA.association_facet = function (spec) {
return;
}
var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
var pkey = $.bbq.getState(that.entity_name+'-pkey');
var title = IPA.messages.association.remove;
title = title.replace('${entity}', that.entity_name);
@ -966,7 +989,7 @@ IPA.association_facet = function (spec) {
'rights': true
};
var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
var pkey = $.bbq.getState(that.entity_name+'-pkey');
var args =[];
/* TODO: make a general solution to generate this value */
var relationship_filter = 'in_' + that.entity_name;

View File

@ -336,7 +336,7 @@ IPA.details_facet = function(spec) {
that.facet_create_header(container);
that.pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
that.pkey = $.bbq.getState(that.entity_name+'-pkey');
var label = IPA.metadata.objects[that.entity_name].label;
var title = that.title;
@ -462,7 +462,7 @@ IPA.details_facet = function(spec) {
that.show = function() {
that.facet_show();
that.pkey = $.bbq.getState(that.entity_name+'-pkey', true) || '';
that.pkey = $.bbq.getState(that.entity_name+'-pkey');
that.entity.header.set_pkey(that.pkey);
if (that.entity.facets.length == 1) {
@ -489,7 +489,7 @@ IPA.details_facet = function(spec) {
};
function new_key(){
var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
var pkey = $.bbq.getState(that.entity_name+'-pkey');
return pkey != that.pkey;
}
that.new_key = new_key;
@ -608,7 +608,7 @@ IPA.details_facet = function(spec) {
that.refresh = function() {
that.pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
that.pkey = $.bbq.getState(that.entity_name+'-pkey');
var command = IPA.command({
entity: that.entity_name,

View File

@ -211,7 +211,7 @@ IPA.records_facet = function(spec) {
dialog.add = function() {
var pkey = $.bbq.getState(that.entity_name+'-pkey', true);
var pkey = $.bbq.getState(that.entity_name+'-pkey');
var resource = dialog.resource.val();
var options = {};
@ -244,7 +244,7 @@ IPA.records_facet = function(spec) {
return;
}
var zone = $.bbq.getState('dnszone-pkey', true);
var zone = $.bbq.getState('dnszone-pkey');
var records = [];
@ -330,8 +330,8 @@ IPA.records_facet = function(spec) {
};
that.is_dirty = function() {
var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
var record = $.bbq.getState(that.entity_name + '-record', true) || '';
var pkey = $.bbq.getState(that.entity_name+'-pkey');
var record = $.bbq.getState(that.entity_name+'-record');
return pkey != that.pkey || record != that.record;
};
@ -415,8 +415,8 @@ IPA.records_facet = function(spec) {
that.show = function() {
that.facet_show();
that.record = $.bbq.getState(that.entity_name + '-record', true) || '';
that.pkey = $.bbq.getState(that.entity_name+'-pkey', true) || '';
that.record = $.bbq.getState(that.entity_name+'-record');
that.pkey = $.bbq.getState(that.entity_name+'-pkey');
that.entity.header.set_pkey(that.pkey);
that.entity.header.back_link.css('visibility', 'visible');
@ -497,7 +497,7 @@ IPA.records_facet = function(spec) {
options.data = data_filter;
}
*/
var args = [$.bbq.getState(that.entity_name + '-pkey', true)];
var args = [$.bbq.getState(that.entity_name+'-pkey')];
if (filter) {
args.push(filter);

View File

@ -364,8 +364,7 @@ IPA.entity = function (spec) {
var current_entity = that;
current_entity = current_entity.containing_entity;
while(current_entity !== null){
pkey.unshift(
$.bbq.getState(current_entity.name + '-pkey', true) || '');
pkey.unshift($.bbq.getState(current_entity.name+'-pkey'));
current_entity = current_entity.containing_entity;
}
return pkey;
@ -375,8 +374,7 @@ IPA.entity = function (spec) {
that.get_primary_key = function() {
var pkey = that.get_primary_key_prefix();
var current_entity = that;
pkey.unshift(
$.bbq.getState(current_entity.name + '-pkey', true) || '');
pkey.unshift($.bbq.getState(current_entity.name+'-pkey'));
return pkey;
};
@ -387,7 +385,7 @@ IPA.entity = function (spec) {
};
IPA.current_facet = function (entity){
var facet_name = $.bbq.getState(entity.name + '-facet', true);
var facet_name = $.bbq.getState(entity.name+'-facet');
var facets = entity.facets.values;
if (!facet_name && facets.length) {
facet_name = facets[0].name;
@ -473,7 +471,7 @@ IPA.entity_header = function(spec) {
that.select_tab = function() {
$(that.facet_tabs).find('a').removeClass('selected');
var facet_name = $.bbq.getState(that.entity.name + '-facet', true);
var facet_name = $.bbq.getState(that.entity.name+'-facet');
if (!facet_name || facet_name === 'default') {
that.facet_tabs.find('a:first').addClass('selected');
@ -490,8 +488,7 @@ IPA.entity_header = function(spec) {
while(current_entity){
breadcrumb.unshift($('<a/>',{
text:$.bbq.getState(current_entity.name + '-pkey', true) ||
'',
text:$.bbq.getState(current_entity.name+'-pkey'),
title: current_entity.name,
click: function() {
var entity = IPA.get_entity((this.title));
@ -538,7 +535,7 @@ IPA.entity_header = function(spec) {
return false;
}
var pkey = $.bbq.getState(that.entity.name+'-pkey', true);
var pkey = $.bbq.getState(that.entity.name+'-pkey');
IPA.nav.show_page(that.entity.name, other_facet.name, pkey);
$('a', that.facet_tabs).removeClass('selected');

View File

@ -341,7 +341,7 @@ IPA.hbacrule_details_facet = function (spec) {
that.update = function() {
var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
var pkey = $.bbq.getState(that.entity_name+'-pkey');
var modify_operation = {
'execute': false,
@ -837,7 +837,7 @@ IPA.hbacrule_accesstime_widget = function (spec) {
that.add = function() {
var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
var pkey = $.bbq.getState(that.entity_name+'-pkey');
var title = IPA.messages.association.add;
title = title.replace('${entity}', IPA.metadata.objects[that.entity_name].label);
title = title.replace('${primary_key}', pkey);
@ -946,7 +946,7 @@ IPA.hbacrule_accesstime_widget = function (spec) {
return;
}
var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
var pkey = $.bbq.getState(that.entity_name+'-pkey');
title = IPA.messages.association.remove;
title = title.replace('${entity}', IPA.metadata.objects[that.entity_name].label);
title = title.replace('${primary_key}', pkey);
@ -1002,7 +1002,7 @@ IPA.hbacrule_accesstime_widget = function (spec) {
summary.append('<p>'+error_thrown.message+'</p>');
}
var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
var pkey = $.bbq.getState(that.entity_name+'-pkey');
IPA.command({
entity: that.entity_name,
method: 'show',

View File

@ -88,7 +88,7 @@ IPA.navigation = function(spec) {
};
that.get_state = function(key) {
return $.bbq.getState(key, true);
return $.bbq.getState(key);
};
that.remove_state = function(key) {

View File

@ -134,7 +134,7 @@ IPA.rule_association_table_widget = function (spec) {
that.add = function(values, on_success, on_error) {
var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
var pkey = $.bbq.getState(that.entity_name+'-pkey');
var batch = IPA.batch_command({
'on_success': on_success,

View File

@ -166,7 +166,7 @@ IPA.search_facet = function(spec) {
that.entity.header.facet_tabs.css('visibility', 'hidden');
if (that.filter) {
var filter = $.bbq.getState(that.entity_name + '-filter', true) || '';
var filter = $.bbq.getState(that.entity_name+'-filter');
that.filter.val(filter);
}
};
@ -295,17 +295,17 @@ IPA.search_facet = function(spec) {
summary.append('<p>'+error_thrown.message+'</p>');
}
var filter = [];
var current_entity = entity;
filter.unshift($.bbq.getState(current_entity.name + '-filter', true) || '');
filter.unshift($.bbq.getState(current_entity.name+'-filter'));
current_entity = current_entity.containing_entity;
while(current_entity !== null){
filter.unshift(
$.bbq.getState(current_entity.name + '-pkey', true) || '');
$.bbq.getState(current_entity.name+'-pkey'));
current_entity = current_entity.containing_entity;
}
var command = IPA.command({
entity: entity.name,
method: 'find',
@ -343,17 +343,17 @@ IPA.nested_search_facet = function(spec){
that.entity.header.facet_tabs.css('visibility', 'visible');
that.entity.header.set_pkey(
$.bbq.getState(IPA.current_entity.name + '-pkey', true) || '');
$.bbq.getState(IPA.current_entity.name+'-pkey'));
if (that.filter) {
var filter =
$.bbq.getState(that.managed_entity_name + '-filter', true) || '';
var filter = $.bbq.getState(that.managed_entity_name+'-filter');
that.filter.val(filter);
}
};
that.refresh = function(){
var pkey = $.bbq.getState(that.entity.name + '-pkey', true) || '';
var pkey = $.bbq.getState(that.entity.name+'-pkey');
if ((!pkey) && (that.entity.redirect_facet)) {

View File

@ -197,7 +197,7 @@ IPA.sudocmd_member_sudocmdgroup_table_widget = function (spec) {
'on_error': on_error
});
var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
var pkey = $.bbq.getState(that.entity_name+'-pkey');
for (var i=0; i<values.length; i++) {
var value = values[i];
@ -226,7 +226,7 @@ IPA.sudocmd_member_sudocmdgroup_table_widget = function (spec) {
'on_error': on_error
});
var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
var pkey = $.bbq.getState(that.entity_name+'-pkey');
for (var i=0; i<values.length; i++) {
var value = values[i];
@ -354,7 +354,7 @@ IPA.sudorule_details_facet = function (spec) {
that.update = function() {
var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
var pkey = $.bbq.getState(that.entity_name+'-pkey');
var modify_operation = {
'execute': false,
@ -1042,7 +1042,7 @@ IPA.sudorule_association_table_widget = function (spec) {
that.external = spec.external;
that.create_add_dialog = function() {
var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
var pkey = $.bbq.getState(that.entity_name+'-pkey');
var label = IPA.metadata.objects[that.other_entity].label;
var title = 'Add '+label+' to '+that.entity_name+' '+pkey;
@ -1240,7 +1240,7 @@ IPA.sudorule_command_table_widget = function (spec) {
that.add = function(values, on_success, on_error) {
var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
var pkey = $.bbq.getState(that.entity_name+'-pkey');
var batch = IPA.batch_command({
'on_success': on_success,
@ -1278,7 +1278,7 @@ IPA.sudorule_command_table_widget = function (spec) {
that.remove = function(values, on_success, on_error) {
var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
var pkey = $.bbq.getState(that.entity_name+'-pkey');
var command = IPA.command({
entity: that.entity_name,

View File

@ -1374,29 +1374,6 @@ IPA.table_widget = function (spec) {
}
};
that.refresh = function() {
function on_success(data, text_status, xhr) {
that.load(data.result.result);
}
function on_error(xhr, text_status, error_thrown) {
var summary = $('span[name=summary]', that.tfoot).empty();
summary.append('<p>Error: '+error_thrown.name+'</p>');
summary.append('<p>'+error_thrown.message+'</p>');
}
var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
IPA.command({
entity: that.entity_name,
method: 'show',
args: [pkey],
options: {'all': true, 'rights': true},
on_success: on_success,
on_error: on_error
}).execute();
};
if (spec.columns) {
for (var i=0; i<spec.columns; i++) {
that.create_column(spec.columns[i]);