diff options
author | Adam Novak | 2020-04-17 13:07:18 -0700 |
---|---|---|
committer | Adam Novak | 2020-04-17 13:07:18 -0700 |
commit | b2d3b101b7a44932632036146b7c271acfd67593 (patch) | |
tree | 5696b0f043b8d364a61992d276b4f14ed8f0e122 | |
parent | 88e6bb6e82f606c91fca6b3edd410cb28146f569 (diff) | |
download | bh20-seq-resource-b2d3b101b7a44932632036146b7c271acfd67593.tar.gz bh20-seq-resource-b2d3b101b7a44932632036146b7c271acfd67593.tar.lz bh20-seq-resource-b2d3b101b7a44932632036146b7c271acfd67593.zip |
Pull 'doc' from the schema through to the frontend
-rw-r--r-- | bh20simplewebuploader/main.py | 9 | ||||
-rw-r--r-- | bh20simplewebuploader/templates/form.html | 2 |
2 files changed, 9 insertions, 2 deletions
diff --git a/bh20simplewebuploader/main.py b/bh20simplewebuploader/main.py index 0db7d84..8c5c18c 100644 --- a/bh20simplewebuploader/main.py +++ b/bh20simplewebuploader/main.py @@ -68,7 +68,8 @@ def generate_form(schema, options): form section in the template) or an 'id', 'label', 'type', and 'required' (in which case we make a form field in the template). Non-heading dicts with type 'select' will have an 'options' field, with a list of (name, - value) tuples, and represent a form dropdown element. + value) tuples, and represent a form dropdown element. Non-heading dicts may + have a human-readable 'docstring' field describing them. Takes the deserialized metadata schema YAML, and also a deserialized YAML of option values. The option values are keyed on (unscoped) field name in @@ -110,8 +111,12 @@ def generate_form(schema, options): # For each field ref_iri = None + docstring = None if not isinstance(field_type, str): # If the type isn't a string + + # It may have documentation + docstring = field_type.get('doc', None) # See if it has a more info/what goes here URL predicate = field_type.get('jsonldPredicate', {}) @@ -156,6 +161,8 @@ def generate_form(schema, options): record['required'] = not optional and not subtree_optional if ref_iri: record['ref_iri'] = ref_iri + if docstring: + record['docstring'] = docstring if field_name in options: # The field will be a 'select' type no matter what its real diff --git a/bh20simplewebuploader/templates/form.html b/bh20simplewebuploader/templates/form.html index 012b9c5..166f51c 100644 --- a/bh20simplewebuploader/templates/form.html +++ b/bh20simplewebuploader/templates/form.html @@ -224,7 +224,7 @@ {{ record['label'] }} {{ "*" if record['required'] else "" }} {% if 'ref_iri' in record %} - <a href="{{ record['ref_iri'] }}" title="More Info" target="_blank">?</a> + <a href="{{ record['ref_iri'] }}" title="{{ record.get('docstring', 'More Info') }}" target="_blank">?</a> {% endif %} </label> {% if record['type'] == 'select' %} |