Skip to content

Commit 3d8ced8

Browse files
committed
picklist menus at bottom of Reference Guide
1 parent e50235d commit 3d8ced8

File tree

2 files changed

+53
-6
lines changed

2 files changed

+53
-6
lines changed

lib/DataHarmonizer.js

+49-6
Original file line numberDiff line numberDiff line change
@@ -1129,12 +1129,35 @@ class DataHarmonizer {
11291129
row_html += `<td>${slot_dict.examples}</td>`;
11301130
}
11311131
if (this.columnHelpEntries.includes('menus')) {
1132-
row_html += ` <td>${slot_dict.sources || ''}</td>`;
1132+
row_html += ` <td>${slot_dict.menus || ''}</td>`;
11331133
}
11341134
row_html += '</tr>';
11351135
}
11361136
}
11371137

1138+
// Note this may include more enumerations than exist in a given template.
1139+
let enum_html = ``;
1140+
for (const key of Object.keys(this.schema.enums).sort()) {
1141+
const enumeration = this.schema.enums[key];
1142+
let title = enumeration.title != enumeration.name ? enumeration.title : '';
1143+
enum_html += `<tr class="section">
1144+
<td colspan="2" id="${enumeration.name}">${enumeration.name}</td>
1145+
<td colspan="2">(${title})<br/>${this.renderSemanticID(enumeration.enum_uri)}</td>
1146+
</tr>`;
1147+
1148+
for (const item_key in enumeration.permissible_values) {
1149+
const item = enumeration.permissible_values[item_key];
1150+
let text = item.text != item_key ? item.text : '';
1151+
enum_html += `<tr>
1152+
<td>${this.renderSemanticID(item.meaning)}</td>
1153+
<td>${item_key}</td>
1154+
<td>${text}</td>
1155+
<td></td>
1156+
</tr>`;
1157+
}
1158+
}
1159+
1160+
11381161
var win = window.open(
11391162
'',
11401163
'Reference',
@@ -1195,7 +1218,19 @@ class DataHarmonizer {
11951218
</tbody>
11961219
</table>
11971220
</div>
1198-
</body>
1221+
1222+
<div>
1223+
<table>
1224+
<thead>
1225+
<tr class="section">
1226+
<td colspan="4"><h3>${i18next.t('help-picklists')}</h3>
1227+
</td>
1228+
</tr>
1229+
</thead>
1230+
<tbody>${enum_html}</tbody>
1231+
</table>
1232+
</div>
1233+
</body>
11991234
</html>
12001235
`;
12011236
return false;
@@ -1948,6 +1983,7 @@ class DataHarmonizer {
19481983
guidance: '',
19491984
examples: '',
19501985
sources: '',
1986+
menus: ''
19511987
};
19521988

19531989
let guidance = [];
@@ -1992,7 +2028,13 @@ class DataHarmonizer {
19922028
guidance.push(i18next.t('reference_guide_msg_unique_record'));
19932029
}
19942030
if (field.sources && field.sources.length) {
1995-
let sources = [];
2031+
let menus = [];
2032+
for (const item of field.sources) {
2033+
menus.push('<a href="#'+ item + '" target="_self">' + item +'</a>');
2034+
}
2035+
guide.menus = '<ul><li>' + menus.join('</li><li>') + '</li></ul>';
2036+
/*
2037+
// List null value menu items directly
19962038
for (const [, item] of Object.entries(field.sources)) {
19972039
// List null value menu items directly
19982040
if (item === 'NullValueMenu') {
@@ -2004,7 +2046,8 @@ class DataHarmonizer {
20042046
sources.push(item);
20052047
}
20062048
}
2007-
guide.sources = '<ul><li>' + sources.join('</li>\n<li>') + '</li></ul>';
2049+
*/
2050+
guide.sources = '<ul><li>' + field.sources.join('</li><li>') + '</li></ul>';
20082051
}
20092052
if (field.multivalued) {
20102053
guidance.push(i18next.t('reference_guide_msg_more_than_one_selection'));
@@ -2035,9 +2078,9 @@ class DataHarmonizer {
20352078

20362079
if (first_item === true) {
20372080
first_item = false;
2038-
examples += '<ul><li>' + i18next.t(item.value) + '</li>\n';
2081+
examples += '<ul><li>' + i18next.t(item.value) + '</li>';
20392082
} else {
2040-
examples += '<li>' + i18next.t(item.value) + '</li>\n';
2083+
examples += '<li>' + i18next.t(item.value) + '</li>';
20412084
}
20422085
}
20432086
guide.examples = examples + '</ul>';

web/translations/translations.json

+4
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,10 @@
243243
"en": "Menus",
244244
"fr": "Menus"
245245
},
246+
"help-picklists": {
247+
"en": "Controlled vocabulary picklists",
248+
"fr": "Des listes de choix de vocabulaire contrôlé"
249+
},
246250
"reference_guide_title": {
247251
"en": "Reference Guide for",
248252
"fr": "Guide de référence pour"

0 commit comments

Comments
 (0)