diff options
author | Endi S. Dewata <edewata@redhat.com> | 2011-07-21 21:29:55 -0500 |
---|---|---|
committer | Adam Young <ayoung@redhat.com> | 2011-07-22 12:13:10 -0400 |
commit | ca7395c35367965f8824f2bfecfa3f79f4b8a87b (patch) | |
tree | 6258c97d760c56421a6e7dc47050216334073b4f /install/ui/entity.js | |
parent | df7ee2ccf5ff12ab43b1a97385b4f28bc64ef083 (diff) | |
download | freeipa-ca7395c35367965f8824f2bfecfa3f79f4b8a87b.tar.gz freeipa-ca7395c35367965f8824f2bfecfa3f79f4b8a87b.tar.xz freeipa-ca7395c35367965f8824f2bfecfa3f79f4b8a87b.zip |
Refactored IPA.current_facet().
The IPA.current_facet() has been merged into IPA.entity.setup()
and replaced by IPA.entity.get_facet(). The setup() will read the
current facet's name from the <entity>-facet URL parameter and store
the facet object in the entity object. The get_facet() without any
parameter will return the current facet object.
Diffstat (limited to 'install/ui/entity.js')
-rw-r--r-- | install/ui/entity.js | 41 |
1 files changed, 19 insertions, 22 deletions
diff --git a/install/ui/entity.js b/install/ui/entity.js index 0940c7d17..83687fe7e 100644 --- a/install/ui/entity.js +++ b/install/ui/entity.js @@ -127,6 +127,10 @@ IPA.facet = function (spec) { that.header.load(data); }; + that.needs_update = function() { + return true; + }; + that.is_dirty = function() { return false; }; @@ -459,7 +463,7 @@ IPA.entity = function (spec) { that.facet_groups = $.ordered_map(); // current facet - that.facet_name = null; + that.facet = null; that.redirect_facet = spec.redirect_facet; that.containing_entity = null; @@ -490,7 +494,14 @@ IPA.entity = function (spec) { }; that.get_facet = function(name) { - if (name === 'default') { + if (name === undefined) { + // return the current facet + if (that.facet) return that.facet; + + // return the main facet + return that.facets.values[0]; + + } else if (name === 'default') { // return the first facet in the first facet group var facet_groups = that.facet_groups.values; for (var i=0; i<facet_groups.length; i++) { @@ -541,22 +552,17 @@ IPA.entity = function (spec) { that.setup = function(container) { - var prev_facet = that.facet; + var prev_entity = IPA.current_entity; + var prev_facet = prev_entity ? prev_entity.facet : null; IPA.current_entity = that; - var facet_name = IPA.current_facet(that); + var facet_name = IPA.nav.get_state(that.name+'-facet'); that.facet = that.get_facet(facet_name); - if (!that.facet) return; - if (IPA.entity_name == that.name) { - if (that.facet_name == that.facet.name) { - if (that.facet.new_key && (!that.facet.new_key())) return; - } else { - that.facet_name = that.facet.name; - } - } else { - IPA.entity_name = that.name; + // same entity, same facet, and doesn't need updating => return + if (that == prev_entity && that.facet == prev_facet && !that.facet.needs_update()) { + return; } if (prev_facet) { @@ -613,15 +619,6 @@ IPA.entity = function (spec) { return that; }; -IPA.current_facet = function(entity) { - 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; - } - return facet_name; -}; - IPA.nested_tab_labels = {}; IPA.get_nested_tab_label = function(entity_name){ |