FHIR-31356 Add quick links to copy 'coding' from value set and code system enumerations
This commit is contained in:
parent
4b8f8e3d2b
commit
d97e2d8534
|
@ -183,7 +183,7 @@ public class CodeSystemRenderer extends TerminologyRenderer {
|
|||
hierarchy = hierarchy || csNav.isRestructure();
|
||||
|
||||
List<String> langs = new ArrayList<>();
|
||||
addMapHeaders(addTableHeaderRowStandard(t, hierarchy, display, definitions, commentS, version, deprecated, properties, null, null, false), maps);
|
||||
addCopyColumn(addMapHeaders(addTableHeaderRowStandard(t, hierarchy, display, definitions, commentS, version, deprecated, properties, null, null, false), maps));
|
||||
for (ConceptDefinitionComponent c : csNav.getConcepts(null)) {
|
||||
hasExtensions = addDefineRowToTable(t, c, 0, hierarchy, display, definitions, commentS, version, deprecated, maps, cs.getUrl(), cs, properties, csNav, langs, isSupplement) || hasExtensions;
|
||||
}
|
||||
|
@ -202,6 +202,13 @@ public class CodeSystemRenderer extends TerminologyRenderer {
|
|||
return hasExtensions;
|
||||
}
|
||||
|
||||
private void addCopyColumn(XhtmlNode tr) {
|
||||
if (context.isCopyButton()) {
|
||||
tr.td().b().tx("Copy");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private boolean conceptsHaveDefinition(ConceptDefinitionComponent c) {
|
||||
if (c.hasDefinition()) {
|
||||
return true;
|
||||
|
@ -492,6 +499,12 @@ public class CodeSystemRenderer extends TerminologyRenderer {
|
|||
}
|
||||
td = tr.td().colspan(Integer.toString(w));
|
||||
}
|
||||
if (context.isCopyButton()) {
|
||||
td = tr.td();
|
||||
clipboard(td, "icon_clipboard_x.png", "XML", "<system value=\""+Utilities.escapeXml(cs.getUrl())+"\">\n"+(cs.getVersionNeeded() ? "<version value=\""+Utilities.escapeXml(cs.getVersion())+"\">\n" : "")+"<code value=\""+Utilities.escapeXml(c.getCode())+"\">\n<display value=\""+Utilities.escapeXml(c.getDisplay())+"\">\n");
|
||||
td.nbsp();
|
||||
clipboard(td, "icon_clipboard_j.png", "JSON", "\"system\" : \""+Utilities.escapeXml(cs.getUrl())+"\",\n"+(cs.getVersionNeeded() ? "\"version\" : \""+Utilities.escapeXml(cs.getVersion())+"\",\n" : "")+"\"code\" : \""+Utilities.escapeXml(c.getCode())+"\",\n\"display\" : \""+Utilities.escapeXml(c.getDisplay())+"\"\n");
|
||||
}
|
||||
return hasExtensions;
|
||||
}
|
||||
|
||||
|
|
|
@ -111,7 +111,7 @@ public abstract class TerminologyRenderer extends ResourceRenderer {
|
|||
}
|
||||
|
||||
|
||||
protected void addMapHeaders(XhtmlNode tr, List<UsedConceptMap> maps) throws FHIRFormatError, DefinitionException, IOException {
|
||||
protected XhtmlNode addMapHeaders(XhtmlNode tr, List<UsedConceptMap> maps) throws FHIRFormatError, DefinitionException, IOException {
|
||||
for (UsedConceptMap m : maps) {
|
||||
XhtmlNode td = tr.td();
|
||||
XhtmlNode b = td.b();
|
||||
|
@ -120,6 +120,7 @@ public abstract class TerminologyRenderer extends ResourceRenderer {
|
|||
if (m.getDetails().isDoDescription() && m.getMap().hasDescription())
|
||||
addMarkdown(td, m.getMap().getDescription());
|
||||
}
|
||||
return tr;
|
||||
}
|
||||
|
||||
protected String getHeader() {
|
||||
|
@ -311,8 +312,6 @@ public abstract class TerminologyRenderer extends ResourceRenderer {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected String getDisplayForConcept(String system, String version, String value) {
|
||||
if (value == null || system == null)
|
||||
return null;
|
||||
|
@ -320,4 +319,13 @@ public abstract class TerminologyRenderer extends ResourceRenderer {
|
|||
return cl == null ? null : cl.getDisplay();
|
||||
}
|
||||
|
||||
|
||||
protected void clipboard(XhtmlNode x, String img, String title, String source) {
|
||||
XhtmlNode span = x.span("cursor: pointer", "Copy "+title+" Format to clipboard");
|
||||
span.attribute("onClick", "navigator.clipboard.writeText('"+Utilities.escapeJson(source)+"');");
|
||||
span.img(img).setAttribute("width", "24px").setAttribute("height", "16px");
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -131,6 +131,7 @@ public class RenderingContext {
|
|||
private DateTimeFormatter dateFormat;
|
||||
private DateTimeFormatter dateYearFormat;
|
||||
private DateTimeFormatter dateYearMonthFormat;
|
||||
private boolean copyButton;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -190,6 +191,7 @@ public class RenderingContext {
|
|||
res.targetVersion = targetVersion;
|
||||
res.locale = locale;
|
||||
res.showComments = showComments;
|
||||
res.copyButton = copyButton;
|
||||
|
||||
res.terminologyServiceOptions = terminologyServiceOptions.copy();
|
||||
return res;
|
||||
|
@ -596,6 +598,13 @@ public class RenderingContext {
|
|||
this.showComments = showComments;
|
||||
return this;
|
||||
}
|
||||
public boolean isCopyButton() {
|
||||
return copyButton;
|
||||
}
|
||||
public RenderingContext setCopyButton(boolean copyButton) {
|
||||
this.copyButton = copyButton;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue