Skip to content

Commit

Permalink
Load concept mappings via Ajax when the concept page is loaded via aj…
Browse files Browse the repository at this point in the history
…ax (hierarchy click)
  • Loading branch information
kinow committed Mar 9, 2019
1 parent 592886a commit 5064253
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
16 changes: 14 additions & 2 deletions resource/js/docready.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,19 @@ $(function() { // DOCUMENT READY
updateJsonLD(data);
updateTitle(data);
updateTopbarLang(data);
makeCallbacks(data);
// ajaxing the concept mapping properties on the concept page
var $conceptAppendix = $('.concept-appendix');
if ($conceptAppendix.length) {
var concept = {
uri: $conceptAppendix.data('concept-uri'),
type: $conceptAppendix.data('concept-type')
};

// Defined in scripts.js. Will load the mapping properties via Ajax request to JSKOS REST service, and render them.
loadMappingProperties(concept, lang, $conceptAppendix, data);
} else {
makeCallbacks(data);
}
// take the content language buttons from the response
$('.header-float .dropdown-menu').empty().append($('.header-float .dropdown-menu', data).html());
}
Expand Down Expand Up @@ -1097,7 +1109,7 @@ $(function() { // DOCUMENT READY
};

// Defined in scripts.js. Will load the mapping properties via Ajax request to JSKOS REST service, and render them.
loadMappingProperties(concept, lang, $conceptAppendix);
loadMappingProperties(concept, lang, $conceptAppendix, null);
} else {
makeCallbacks();
}
Expand Down
8 changes: 5 additions & 3 deletions resource/js/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -366,9 +366,11 @@ function renderPropertyMappings(concept, contentLang, properties) {
* template is comprised of another template, for concept mapping property values.
*
* @param concept dictionary/object populated with data from the Concept object
* @param htmlElement HTML (a div) parent object. Initially hidden.
* @param contentLang language to display content
* @param $htmlElement HTML (a div) parent object (initially hidden)
* @param conceptData concept page data returned via ajax, passed to makeCallback only
*/
function loadMappingProperties(concept, contentLang, $htmlElement) {
function loadMappingProperties(concept, contentLang, $htmlElement, conceptData) {
// display with the spinner
$htmlElement
.removeClass('hidden')
Expand Down Expand Up @@ -422,7 +424,7 @@ function loadMappingProperties(concept, contentLang, $htmlElement) {
console.log("Error retrieving mapping properties for [" + $htmlElement.data('concept-uri') + "]: " + data.responseText);
},
complete: function() {
makeCallbacks();
makeCallbacks(conceptData);
}
});
}

0 comments on commit 5064253

Please sign in to comment.