Skip to content

Commit

Permalink
cassproject/cass-viewer #8 #9 Added array/string parser
Browse files Browse the repository at this point in the history
  • Loading branch information
whistlinjoe committed Dec 11, 2018
1 parent bbccee7 commit e9988f0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
12 changes: 6 additions & 6 deletions js/cass-ui-prf-exp/cui-pe-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ function isFrameworkIdOrProfileUser(id) {
function getFrameworkName(frameworkId) {
if (profileUserName && profileUserName != null && frameworkId == profileUserName) return profileUserName;
if (!applicableFrameworkMap[frameworkId] || applicableFrameworkMap[frameworkId] == null) return null;
return applicableFrameworkMap[frameworkId].getName().trim();
return getStringVal(applicableFrameworkMap[frameworkId].getName()).trim();
}

function getFrameworkDescription(frameworkId) {
Expand All @@ -205,7 +205,7 @@ function getFrameworkDescription(frameworkId) {
else return PROFILE_DESCRIPTION_OTHER;
}
if (!applicableFrameworkMap[frameworkId] || applicableFrameworkMap[frameworkId] == null) return null;
return applicableFrameworkMap[frameworkId].getDescription().trim();
return getStringVal(applicableFrameworkMap[frameworkId].getDescription()).trim();
}

function getFrameworksForCompetency(competencyId) {
Expand Down Expand Up @@ -236,7 +236,7 @@ function buildCassEditorFrameworkHyperlinkListForCompetency(competencyId) {
var retHtml = "";
for (var i = 0; i < fwa.length; i++) {
var fw = fwa[i];
retHtml += generateAnchorLink("https://cassproject.github.io/cass-editor/?frameworkId=" + fw.shortId() + "&view=true", fw.getName(), fw.getName());
retHtml += generateAnchorLink("https://cassproject.github.io/cass-editor/?frameworkId=" + fw.shortId() + "&view=true", getStringVal(fw.getName()), getStringVal(fw.getName()));
if (i < (fwa.length - 1)) retHtml += ", ";
}
return retHtml;
Expand All @@ -248,7 +248,7 @@ function buildFrameworkExplorerFrameworkHyperlinkListForCompetency(competencyId)
var retHtml = "";
for (var i = 0; i < fwa.length; i++) {
var fw = fwa[i];
retHtml += "<a onclick=\"openFrameworkExplorer('" + fw.shortId() + "');\">" + escapeSingleQuote(fw.getName()) + "</a>"
retHtml += "<a onclick=\"openFrameworkExplorer('" + fw.shortId() + "');\">" + escapeSingleQuote(getStringVal(fw.getName())) + "</a>"
if (i < (fwa.length - 1)) retHtml += ", ";
}
return retHtml;
Expand All @@ -266,7 +266,7 @@ function buildHyperlinkListForCompetency(competencyId) {
for (var i = 0; i < fwa.length; i++) {
var fw = fwa[i];
var linkHref = "https://cassproject.github.io/cass-editor/?frameworkId=" + fw.shortId() + "&competencyId=" + competencyId + "&view=true";
var linkName = compName + "(" + fw.getName() + ")";
var linkName = compName + "(" + getStringVal(fw.getName()) + ")";
retHtml += generateAnchorLink(linkHref, linkName, linkName);
if (i < (fwa.length - 1)) retHtml += ", ";
}
Expand Down Expand Up @@ -1903,7 +1903,7 @@ function buildGraphProfileSummaryFrameworkCategories() {
$(CIR_FCS_SUM_LIST_CTR).empty();
frameworkGraphSummaryLiMap = {};
applicableFrameworkList.sort(function (a, b) {
return a.getName().localeCompare(b.getName());
return getStringVal(a.getName()).localeCompare(getStringVal(b.getName()));
});
var frameworkCategories = categorizeFrameworksForSummary();
for (var category in frameworkCategories) {
Expand Down
10 changes: 10 additions & 0 deletions js/cass-ui-prf-exp/cui-pe-ui-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,16 @@ function setProfileName(name) {
$(PROFILE_NAME).html(name);
}

function getStringVal(f) {
if (!f) return "";
else if (typeof f === 'string' || f instanceof String) return f;
else if (Array.isArray(f)) {
if (f.length >= 1) return f[0];
else return "";
}
else return "";
}

//**************************************************************************************************
// List Screen Utility Functions
//**************************************************************************************************
Expand Down

0 comments on commit e9988f0

Please sign in to comment.