-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #151 from vrk-kpa/REKDAT-67_fix_missing_input_desc…
…ription REKDAT-67: fix missing input descriptions
- Loading branch information
Showing
27 changed files
with
466 additions
and
436 deletions.
There are no files selected for viewing
345 changes: 180 additions & 165 deletions
345
ckan/ckanext/ckanext-registrydata/ckanext/registrydata/i18n/ckanext-registrydata.pot
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
ckan/ckanext/ckanext-registrydata/ckanext/registrydata/templates/macros/form/input.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{% from "macros/form/input_block.html" import input_block %} | ||
{% from "macros/form/attributes.html" import attributes %} | ||
|
||
{# | ||
ADDED DESCRIPTION PROPERTY | ||
Creates all the markup required for an input element. Handles matching labels to | ||
inputs, error messages and other useful elements. | ||
|
||
name - The name of the form parameter. | ||
id - The id to use on the input and label. Convention is to prefix with 'field-'. | ||
label - The human readable label. | ||
value - The value of the input. | ||
placeholder - Some placeholder text. | ||
type - The type of input eg. email, url, date (default: text). | ||
error - A list of error strings for the field or just true to highlight the field. | ||
classes - An array of classes to apply to the form-group. | ||
is_required - Boolean of whether this input is requred for the form to validate | ||
description - Additional description text between the label and the input | ||
#} | ||
|
||
|
||
|
||
{% macro input(name, id='', label='', value='', placeholder='', type='text', error="", classes=[], attrs={'class': 'form-control'}, is_required=false, description="") %} | ||
{%- set extra_html = caller() if caller -%} | ||
{% call input_block(id or name, label or name, error, classes, extra_html=extra_html, is_required=is_required, description=description) %} | ||
<input id="{{ id or name }}" type="{{ type }}" name="{{ name }}" value="{{ value | empty_and_escape }}" placeholder="{{ placeholder }}" {{ attributes(attrs) }} /> | ||
{% endcall %} | ||
{% endmacro %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
...anext/ckanext-registrydata/ckanext/registrydata/templates/macros/form/input_multiple.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{% from "macros/form/input_block.html" import input_block %} | ||
{% from "macros/form/attributes.html" import attributes %} | ||
|
||
{% macro input_multiple(name, id='', label='', value='', placeholder='', type='text', error="", classes=[], attrs={}, is_required=false, description="") %} | ||
{% asset 'registrydata/form-js' %} | ||
{% do classes.append('control-medium') %} | ||
{%- set extra_html = caller() if caller -%} | ||
{% call input_block(id or name, label or name, error, classes, control_classes=["editor"], extra_html=extra_html, is_required=is_required, description="") %} | ||
<div class="multiple-values"> | ||
{% if value and value != [''] %} | ||
{% set values = value if value.append else [value] %} | ||
{% for value_item in values %} | ||
{% if value_item %} | ||
<div class="multiple-value-group"> | ||
<input id="{{ id or name }}-{{ loop.index }}" type="{{ type }}" name="{{ name }}" value="{{ value_item | empty_and_escape }}" placeholder="{{ placeholder }}" class="multiple-value form-control" {{ form.attributes(attrs) }} /> | ||
</div> | ||
{% endif %} | ||
{% endfor %} | ||
{% else %} | ||
<div class="multiple-value-group"> | ||
<input id="{{ id or name }}" type="{{ type }}" name="{{ name }}" value="" placeholder="{{ placeholder }}" class="multiple-value form-control" {{ attributes(attrs) }} /> | ||
</div> | ||
{% endif %} | ||
</div> | ||
{% endcall %} | ||
{% endmacro %} |
42 changes: 42 additions & 0 deletions
42
ckan/ckanext/ckanext-registrydata/ckanext/registrydata/templates/macros/form/markdown.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{% from "macros/form/input_block.html" import input_block %} | ||
{% from "macros/form/attributes.html" import attributes %} | ||
|
||
|
||
{# | ||
Creates all the markup required for a Markdown textarea element. Handles | ||
matching labels to inputs, selected item and error messages. | ||
|
||
name - The name of the form parameter. | ||
id - The id to use on the input and label. Convention is to prefix with 'field-'. | ||
label - The human readable label. | ||
value - The value of the input. | ||
placeholder - Some placeholder text. | ||
error - A list of error strings for the field or just true to highlight the field. | ||
classes - An array of classes to apply to the form-group. | ||
is_required - Boolean of whether this input is requred for the form to validate | ||
|
||
Examples: | ||
|
||
{% import 'macros/form.html' as form %} | ||
{{ form.markdown('desc', id='field-description', label=_('Description'), value=data.desc, error=errors.desc) }} | ||
|
||
#} | ||
|
||
|
||
{% macro markdown(name, id='', label='', value='', placeholder='', error="", classes=[], attrs={'class': 'form-control'}, is_required=false, description=None) %} | ||
{% set classes = (classes|list) %} | ||
{% do classes.append('control-full') %} | ||
{% set markdown_tooltip = '<pre><p>__Bold text__ or _italic text_</p><p># title<br>## secondary title<br>### etc</p><p>* list<br>* of<br>* items</p><p>http://auto.link.ed/</p></pre><p><b><a href="https://daringfireball.net/projects/markdown/syntax" | ||
target="_blank">Full markdown syntax</a></b></p><p class="text-muted"><b>Please note:</b> HTML tags are stripped out for security reasons</p>' %} | ||
|
||
{%- set extra_html = caller() if caller -%} | ||
{% call input_block(id or name, label or name, error, classes, control_classes=["editor"], extra_html=extra_html, is_required=is_required, description=description) %} | ||
<textarea id="{{ id or name }}" name="{{ name }}" cols="20" rows="5" placeholder="{{ placeholder }}" {{ form.attributes(attrs) }}>{{ value | empty_and_escape }}</textarea> | ||
<span class="editor-info-block">{% trans %}You can use <a href="#markdown" | ||
title="Markdown quick reference" | ||
data-bs-toggle="popover" | ||
data-bs-trigger="focus" | ||
data-bs-content="{{ markdown_tooltip }}" | ||
data-bs-html="true">Markdown formatting</a> here{% endtrans %}</span> | ||
{% endcall %} | ||
{% endmacro %} |
41 changes: 41 additions & 0 deletions
41
ckan/ckanext/ckanext-registrydata/ckanext/registrydata/templates/macros/form/prepend.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{% from "macros/form/input_block.html" import input_block %} | ||
{% from "macros/form/attributes.html" import attributes %} | ||
|
||
{# | ||
ADDED DESCRIPTION PROPERTY | ||
Creates all the markup required for an input element with a prefixed segment. | ||
These are useful for showing url slugs and other fields where the input | ||
information forms only part of the saved data. | ||
|
||
name - The name of the form parameter. | ||
id - The id to use on the input and label. Convention is to prefix with 'field-'. | ||
label - The human readable label. | ||
prepend - The text that will be prepended before the input. | ||
value - The value of the input. | ||
which will use the name key as the value. | ||
placeholder - Some placeholder text. | ||
error - A list of error strings for the field or just true to highlight the field. | ||
classes - An array of classes to apply to the form-group. | ||
is_required - Boolean of whether this input is requred for the form to validate | ||
|
||
Examples: | ||
|
||
{% import 'macros/form.html' as form %} | ||
{{ form.prepend('slug', id='field-slug', prepend='/dataset/', label=_('Slug'), value=data.slug, error=errors.slug) }} | ||
|
||
#} | ||
{% macro prepend(name, id='', label='', prepend='', value='', placeholder='', type='text', error="", classes=[], attrs={'class': 'form-control'}, is_required=false, description='') %} | ||
{# We manually append the error here as it needs to be inside the .input-group block #} | ||
{% set classes = (classes|list) %} | ||
{% do classes.append('error') if error %} | ||
{%- set extra_html = caller() if caller -%} | ||
{% call input_block(id or name, label or name, error='', classes=classes, extra_html=extra_html, is_required=is_required, description=description) %} | ||
<div class="input-group"> | ||
{% if prepend %} | ||
<label class="input-group-text">{{ prepend }}</label> | ||
{%- endif -%} | ||
<input id="{{ id or name }}" type="{{ type }}" name="{{ name }}" value="{{ value | empty_and_escape }}" placeholder="{{ placeholder }}" {{ attributes(attrs) }} /> | ||
{% if error and error is iterable %}<span class="error-block">{{ error|join(", ") }}</span>{% endif %} | ||
</div> | ||
{% endcall %} | ||
{% endmacro %} |
42 changes: 42 additions & 0 deletions
42
ckan/ckanext/ckanext-registrydata/ckanext/registrydata/templates/macros/form/select.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{% from "macros/form/input_block.html" import input_block %} | ||
{% from "macros/form/attributes.html" import attributes %} | ||
|
||
{# | ||
ADDED DESCRIPTION PROPERTY | ||
Creates all the markup required for an select element. Handles matching labels to | ||
inputs and error messages. | ||
|
||
A field should be a dict with a "value" key and an optional "text" key which | ||
will be displayed to the user. We use a dict to easily allow extension in | ||
future should extra options be required. | ||
|
||
name - The name of the form parameter. | ||
id - The id to use on the input and label. Convention is to prefix with 'field-'. | ||
label - The human readable label. | ||
description - Additional description text between the label and the input | ||
options - A list/tuple of fields to be used as <options>. | ||
selected - The value of the selected <option>. | ||
error - A list of error strings for the field or just true to highlight the field. | ||
classes - An array of classes to apply to the form-group. | ||
is_required - Boolean of whether this input is requred for the form to validate | ||
|
||
Examples: | ||
|
||
{% import 'macros/form.html' as form %} | ||
{{ form.select('year', label=_('Year'), options=[{'name':2010, 'value': 2010},{'name': 2011, 'value': 2011}], selected=2011, error=errors.year) }} | ||
|
||
#} | ||
{% macro select(name, id='', label='', options='', selected='', error='', classes=[], attrs={'class': 'form-control'}, is_required=false, description='') %} | ||
{% set classes = (classes|list) %} | ||
{% do classes.append('control-select') %} | ||
|
||
{%- set extra_html = caller() if caller -%} | ||
{% call input_block(id or name, label or name, error, classes, extra_html=extra_html, is_required=is_required, description=description) %} | ||
<select id="{{ id or name }}" name="{{ name }}" {{ attributes(attrs) }}> | ||
{% for option in options %} | ||
<option value="{{ option.value }}" | ||
{% if option.value == selected %}selected{% endif %}>{{ option.text or option.value }}</option> | ||
{% endfor %} | ||
</select> | ||
{% endcall %} | ||
{% endmacro %} |
35 changes: 35 additions & 0 deletions
35
ckan/ckanext/ckanext-registrydata/ckanext/registrydata/templates/macros/form/textarea.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{% from "macros/form/input_block.html" import input_block %} | ||
{% from "macros/form/attributes.html" import attributes %} | ||
|
||
{# | ||
ADDED DESCRIPTION PROPERTY | ||
Creates all the markup required for a plain textarea element. Handles | ||
matching labels to inputs, selected item and error messages. | ||
|
||
name - The name of the form parameter. | ||
id - The id to use on the input and label. Convention is to prefix with 'field-'. | ||
label - The human readable label. | ||
description - Additional description text between the label and the input | ||
value - The value of the input. | ||
placeholder - Some placeholder text. | ||
error - A list of error strings for the field or just true to highlight the field. | ||
classes - An array of classes to apply to the form-group. | ||
is_required - Boolean of whether this input is requred for the form to validate | ||
|
||
Examples: | ||
|
||
{% import 'macros/form.html' as form %} | ||
{{ form.textarea('desc', id='field-description', label=_('Description'), value=data.desc, error=errors.desc) }} | ||
|
||
#} | ||
|
||
|
||
{% macro textarea(name, id='', label='', value='', placeholder='', error="", classes=[], attrs={'class': 'form-control'}, is_required=false, rows=5, cols=20, description='') %} | ||
{% set classes = (classes|list) %} | ||
{% do classes.append('control-full') %} | ||
|
||
{%- set extra_html = caller() if caller -%} | ||
{% call input_block(id or name, label or name, error, classes, extra_html=extra_html, is_required=is_required, description=description) %} | ||
<textarea id="{{ id or name }}" name="{{ name }}" cols="{{ cols }}" rows="{{ rows }}" placeholder="{{ placeholder }}" {{ attributes(attrs) }}>{{ value | empty_and_escape }}</textarea> | ||
{% endcall %} | ||
{% endmacro %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...egistrydata/ckanext/registrydata/templates/scheming/form_snippets/fluent_markdown_ex.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.