@@ -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.
@@ -1088,9 +1113,11 @@ class DataHarmonizer {
1088
1113
for ( const slot of section . children ) {
1089
1114
const slot_dict = this . getCommentDict ( slot ) ;
1090
1115
1116
+ const slot_uri = this . renderSemanticID ( slot_dict . slot_uri ) ;
1117
+
1091
1118
row_html += '<tr>' ;
1092
1119
if ( this . columnHelpEntries . includes ( 'column' ) ) {
1093
- row_html += `<td class="label">${ slot_dict . title } </td>` ;
1120
+ row_html += `<td class="label">${ slot_dict . title } <br/> ${ slot_uri } < /td>` ;
1094
1121
}
1095
1122
if ( this . columnHelpEntries . includes ( 'description' ) ) {
1096
1123
row_html += `<td>${ slot_dict . description } </td>` ;
@@ -1102,12 +1129,35 @@ class DataHarmonizer {
1102
1129
row_html += `<td>${ slot_dict . examples } </td>` ;
1103
1130
}
1104
1131
if ( this . columnHelpEntries . includes ( 'menus' ) ) {
1105
- row_html += ` <td>${ slot_dict . sources || '' } </td>` ;
1132
+ row_html += ` <td>${ slot_dict . menus || '' } </td>` ;
1106
1133
}
1107
1134
row_html += '</tr>' ;
1108
1135
}
1109
1136
}
1110
1137
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
+
1111
1161
var win = window . open (
1112
1162
'' ,
1113
1163
'Reference' ,
@@ -1168,7 +1218,19 @@ class DataHarmonizer {
1168
1218
</tbody>
1169
1219
</table>
1170
1220
</div>
1171
- </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>
1172
1234
</html>
1173
1235
` ;
1174
1236
return false ;
@@ -1868,6 +1930,14 @@ class DataHarmonizer {
1868
1930
) } </strong>: ${ field . title || field . name } </p>`;
1869
1931
}
1870
1932
1933
+ // Requires markup treatment of URLS.
1934
+ const slot_uri = this . renderSemanticID ( field . slot_uri ) ;
1935
+ if ( field . slot_uri && this . columnHelpEntries . includes ( 'slot_uri' ) ) {
1936
+ ret += `<p><strong data-i18n="help-sidebar__column">${ i18next . t (
1937
+ 'help-sidebar__slot_uri'
1938
+ ) } </strong>: ${ slot_uri } </p>`;
1939
+ }
1940
+
1871
1941
if ( field . description && this . columnHelpEntries . includes ( 'description' ) ) {
1872
1942
ret += `<p><strong data-i18n="help-sidebar__description">${ i18next . t (
1873
1943
'help-sidebar__description'
@@ -1907,10 +1977,12 @@ class DataHarmonizer {
1907
1977
let guide = {
1908
1978
title : field . title ,
1909
1979
name : field . name ,
1910
- description : field . description || '' ,
1980
+ slot_uri : field . slot_uri ,
1981
+ description : urlToClickableAnchor ( field . description ) || '' ,
1911
1982
guidance : '' ,
1912
1983
examples : '' ,
1913
1984
sources : '' ,
1985
+ menus : ''
1914
1986
} ;
1915
1987
1916
1988
let guidance = [ ] ;
@@ -1955,7 +2027,13 @@ class DataHarmonizer {
1955
2027
guidance . push ( i18next . t ( 'reference_guide_msg_unique_record' ) ) ;
1956
2028
}
1957
2029
if ( field . sources && field . sources . length ) {
1958
- let sources = [ ] ;
2030
+ let menus = [ ] ;
2031
+ for ( const item of field . sources ) {
2032
+ menus . push ( '<a href="#' + item + '" target="_self">' + item + '</a>' ) ;
2033
+ }
2034
+ guide . menus = '<ul><li>' + menus . join ( '</li><li>' ) + '</li></ul>' ;
2035
+ /*
2036
+ // List null value menu items directly
1959
2037
for (const [, item] of Object.entries(field.sources)) {
1960
2038
// List null value menu items directly
1961
2039
if (item === 'NullValueMenu') {
@@ -1967,7 +2045,8 @@ class DataHarmonizer {
1967
2045
sources.push(item);
1968
2046
}
1969
2047
}
1970
- guide . sources = '<ul><li>' + sources . join ( '</li>\n<li>' ) + '</li></ul>' ;
2048
+ */
2049
+ guide . sources = '<ul><li>' + field . sources . join ( '</li><li>' ) + '</li></ul>' ;
1971
2050
}
1972
2051
if ( field . multivalued ) {
1973
2052
guidance . push ( i18next . t ( 'reference_guide_msg_more_than_one_selection' ) ) ;
@@ -1979,6 +2058,10 @@ class DataHarmonizer {
1979
2058
} )
1980
2059
. join ( '\n' ) ;
1981
2060
2061
+ // Makes full URIs that aren't in markup into <a href>
2062
+ if ( guide . guidance )
2063
+ guide . guidance = urlToClickableAnchor ( guide . guidance ) ;
2064
+
1982
2065
if ( field . examples && field . examples . length ) {
1983
2066
let examples = [ ] ;
1984
2067
let first_item = true ;
@@ -1994,9 +2077,9 @@ class DataHarmonizer {
1994
2077
1995
2078
if ( first_item === true ) {
1996
2079
first_item = false ;
1997
- examples += '<ul><li>' + i18next . t ( item . value ) + '</li>\n ' ;
2080
+ examples += '<ul><li>' + i18next . t ( item . value ) + '</li>' ;
1998
2081
} else {
1999
- examples += '<li>' + i18next . t ( item . value ) + '</li>\n ' ;
2082
+ examples += '<li>' + i18next . t ( item . value ) + '</li>' ;
2000
2083
}
2001
2084
}
2002
2085
guide . examples = examples + '</ul>' ;
0 commit comments