init
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
{% extends "forms/field.html.twig" %}
|
||||
|
||||
{% macro spanToggle(input, length) %}
|
||||
{% set space = repeat(' ', (length - input|length) / 2) %}
|
||||
{{ (space ~ input ~ space)|raw }}
|
||||
{% endmacro %}
|
||||
|
||||
{% import _self as macro %}
|
||||
|
||||
{% set value = (value is null ? field.default : value) %}
|
||||
|
||||
{% block global_attributes %}
|
||||
{{ parent() }}
|
||||
data-grav-field-name="{{ (scope ~ field.name)|fieldName }}"
|
||||
{% endblock %}
|
||||
|
||||
{% block input %}
|
||||
{% set flex = grav['flex_objects'] %}
|
||||
{% set all = flex.blueprints %}
|
||||
{% if all|count %}
|
||||
{% set legacy = flex.getLegacyBlueprintMap() %}
|
||||
{% for label, directory in all %}
|
||||
{% set url = directory.blueprintFile %}
|
||||
{% set found = url in value %}
|
||||
{% if not found and legacy[url] is defined %}
|
||||
{% set found = legacy[url] in value %}
|
||||
{% endif %}
|
||||
|
||||
<div class="form-data block size-2-3" data-grav-field="toggle" data-grav-disabled="" data-grav-default="null" data-grav-field-name="{{ (scope ~ field.name)|fieldName }}[{{ loop.index0 }}]">
|
||||
<div class="switch-toggle switch-grav switch-2">
|
||||
{% set maxLen = 0 %}
|
||||
{% for text in ['PLUGIN_ADMIN.ENABLED', 'PLUGIN_ADMIN.DISABLED'] %}
|
||||
{% set translation = grav.twig.twig.filters['tu'] is defined ? text|tu : text|t %}
|
||||
{% set maxLen = max(translation|length, maxLen) %}
|
||||
{% endfor %}
|
||||
|
||||
{% set id = "toggle_" ~ field.name ~ '_' ~ label %}
|
||||
|
||||
<input type="radio"
|
||||
value="{{ url }}"
|
||||
id="{{ id ~ '_yes' }}"
|
||||
name="{{ (scope ~ field.name)|fieldName }}[{{ loop.index0 }}]"
|
||||
class="highlight"
|
||||
{% if found %}
|
||||
checked="checked"
|
||||
{% endif %}
|
||||
/>
|
||||
{% set text = 'PLUGIN_ADMIN.ENABLED' %}
|
||||
{% set translation = (grav.twig.twig.filters['tu'] is defined ? text|tu : text|t)|trim %}
|
||||
<label for="{{ id ~ '_yes' }}">{{ (macro.spanToggle(translation, maxLen)|trim)|raw }}</label>
|
||||
<input type="radio"
|
||||
value=""
|
||||
name="{{ (scope ~ field.name)|fieldName }}[{{ loop.index0 }}]"
|
||||
id="{{ id ~ '_no' }}"
|
||||
{% if not found %}
|
||||
checked="checked"
|
||||
{% endif %}
|
||||
/>
|
||||
{% set text = 'PLUGIN_ADMIN.DISABLED' %}
|
||||
{% set translation = (grav.twig.twig.filters['tu'] is defined ? text|tu : text|t)|trim %}
|
||||
<label for="{{ id ~ '_no' }}">{{ (macro.spanToggle(translation, maxLen)|trim)|raw }}</label>
|
||||
</div>
|
||||
<span title="{{ directory.description|tu }}">{{ directory.title|tu }}</span>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<div>{{ 'PLUGIN_FLEX_OBJECTS.ERROR.NO_FLEX_DIRECTORIES'|tu }}</div>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,37 @@
|
||||
{% extends "forms/field.html.twig" %}
|
||||
|
||||
{% set originalValue = value %}
|
||||
{% set value = (value is null ? field.default : value) %}
|
||||
{% set isNew = key ? false : true %}
|
||||
{% set savedOption = grav.session.post_entries_save|default('create-new') %}
|
||||
|
||||
{% if isNew %}
|
||||
{% set options = {'create-new':'PLUGIN_FLEX_OBJECTS.ACTION.CREATE_NEW', 'edit':'PLUGIN_FLEX_OBJECTS.ACTION.EDIT_ITEM', 'list':'PLUGIN_FLEX_OBJECTS.ACTION.LIST_ITEMS'} %}
|
||||
{% else %}
|
||||
{% set options = {'edit':'PLUGIN_FLEX_OBJECTS.ACTION.EDIT_ITEM', 'list':'PLUGIN_FLEX_OBJECTS.ACTION.LIST_ITEMS'} %}
|
||||
{% endif %}
|
||||
|
||||
{% block input %}
|
||||
{% set savedOption = not isNew and savedOption == 'create-new' ? 'edit' : savedOption %}
|
||||
{% for key, text in options %}
|
||||
{% set id = field.id|default(field.name) ~ '-' ~ key %}
|
||||
|
||||
{% if savedOption == key %}
|
||||
{% set value = savedOption %}
|
||||
{% endif %}
|
||||
|
||||
<span class="radio">
|
||||
<input type="radio"
|
||||
value="{{ key|e }}"
|
||||
id="{{ id|e }}"
|
||||
name="{{ (field.name)|fieldName }}"
|
||||
{% if key == value %}checked="checked" {% endif %}
|
||||
{% if field.disabled or isDisabledToggleable %}disabled="disabled"{% endif %}
|
||||
{% if field.validate.required in ['on', 'true', 1] %}required="required"{% endif %}
|
||||
/>
|
||||
<label style="display: inline" class="inline" for="{{ id|e }}">{{ text|tu|e }}</label>
|
||||
</span>
|
||||
|
||||
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user