mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
shorten url cache state in a javascript variable, and leave on information about the current entity in the URL hash params
https://fedorahosted.org/freeipa/ticket/674 decrement depth for hidden tabs. Initialize state from url useing delete for removing state stricter attribute matching not incrementing depth for all hidden tabs. whitespace cleanup
This commit is contained in:
parent
67b807d640
commit
66eeaceb8c
@ -514,7 +514,7 @@ IPA.association_table_widget = function (spec) {
|
||||
};
|
||||
|
||||
that.create_add_dialog = function() {
|
||||
var pkey = $.bbq.getState(that.entity_name+'-pkey');
|
||||
var pkey = IPA.nav.get_state(that.entity_name+'-pkey');
|
||||
var label = IPA.metadata.objects[that.other_entity].label;
|
||||
var title = IPA.messages.association.add;
|
||||
|
||||
@ -562,7 +562,7 @@ IPA.association_table_widget = function (spec) {
|
||||
|
||||
that.add = function(values, on_success, on_error) {
|
||||
|
||||
var pkey = $.bbq.getState(that.entity_name+'-pkey');
|
||||
var pkey = IPA.nav.get_state(that.entity_name+'-pkey');
|
||||
|
||||
var command = IPA.command({
|
||||
entity: that.entity_name,
|
||||
@ -587,7 +587,7 @@ IPA.association_table_widget = function (spec) {
|
||||
return;
|
||||
}
|
||||
|
||||
var pkey = $.bbq.getState(that.entity_name+'-pkey');
|
||||
var pkey = IPA.nav.get_state(that.entity_name+'-pkey');
|
||||
var label = IPA.metadata.objects[that.other_entity].label;
|
||||
var title = IPA.messages.association.remove;
|
||||
|
||||
@ -625,7 +625,7 @@ IPA.association_table_widget = function (spec) {
|
||||
|
||||
that.remove = function(values, on_success, on_error) {
|
||||
|
||||
var pkey = $.bbq.getState(that.entity_name+'-pkey');
|
||||
var pkey = IPA.nav.get_state(that.entity_name+'-pkey');
|
||||
|
||||
var command = IPA.command({
|
||||
entity: that.entity_name,
|
||||
@ -651,7 +651,7 @@ IPA.association_table_widget = function (spec) {
|
||||
summary.append(error_thrown.name+': '+error_thrown.message);
|
||||
}
|
||||
|
||||
var pkey = $.bbq.getState(that.entity_name+'-pkey');
|
||||
var pkey = IPA.nav.get_state(that.entity_name+'-pkey');
|
||||
IPA.command({
|
||||
entity: that.entity_name,
|
||||
method: 'show',
|
||||
@ -814,7 +814,7 @@ IPA.association_facet = function (spec) {
|
||||
|
||||
that.facet_create_header(container);
|
||||
|
||||
that.pkey = $.bbq.getState(that.entity_name+'-pkey');
|
||||
that.pkey = IPA.nav.get_state(that.entity_name+'-pkey');
|
||||
var other_label = IPA.metadata.objects[that.other_entity].label;
|
||||
|
||||
if (!that.read_only) {
|
||||
@ -891,13 +891,13 @@ IPA.association_facet = function (spec) {
|
||||
that.show = function() {
|
||||
that.facet_show();
|
||||
|
||||
that.pkey = $.bbq.getState(that.entity_name+'-pkey');
|
||||
that.pkey = IPA.nav.get_state(that.entity_name+'-pkey');
|
||||
that.header.set_pkey(that.pkey);
|
||||
};
|
||||
|
||||
that.show_add_dialog = function() {
|
||||
|
||||
var pkey = $.bbq.getState(that.entity_name+'-pkey');
|
||||
var pkey = IPA.nav.get_state(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;
|
||||
|
||||
@ -920,7 +920,7 @@ IPA.association_facet = function (spec) {
|
||||
|
||||
dialog.execute = function() {
|
||||
|
||||
var pkey = $.bbq.getState(that.entity_name+'-pkey');
|
||||
var pkey = IPA.nav.get_state(that.entity_name+'-pkey');
|
||||
|
||||
var associator = that.associator({
|
||||
'entity_name': that.entity_name,
|
||||
@ -958,7 +958,7 @@ IPA.association_facet = function (spec) {
|
||||
return;
|
||||
}
|
||||
|
||||
var pkey = $.bbq.getState(that.entity_name+'-pkey');
|
||||
var pkey = IPA.nav.get_state(that.entity_name+'-pkey');
|
||||
var title = IPA.messages.association.remove;
|
||||
|
||||
title = title.replace('${entity}', that.entity_name);
|
||||
|
@ -378,7 +378,7 @@ IPA.details_facet = function(spec) {
|
||||
|
||||
that.facet_create_header(container);
|
||||
|
||||
that.pkey = $.bbq.getState(that.entity_name+'-pkey');
|
||||
that.pkey = IPA.nav.get_state(that.entity_name+'-pkey');
|
||||
|
||||
that.create_controls();
|
||||
|
||||
@ -486,7 +486,7 @@ IPA.details_facet = function(spec) {
|
||||
that.show = function() {
|
||||
that.facet_show();
|
||||
|
||||
that.pkey = $.bbq.getState(that.entity_name+'-pkey');
|
||||
that.pkey = IPA.nav.get_state(that.entity_name+'-pkey');
|
||||
that.header.set_pkey(that.pkey);
|
||||
};
|
||||
|
||||
@ -505,7 +505,7 @@ IPA.details_facet = function(spec) {
|
||||
};
|
||||
|
||||
function new_key(){
|
||||
var pkey = $.bbq.getState(that.entity_name+'-pkey');
|
||||
var pkey = IPA.nav.get_state(that.entity_name+'-pkey');
|
||||
return pkey != that.pkey;
|
||||
}
|
||||
that.new_key = new_key;
|
||||
@ -626,7 +626,7 @@ IPA.details_facet = function(spec) {
|
||||
|
||||
that.refresh = function() {
|
||||
|
||||
that.pkey = $.bbq.getState(that.entity_name+'-pkey');
|
||||
that.pkey = IPA.nav.get_state(that.entity_name+'-pkey');
|
||||
|
||||
var command = IPA.command({
|
||||
entity: that.entity_name,
|
||||
|
@ -228,7 +228,7 @@ IPA.dnsrecord_facet = function(spec) {
|
||||
|
||||
dialog.add = function() {
|
||||
|
||||
var pkey = $.bbq.getState(that.entity_name+'-pkey');
|
||||
var pkey = IPA.nav.get_state(that.entity_name+'-pkey');
|
||||
var resource = dialog.resource.val();
|
||||
|
||||
var options = {};
|
||||
@ -261,7 +261,7 @@ IPA.dnsrecord_facet = function(spec) {
|
||||
return;
|
||||
}
|
||||
|
||||
var zone = $.bbq.getState('dnszone-pkey');
|
||||
var zone = IPA.nav.get_state('dnszone-pkey');
|
||||
|
||||
var records = [];
|
||||
|
||||
@ -433,8 +433,8 @@ IPA.dnsrecord_facet = function(spec) {
|
||||
that.show = function() {
|
||||
that.facet_show();
|
||||
|
||||
that.record = $.bbq.getState(that.entity_name+'-record');
|
||||
that.pkey = $.bbq.getState(that.entity_name+'-pkey');
|
||||
that.record = IPA.nav.get_state(that.entity_name+'-record');
|
||||
that.pkey = IPA.nav.get_state(that.entity_name+'-pkey');
|
||||
that.header.set_pkey(that.pkey);
|
||||
};
|
||||
|
||||
@ -517,7 +517,7 @@ IPA.dnsrecord_facet = function(spec) {
|
||||
options.data = data_filter;
|
||||
}
|
||||
*/
|
||||
var args = [$.bbq.getState(that.entity_name+'-pkey')];
|
||||
var args = [IPA.nav.get_state(that.entity_name+'-pkey')];
|
||||
|
||||
if (filter) {
|
||||
args.push(filter);
|
||||
|
@ -196,7 +196,7 @@ IPA.facet_header = function(spec) {
|
||||
if (that.facet.disable_facet_tabs) return;
|
||||
|
||||
$(that.facet_tabs).find('a').removeClass('selected');
|
||||
var facet_name = $.bbq.getState(that.facet.entity.name+'-facet');
|
||||
var facet_name = IPA.nav.get_state(that.facet.entity.name+'-facet');
|
||||
|
||||
if (!facet_name || facet_name === 'default') {
|
||||
that.facet_tabs.find('a:first').addClass('selected');
|
||||
@ -215,7 +215,7 @@ IPA.facet_header = function(spec) {
|
||||
|
||||
while (entity) {
|
||||
breadcrumb.unshift($('<a/>', {
|
||||
text: $.bbq.getState(entity.name+'-pkey'),
|
||||
text: IPA.nav.get_state(entity.name+'-pkey'),
|
||||
title: entity.name,
|
||||
click: function(entity) {
|
||||
return function() {
|
||||
@ -260,7 +260,7 @@ IPA.facet_header = function(spec) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var pkey = $.bbq.getState(that.facet.entity.name+'-pkey');
|
||||
var pkey = IPA.nav.get_state(that.facet.entity.name+'-pkey');
|
||||
IPA.nav.show_page(that.facet.entity.name, other_facet.name, pkey);
|
||||
|
||||
return false;
|
||||
@ -584,7 +584,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'));
|
||||
pkey.unshift(IPA.nav.get_state(current_entity.name+'-pkey'));
|
||||
current_entity = current_entity.containing_entity;
|
||||
}
|
||||
return pkey;
|
||||
@ -594,7 +594,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'));
|
||||
pkey.unshift(IPA.nav.get_state(current_entity.name+'-pkey'));
|
||||
return pkey;
|
||||
};
|
||||
|
||||
@ -605,7 +605,7 @@ IPA.entity = function (spec) {
|
||||
};
|
||||
|
||||
IPA.current_facet = function(entity) {
|
||||
var facet_name = $.bbq.getState(entity.name+'-facet');
|
||||
var facet_name = IPA.nav.get_state(entity.name+'-facet');
|
||||
var facets = entity.facets.values;
|
||||
if (!facet_name && facets.length) {
|
||||
facet_name = facets[0].name;
|
||||
|
@ -324,7 +324,7 @@ IPA.hbacrule_details_facet = function (spec) {
|
||||
|
||||
that.update = function() {
|
||||
|
||||
var pkey = $.bbq.getState(that.entity_name+'-pkey');
|
||||
var pkey = IPA.nav.get_state(that.entity_name+'-pkey');
|
||||
|
||||
var modify_operation = {
|
||||
'execute': false,
|
||||
@ -819,7 +819,7 @@ IPA.hbacrule_accesstime_widget = function (spec) {
|
||||
|
||||
that.add = function() {
|
||||
|
||||
var pkey = $.bbq.getState(that.entity_name+'-pkey');
|
||||
var pkey = IPA.nav.get_state(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);
|
||||
@ -928,7 +928,7 @@ IPA.hbacrule_accesstime_widget = function (spec) {
|
||||
return;
|
||||
}
|
||||
|
||||
var pkey = $.bbq.getState(that.entity_name+'-pkey');
|
||||
var pkey = IPA.nav.get_state(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);
|
||||
@ -983,7 +983,7 @@ IPA.hbacrule_accesstime_widget = function (spec) {
|
||||
summary.append(error_thrown.name+': '+error_thrown.message);
|
||||
}
|
||||
|
||||
var pkey = $.bbq.getState(that.entity_name+'-pkey');
|
||||
var pkey = IPA.nav.get_state(that.entity_name+'-pkey');
|
||||
IPA.command({
|
||||
entity: that.entity_name,
|
||||
method: 'show',
|
||||
|
@ -65,23 +65,25 @@ IPA.navigation = function(spec) {
|
||||
|
||||
that.get_path_state = function(name) {
|
||||
|
||||
var state = {};
|
||||
var path_state = {};
|
||||
|
||||
var tab = that.get_tab(name);
|
||||
var parent = tab.parent;
|
||||
|
||||
while (parent) {
|
||||
state[parent.name] = tab.name;
|
||||
path_state[parent.name] = tab.name;
|
||||
|
||||
tab = parent;
|
||||
parent = tab.parent;
|
||||
}
|
||||
|
||||
state[that.container.attr('id')] = tab.name;
|
||||
path_state[that.container.attr('id')] = tab.name;
|
||||
|
||||
return state;
|
||||
return path_state;
|
||||
};
|
||||
|
||||
var state = $.bbq.getState();
|
||||
|
||||
that.push_state = function(params) {
|
||||
|
||||
if (IPA.current_entity) {
|
||||
@ -104,15 +106,37 @@ IPA.navigation = function(spec) {
|
||||
}
|
||||
}
|
||||
|
||||
$.bbq.pushState(params);
|
||||
for ( var param in params){
|
||||
state[param] = params[param];
|
||||
}
|
||||
|
||||
var url_state ={};
|
||||
var key = 'navigation';
|
||||
while(state[key]){
|
||||
var value = state[key];
|
||||
url_state[key] = value;
|
||||
var entity = value;
|
||||
for (var key2 in state){
|
||||
if ((key2 === entity) || (key2.search('^'+entity) > -1)){
|
||||
url_state[key2] = state[key2];
|
||||
}
|
||||
}
|
||||
key = value;
|
||||
}
|
||||
$.bbq.pushState(url_state,2);
|
||||
return true;
|
||||
};
|
||||
|
||||
that.get_state = function(key) {
|
||||
return $.bbq.getState(key);
|
||||
var url_state = $.bbq.getState(key);
|
||||
if (!url_state){
|
||||
url_state = state[key];
|
||||
}
|
||||
return url_state;
|
||||
};
|
||||
|
||||
that.remove_state = function(key) {
|
||||
delete state[key];
|
||||
$.bbq.removeState(key);
|
||||
};
|
||||
|
||||
@ -218,15 +242,21 @@ IPA.navigation = function(spec) {
|
||||
container.tabs('select', index);
|
||||
|
||||
var tab = tabs[index];
|
||||
if (tab.hidden){
|
||||
depth = depth -1;
|
||||
}
|
||||
|
||||
if (tab.children && tab.children.length) {
|
||||
that._update(tab.children, tab.container, depth+1);
|
||||
var next_depth = depth + 1;
|
||||
that._update(tab.children, tab.container, next_depth);
|
||||
|
||||
} else if (tab.entity) {
|
||||
|
||||
that.container.addClass(that.tab_class+'-'+depth);
|
||||
that.content.addClass(that.tab_class+'-'+depth);
|
||||
|
||||
var entity_container = $('.entity[name="'+tab.entity.name+'"]', that.content);
|
||||
var entity_container = $('.entity[name="'+tab.entity.name+'"]',
|
||||
that.content);
|
||||
if (!entity_container.length) {
|
||||
tab.content = $('<div/>', {
|
||||
name: tab.name,
|
||||
|
@ -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');
|
||||
var pkey = IPA.nav.get_state(that.entity_name+'-pkey');
|
||||
|
||||
var batch = IPA.batch_command({
|
||||
'on_success': on_success,
|
||||
|
@ -102,7 +102,7 @@ IPA.search_facet = function(spec) {
|
||||
|
||||
that.filter = $('<input/>', {
|
||||
type: 'text',
|
||||
'class': 'search-filter',
|
||||
'class': 'search-filter',
|
||||
name: 'filter'
|
||||
}).appendTo(span);
|
||||
|
||||
@ -156,7 +156,7 @@ IPA.search_facet = function(spec) {
|
||||
that.facet_show();
|
||||
|
||||
if (that.filter) {
|
||||
var filter = $.bbq.getState(that.entity_name+'-filter');
|
||||
var filter = IPA.nav.get_state(that.entity_name+'-filter');
|
||||
that.filter.val(filter);
|
||||
}
|
||||
};
|
||||
@ -301,11 +301,11 @@ IPA.search_facet = function(spec) {
|
||||
|
||||
var filter = [];
|
||||
var current_entity = entity;
|
||||
filter.unshift($.bbq.getState(current_entity.name+'-filter'));
|
||||
filter.unshift(IPA.nav.get_state(current_entity.name+'-filter'));
|
||||
current_entity = current_entity.containing_entity;
|
||||
while(current_entity !== null){
|
||||
filter.unshift(
|
||||
$.bbq.getState(current_entity.name+'-pkey'));
|
||||
IPA.nav.get_state(current_entity.name+'-pkey'));
|
||||
current_entity = current_entity.containing_entity;
|
||||
}
|
||||
|
||||
@ -349,17 +349,17 @@ IPA.nested_search_facet = function(spec) {
|
||||
that.facet_show();
|
||||
|
||||
that.header.set_pkey(
|
||||
$.bbq.getState(IPA.current_entity.name+'-pkey'));
|
||||
IPA.nav.get_state(IPA.current_entity.name+'-pkey'));
|
||||
|
||||
if (that.filter) {
|
||||
var filter = $.bbq.getState(that.managed_entity_name+'-filter');
|
||||
var filter = IPA.nav.get_state(that.managed_entity_name+'-filter');
|
||||
that.filter.val(filter);
|
||||
}
|
||||
};
|
||||
|
||||
that.refresh = function(){
|
||||
|
||||
var pkey = $.bbq.getState(that.entity.name+'-pkey');
|
||||
var pkey = IPA.nav.get_state(that.entity.name+'-pkey');
|
||||
|
||||
if ((!pkey) && (that.entity.redirect_facet)) {
|
||||
that.redirect();
|
||||
|
@ -202,7 +202,7 @@ IPA.sudocmd_member_sudocmdgroup_table_widget = function (spec) {
|
||||
'on_error': on_error
|
||||
});
|
||||
|
||||
var pkey = $.bbq.getState(that.entity_name+'-pkey');
|
||||
var pkey = IPA.nav.get_state(that.entity_name+'-pkey');
|
||||
|
||||
for (var i=0; i<values.length; i++) {
|
||||
var value = values[i];
|
||||
@ -231,7 +231,7 @@ IPA.sudocmd_member_sudocmdgroup_table_widget = function (spec) {
|
||||
'on_error': on_error
|
||||
});
|
||||
|
||||
var pkey = $.bbq.getState(that.entity_name+'-pkey');
|
||||
var pkey = IPA.nav.get_state(that.entity_name+'-pkey');
|
||||
|
||||
for (var i=0; i<values.length; i++) {
|
||||
var value = values[i];
|
||||
@ -353,7 +353,7 @@ IPA.sudorule_details_facet = function (spec) {
|
||||
|
||||
that.update = function() {
|
||||
|
||||
var pkey = $.bbq.getState(that.entity_name+'-pkey');
|
||||
var pkey = IPA.nav.get_state(that.entity_name+'-pkey');
|
||||
|
||||
var modify_operation = {
|
||||
'execute': false,
|
||||
@ -1045,7 +1045,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');
|
||||
var pkey = IPA.nav.get_state(that.entity_name+'-pkey');
|
||||
var label = IPA.metadata.objects[that.other_entity].label;
|
||||
var title = 'Add '+label+' to '+that.entity_name+' '+pkey;
|
||||
|
||||
@ -1243,7 +1243,7 @@ IPA.sudorule_command_table_widget = function (spec) {
|
||||
|
||||
that.add = function(values, on_success, on_error) {
|
||||
|
||||
var pkey = $.bbq.getState(that.entity_name+'-pkey');
|
||||
var pkey = IPA.nav.get_state(that.entity_name+'-pkey');
|
||||
|
||||
var batch = IPA.batch_command({
|
||||
'on_success': on_success,
|
||||
@ -1281,7 +1281,7 @@ IPA.sudorule_command_table_widget = function (spec) {
|
||||
|
||||
that.remove = function(values, on_success, on_error) {
|
||||
|
||||
var pkey = $.bbq.getState(that.entity_name+'-pkey');
|
||||
var pkey = IPA.nav.get_state(that.entity_name+'-pkey');
|
||||
|
||||
var command = IPA.command({
|
||||
entity: that.entity_name,
|
||||
|
@ -35,6 +35,12 @@ module('details', {
|
||||
}
|
||||
);
|
||||
|
||||
IPA.nav = {};
|
||||
|
||||
IPA.nav.get_state = function(key){
|
||||
return $.bbq.getState(key);
|
||||
};
|
||||
|
||||
details_container = $('<div id="details"/>').appendTo(document.body);
|
||||
|
||||
var obj_name = 'user';
|
||||
|
@ -177,7 +177,7 @@ IPA.user_status_widget = function(spec) {
|
||||
click: function() {
|
||||
var jobj = $(this);
|
||||
var val = jobj.attr('title');
|
||||
var pkey = $.bbq.getState('user-pkey');
|
||||
var pkey = IPA.nav.get_state('user-pkey');
|
||||
var method = 'enable';
|
||||
if (val == IPA.messages.objects.user.active) {
|
||||
method = 'disable';
|
||||
@ -266,7 +266,7 @@ IPA.user_password_widget = function(spec) {
|
||||
return;
|
||||
}
|
||||
|
||||
var user_pkey = $.bbq.getState('user-pkey');
|
||||
var user_pkey = IPA.nav.get_state('user-pkey');
|
||||
|
||||
var args;
|
||||
if (user_pkey === IPA.whoami.uid[0]) {
|
||||
|
@ -53,9 +53,12 @@ IPA.admin_navigation = function(spec) {
|
||||
{entity: 'sudocmd'},
|
||||
{entity: 'sudocmdgroup'}
|
||||
]},
|
||||
{entity: 'automountlocation', label: IPA.messages.tabs.automount},
|
||||
{entity: 'automountmap', hidden: true},
|
||||
{entity: 'automountkey', hidden: true},
|
||||
{name:'automount',
|
||||
label: IPA.messages.tabs.automount,
|
||||
children:[
|
||||
{entity: 'automountlocation', hidden:true},
|
||||
{entity: 'automountmap', hidden: true},
|
||||
{entity: 'automountkey', hidden: true}]},
|
||||
{entity: 'pwpolicy'},
|
||||
{entity: 'krbtpolicy'}
|
||||
]},
|
||||
|
Loading…
Reference in New Issue
Block a user