@@ -125,6 +125,7 @@ class DataHarmonizer {
125
125
) ;
126
126
this . columnHelpEntries = options . columnHelpEntries || [
127
127
'column' ,
128
+ 'slot_uri' ,
128
129
'description' ,
129
130
'guidance' ,
130
131
'examples' ,
@@ -176,7 +177,7 @@ class DataHarmonizer {
176
177
( field ) => field . title === field_reference
177
178
) ;
178
179
$ ( '#field-description-text' ) . html (
179
- urlToClickableAnchor ( this . getComment ( field ) )
180
+ this . getComment ( field )
180
181
) ;
181
182
$ ( '#field-description-modal' ) . modal ( 'show' ) ;
182
183
} ) ;
@@ -1037,6 +1038,30 @@ class DataHarmonizer {
1037
1038
hotInstance . render ( ) ; // Render the table to apply changes
1038
1039
}
1039
1040
1041
+ renderSemanticID ( curieOrURI , as_markup = false ) {
1042
+ if ( curieOrURI ) {
1043
+ if ( curieOrURI . toLowerCase ( ) . startsWith ( 'http' ) ) {
1044
+ if ( as_markup )
1045
+ return `[${ curieOrURI } ](${ curieOrURI } )` ;
1046
+
1047
+ return `<a href="${ curieOrURI } " target="_blank">${ curieOrURI } </a>` ;
1048
+ }
1049
+ else if ( curieOrURI . includes ( ':' ) ) {
1050
+ const [ prefix , reference ] = curieOrURI . split ( ':' , 2 ) ;
1051
+ if ( prefix && reference && ( prefix in this . schema . prefixes ) ) {
1052
+ // Lookup curie
1053
+ let url = this . schema . prefixes [ prefix ] [ 'prefix_reference' ] + reference ;
1054
+ if ( as_markup )
1055
+ return `[${ curieOrURI } ](${ url } )` ;
1056
+ return `<a href="${ url } " target="_blank">${ curieOrURI } </a>` ;
1057
+ }
1058
+ else
1059
+ return `${ curieOrURI } ` ;
1060
+ }
1061
+ }
1062
+ return '' ;
1063
+ }
1064
+
1040
1065
/**
1041
1066
* Presents reference guide in a popup.
1042
1067
* @param {String } mystyle simple css stylesheet commands to override default.
@@ -1046,6 +1071,7 @@ class DataHarmonizer {
1046
1071
1047
1072
let style = `
1048
1073
body {
1074
+ background-color:#fff;
1049
1075
font-family: arial;
1050
1076
margin:5% 5% 5% 5%;
1051
1077
}
@@ -1080,17 +1106,19 @@ class DataHarmonizer {
1080
1106
let row_html = '' ;
1081
1107
for ( const section of this . sections ) {
1082
1108
row_html += `<tr class="section">
1083
- <td colspan="${ this . columnHelpEntries . length } "><h3>${
1109
+ <td colspan="${ this . columnHelpEntries . length - 1 } "><h3>${
1084
1110
section . title || section . name
1085
1111
} </h3></td>
1086
1112
</tr>
1087
1113
` ;
1088
1114
for ( const slot of section . children ) {
1089
1115
const slot_dict = this . getCommentDict ( slot ) ;
1090
1116
1117
+ const slot_uri = this . renderSemanticID ( slot_dict . slot_uri ) ;
1118
+
1091
1119
row_html += '<tr>' ;
1092
1120
if ( this . columnHelpEntries . includes ( 'column' ) ) {
1093
- row_html += `<td class="label">${ slot_dict . title } </td>` ;
1121
+ row_html += `<td class="label">${ slot_dict . title } <br> ${ slot_uri } < /td>` ;
1094
1122
}
1095
1123
if ( this . columnHelpEntries . includes ( 'description' ) ) {
1096
1124
row_html += `<td>${ slot_dict . description } </td>` ;
@@ -1102,38 +1130,62 @@ class DataHarmonizer {
1102
1130
row_html += `<td>${ slot_dict . examples } </td>` ;
1103
1131
}
1104
1132
if ( this . columnHelpEntries . includes ( 'menus' ) ) {
1105
- row_html += ` <td>${ slot_dict . sources || '' } </td>` ;
1133
+ row_html += ` <td>${ slot_dict . menus || '' } </td>` ;
1106
1134
}
1107
1135
row_html += '</tr>' ;
1108
1136
}
1109
1137
}
1110
1138
1139
+ // Note this may include more enumerations than exist in a given template.
1140
+ let enum_html = `` ;
1141
+ for ( const key of Object . keys ( this . schema . enums ) . sort ( ) ) {
1142
+ const enumeration = this . schema . enums [ key ] ;
1143
+ let title = enumeration . title != enumeration . name ? enumeration . title : '' ;
1144
+ enum_html += `<tr class="section">
1145
+ <td colspan="2" id="${ enumeration . name } ">${ enumeration . name } </td>
1146
+ <td colspan="2" style="font-size:1.2rem;">"${ title } "<br>${ this . renderSemanticID ( enumeration . enum_uri ) } </td>
1147
+ </tr>` ;
1148
+
1149
+ for ( const item_key in enumeration . permissible_values ) {
1150
+ const item = enumeration . permissible_values [ item_key ] ;
1151
+ let text = item . text != item_key ? item . text : '' ;
1152
+ enum_html += `<tr>
1153
+ <td>${ this . renderSemanticID ( item . meaning ) } </td>
1154
+ <td>${ item_key } </td>
1155
+ <td>${ text } </td>
1156
+ <td></td>
1157
+ </tr>` ;
1158
+ }
1159
+ }
1160
+
1111
1161
var win = window . open (
1112
1162
'' ,
1113
1163
'Reference' ,
1114
- 'toolbar=no,location=no ,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=1000,height=600'
1164
+ 'toolbar=no,location=yes ,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=1000,height=600'
1115
1165
) ;
1116
1166
1117
- win . document . head . innerHTML = `
1118
- <meta charset="utf-8">
1119
- <title>${ i18next . t ( 'reference_guide_title' ) } "${
1167
+ win . document . open ( ) ; // For reloads
1168
+ win . document . write ( `<!DOCTYPE html>
1169
+ <html lang="en">
1170
+ <head>
1171
+ <meta charset="utf-8">
1172
+ <title>${ i18next . t ( 'reference_guide_title' ) } "${
1120
1173
schema_template . title || schema_template . name
1121
1174
} " template</title>
1122
- <meta name="description" content="${ schema_template . description || '' } ">
1123
- <style>${ style } </style>
1124
- ` ;
1125
-
1126
- win . document . body . innerHTML = `
1127
- <div>
1175
+ <meta name="description" content="${ schema_template . description || '' } ">
1176
+ <style>${ style } </style>
1177
+ </head>
1178
+ <body>
1179
+ <div>
1128
1180
<h2>${ i18next . t ( 'reference_guide_title' ) } "${
1129
1181
schema_template . title || schema_template . name
1130
1182
} " template</h2>
1131
- <hr size="2" />
1183
+ <hr/>
1132
1184
<p>${ schema_template . description || '' } </p>
1133
1185
1134
1186
<table>
1135
- <thead>
1136
- <tr>
1187
+ <thead>
1188
+ <tr>
1137
1189
${
1138
1190
this . columnHelpEntries . includes ( 'column' )
1139
1191
? `<th class="label">${ i18next . t ( 'help-sidebar__column' ) } </th>`
@@ -1161,16 +1213,25 @@ class DataHarmonizer {
1161
1213
? `<th class="data_status">${ i18next . t ( 'help-sidebar__menus' ) } </th>`
1162
1214
: ''
1163
1215
}
1164
- </tr>
1165
- </thead>
1166
- <tbody>
1167
- ${ row_html }
1168
- </tbody>
1169
- </table>
1216
+ </tr>
1217
+ </thead>
1218
+ <tbody>
1219
+ ${ row_html }
1220
+ </tbody>
1221
+ </table>
1170
1222
</div>
1171
- </body>
1172
- </html>
1173
- ` ;
1223
+ <div>
1224
+ <table>
1225
+ <thead>
1226
+ <tr class="section">
1227
+ <th colspan="4">${ i18next . t ( 'help-picklists' ) } </th>
1228
+ </tr>
1229
+ </thead>
1230
+ <tbody>${ enum_html } </tbody>
1231
+ </table>
1232
+ </div>
1233
+ </body>
1234
+ </html>` ) ;
1174
1235
return false ;
1175
1236
}
1176
1237
@@ -1455,8 +1516,8 @@ class DataHarmonizer {
1455
1516
// Close current dialog and switch to error message
1456
1517
//$('specify-headers-modal').modal('hide');
1457
1518
//$('#unmapped-headers-modal').modal('hide');
1458
- const errMsg = `The template for the loaded file has a configuration error:<br/ >
1459
- <strong>${ parent . title } </strong><br/ >
1519
+ const errMsg = `The template for the loaded file has a configuration error:<br>
1520
+ <strong>${ parent . title } </strong><br>
1460
1521
This is a field that has no parent, or a section that has no fields.` ;
1461
1522
$ ( '#unmapped-headers-list' ) . html ( errMsg ) ;
1462
1523
$ ( '#unmapped-headers-modal' ) . modal ( 'show' ) ;
@@ -1868,6 +1929,14 @@ class DataHarmonizer {
1868
1929
) } </strong>: ${ field . title || field . name } </p>`;
1869
1930
}
1870
1931
1932
+ // Requires markup treatment of URLS.
1933
+ const slot_uri = this . renderSemanticID ( field . slot_uri ) ;
1934
+ if ( field . slot_uri && this . columnHelpEntries . includes ( 'slot_uri' ) ) {
1935
+ ret += `<p><strong data-i18n="help-sidebar__column">${ i18next . t (
1936
+ 'help-sidebar__slot_uri'
1937
+ ) } </strong>: ${ slot_uri } </p>`;
1938
+ }
1939
+
1871
1940
if ( field . description && this . columnHelpEntries . includes ( 'description' ) ) {
1872
1941
ret += `<p><strong data-i18n="help-sidebar__description">${ i18next . t (
1873
1942
'help-sidebar__description'
@@ -1907,10 +1976,12 @@ class DataHarmonizer {
1907
1976
let guide = {
1908
1977
title : field . title ,
1909
1978
name : field . name ,
1910
- description : field . description || '' ,
1979
+ slot_uri : field . slot_uri ,
1980
+ description : urlToClickableAnchor ( field . description ) || '' ,
1911
1981
guidance : '' ,
1912
1982
examples : '' ,
1913
1983
sources : '' ,
1984
+ menus : ''
1914
1985
} ;
1915
1986
1916
1987
let guidance = [ ] ;
@@ -1955,7 +2026,13 @@ class DataHarmonizer {
1955
2026
guidance . push ( i18next . t ( 'reference_guide_msg_unique_record' ) ) ;
1956
2027
}
1957
2028
if ( field . sources && field . sources . length ) {
1958
- let sources = [ ] ;
2029
+ let menus = [ ] ;
2030
+ for ( const item of field . sources ) {
2031
+ menus . push ( '<a href="#' + item + '" target="Reference">' + item + '</a>' ) ;
2032
+ }
2033
+ guide . menus = '<ul><li>' + menus . join ( '</li><li>' ) + '</li></ul>' ;
2034
+ /*
2035
+ // List null value menu items directly
1959
2036
for (const [, item] of Object.entries(field.sources)) {
1960
2037
// List null value menu items directly
1961
2038
if (item === 'NullValueMenu') {
@@ -1967,7 +2044,8 @@ class DataHarmonizer {
1967
2044
sources.push(item);
1968
2045
}
1969
2046
}
1970
- guide . sources = '<ul><li>' + sources . join ( '</li>\n<li>' ) + '</li></ul>' ;
2047
+ */
2048
+ guide . sources = '<ul><li>' + field . sources . join ( '</li><li>' ) + '</li></ul>' ;
1971
2049
}
1972
2050
if ( field . multivalued ) {
1973
2051
guidance . push ( i18next . t ( 'reference_guide_msg_more_than_one_selection' ) ) ;
@@ -1979,6 +2057,10 @@ class DataHarmonizer {
1979
2057
} )
1980
2058
. join ( '\n' ) ;
1981
2059
2060
+ // Makes full URIs that aren't in markup into <a href>
2061
+ if ( guide . guidance )
2062
+ guide . guidance = urlToClickableAnchor ( guide . guidance ) ;
2063
+
1982
2064
if ( field . examples && field . examples . length ) {
1983
2065
let examples = [ ] ;
1984
2066
let first_item = true ;
@@ -1994,9 +2076,9 @@ class DataHarmonizer {
1994
2076
1995
2077
if ( first_item === true ) {
1996
2078
first_item = false ;
1997
- examples += '<ul><li>' + i18next . t ( item . value ) + '</li>\n ' ;
2079
+ examples += '<ul><li>' + i18next . t ( item . value ) + '</li>' ;
1998
2080
} else {
1999
- examples += '<li>' + i18next . t ( item . value ) + '</li>\n ' ;
2081
+ examples += '<li>' + i18next . t ( item . value ) + '</li>' ;
2000
2082
}
2001
2083
}
2002
2084
guide . examples = examples + '</ul>' ;
0 commit comments