forked from ckan/ckanext-scheming
-
Notifications
You must be signed in to change notification settings - Fork 0
/
slug.html
35 lines (30 loc) · 1.16 KB
/
slug.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
{% import 'macros/form.html' as form %}
{%- if entity_type == 'dataset' %}
{%- set controller = 'package' -%}
{%- set module_placeholder = '<dataset>' -%}
{%- elif entity_type == 'organization' %}
{%- set controller = 'organization' -%}
{%- set module_placeholder = '<organization>' -%}
{%- elif entity_type == 'group' -%}
{%- set controller = 'group' -%}
{%- set module_placeholder = '<group>' -%}
{%- endif -%}
{%- set prefix = h.url_for(controller=controller, action='read', id='') -%}
{%- set domain = h.url_for(controller=controller, action='read', id='',
qualified=true) -%}
{%- set domain = domain|replace("http://", "")|replace("https://", "") -%}
{%- set attrs = {
'data-module': 'slug-preview-slug',
'data-module-prefix': domain,
'data-module-placeholder': module_placeholder } -%}
{{ form.prepend(
field.field_name,
id='field-' + field.field_name,
label=h.scheming_language_text(field.label),
prepend=prefix,
placeholder=h.scheming_language_text(field.form_placeholder),
value=data[field.field_name],
error=errors[field.field_name],
attrs=attrs,
is_required=h.scheming_field_required(field)
) }}