diff options
author | Adam Young <ayoung@redhat.com> | 2011-06-28 13:39:10 -0400 |
---|---|---|
committer | Endi S. Dewata <edewata@redhat.com> | 2011-06-28 22:40:42 +0000 |
commit | 66eeaceb8cc50902b408e5c97c6d04e59e57f97a (patch) | |
tree | d279fd33648bf1470f566afca418b876683748a2 /install/ui | |
parent | 67b807d6402942061d9762f2c1ff31779b7d4744 (diff) | |
download | freeipa.git-66eeaceb8cc50902b408e5c97c6d04e59e57f97a.tar.gz freeipa.git-66eeaceb8cc50902b408e5c97c6d04e59e57f97a.tar.xz freeipa.git-66eeaceb8cc50902b408e5c97c6d04e59e57f97a.zip |
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
Diffstat (limited to 'install/ui')
-rw-r--r-- | install/ui/association.js | 20 | ||||
-rw-r--r-- | install/ui/details.js | 8 | ||||
-rw-r--r-- | install/ui/dns.js | 10 | ||||
-rw-r--r-- | install/ui/entity.js | 12 | ||||
-rw-r--r-- | install/ui/hbac.js | 8 | ||||
-rw-r--r-- | install/ui/navigation.js | 46 | ||||
-rw-r--r-- | install/ui/rule.js | 2 | ||||
-rw-r--r-- | install/ui/search.js | 14 | ||||
-rw-r--r-- | install/ui/sudo.js | 12 | ||||
-rw-r--r-- | install/ui/test/details_tests.js | 6 | ||||
-rw-r--r-- | install/ui/user.js | 4 | ||||
-rw-r--r-- | install/ui/webui.js | 9 |
12 files changed, 95 insertions, 56 deletions
diff --git a/install/ui/association.js b/install/ui/association.js index ad2268f5..6f74bf62 100644 --- a/install/ui/association.js +++ b/install/ui/association.js @@ -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); diff --git a/install/ui/details.js b/install/ui/details.js index 91e349a3..afab5a7e 100644 --- a/install/ui/details.js +++ b/install/ui/details.js @@ -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, diff --git a/install/ui/dns.js b/install/ui/dns.js index 25addc42..8bc14a30 100644 --- a/install/ui/dns.js +++ b/install/ui/dns.js @@ -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); diff --git a/install/ui/entity.js b/install/ui/entity.js index 4a22c58a..c04f85d6 100644 --- a/install/ui/entity.js +++ b/install/ui/entity.js @@ -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; diff --git a/install/ui/hbac.js b/install/ui/hbac.js index 4c29abaa..c082056b 100644 --- a/install/ui/hbac.js +++ b/install/ui/hbac.js @@ -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', diff --git a/install/ui/navigation.js b/install/ui/navigation.js index 5d70f879..d0b45cc3 100644 --- a/install/ui/navigation.js +++ b/install/ui/navigation.js @@ -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, diff --git a/install/ui/rule.js b/install/ui/rule.js index 08c27e6d..4969ffb5 100644 --- a/install/ui/rule.js +++ b/install/ui/rule.js @@ -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, diff --git a/install/ui/search.js b/install/ui/search.js index 4f380278..b5f71e0d 100644 --- a/install/ui/search.js +++ b/install/ui/search.js @@ -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(); diff --git a/install/ui/sudo.js b/install/ui/sudo.js index b3882b05..0ed46d8c 100644 --- a/install/ui/sudo.js +++ b/install/ui/sudo.js @@ -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, diff --git a/install/ui/test/details_tests.js b/install/ui/test/details_tests.js index dc84dc02..71e6bf98 100644 --- a/install/ui/test/details_tests.js +++ b/install/ui/test/details_tests.js @@ -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'; diff --git a/install/ui/user.js b/install/ui/user.js index ce925d8e..d7217542 100644 --- a/install/ui/user.js +++ b/install/ui/user.js @@ -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]) { diff --git a/install/ui/webui.js b/install/ui/webui.js index 72f9f729..2c445148 100644 --- a/install/ui/webui.js +++ b/install/ui/webui.js @@ -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'} ]}, |