Skip to content

Commit

Permalink
#101 - ContextHub profile requires "manual" loading of current reques…
Browse files Browse the repository at this point in the history
…t user. Consolidates JS calls to remove issue w/ duplicative JS code execution. (#117)
  • Loading branch information
davidjgonzalez authored and godanny86 committed Feb 6, 2018
1 parent 3e8255c commit 4fdcff3
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,5 @@ data.js
navigation.js
form-data.js
ajax.js
events.js




contexthub.js
events.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Asset Share Commons
*
* Copyright [2017] Adobe
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/*global jQuery: false, AssetShare: false, ContextHub: false */

AssetShare.ContextHub.Profile = (function ($, ns, contextHub) {
"use strict";

$(function() {
// https://github.com/Adobe-Marketing-Cloud/aem-sample-we-retail/blob/master/ui.apps/src/main/content/jcr_root/apps/weretail/components/structure/header/clientlib/js/utilities.js
$.ajax({
type : "GET",
url : "/libs/granite/security/currentuser.json?nocache=" + new Date().getTime(),
async : true,
success: function (json) {

// On publish: load the request user into ContextHub
if (typeof contextHub !== "undefined") {
var profileStore = contextHub.getStore("profile"),
requestUser = json.home,
contextHubUser = profileStore.getTree().path;

if (!contextHubUser || contextHubUser !== requestUser) {
profileStore.loadProfile(requestUser);
}
}
}
});
});

return {};
}(jQuery,
AssetShare,
ContextHub));
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,7 @@ AssetShare.Search = {};

AssetShare.Cart = {};

AssetShare.ContextHub = AssetShare.ContextHub || {};

AssetShare.SemanticUI = {};
AssetShare.SemanticUI.Modals = {};
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
jcr:primaryType="cq:ClientLibraryFolder"
allowProxy="{Boolean}true"
categories="[asset-share-commons.semantic-ui-dark]"
dependencies="[asset-share-commons.base]"
embed="[
asset-share-commons.semantic-ui-dark.globals,
asset-share-commons.semantic-ui-dark.elements,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
jcr:primaryType="cq:ClientLibraryFolder"
allowProxy="{Boolean}true"
categories="[asset-share-commons.semantic-ui-light]"
dependencies="[asset-share-commons.base]"
embed="[
asset-share-commons.semantic-ui-light.globals,
asset-share-commons.semantic-ui-light.elements,
Expand Down

0 comments on commit 4fdcff3

Please sign in to comment.