-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
0a54e3f
commit 48d9117
Showing
12 changed files
with
149 additions
and
145 deletions.
There are no files selected for viewing
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
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
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
85 changes: 0 additions & 85 deletions
85
src/bundle/Resources/views/themes/admin/ui/component/dropdown.html.twig
This file was deleted.
Oops, something went wrong.
119 changes: 119 additions & 0 deletions
119
src/bundle/Resources/views/themes/admin/ui/component/dropdown/dropdown.html.twig
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,119 @@ | ||
|
||
{% set choices_flat = choices | ||
| map(choice => choice.choices is defined ? choice.choices : [choice]) | ||
| reduce((carry, choices) => carry|merge(choices), []) | ||
%} | ||
{% set preferred_choices = preferred_choices|default([]) %} | ||
{% set min_search_items = min_search_items|default(5) %} | ||
{% set custom_form = custom_form is defined ? custom_form : true %} | ||
{% set translation_domain = translation_domain|default(false) %} | ||
{% set value = value is defined ? value : null %} | ||
{% set multiple = multiple|default(false) %} | ||
{% set no_items = choices_flat|length == 0 %} | ||
|
||
{% macro get_translated_label(label, translation_domain) %} | ||
{{ translation_domain is same as(false) ? label : label|trans({}, translation_domain) }} | ||
{% endmacro %} | ||
|
||
<div | ||
class="ibexa-dropdown | ||
{{ multiple ? "ibexa-dropdown--multi" : "ibexa-dropdown--single" }} | ||
{{ custom_init|default(false) ? "ibexa-dropdown--custom-init" }} | ||
{{ no_items ? "ibexa-dropdown--no-items" }} | ||
{{ class|default('') }} | ||
" | ||
> | ||
<div class="ibexa-dropdown__source"> | ||
{{ source|default(null)|raw }} | ||
</div> | ||
<div class="ibexa-dropdown__wrapper"> | ||
<ul | ||
class="ibexa-dropdown__selection-info" | ||
data-template="{{ include('@ibexadesign/ui/component/dropdown/dropdown_selected_item.html.twig', { | ||
value: '{{ value }}', | ||
label: '{{ label }}', | ||
})|e('html_attr') }}" | ||
> | ||
{% if no_items %} | ||
<li class="ibexa-dropdown__selected-item ibexa-dropdown__selected-item--predefined ibexa-dropdown__selected-placeholder"> | ||
{{ 'dropdown.placeholder.empty'|trans|desc("No options available") }} | ||
</li> | ||
{% else %} | ||
{% for choice in choices_flat %} | ||
{% if custom_form ? choice.value == value : choice is selectedchoice(value) %} | ||
{% include '@ibexadesign/ui/component/dropdown/dropdown_selected_item.html.twig' with { | ||
value: choice.value, | ||
label: _self.get_translated_label(choice.label, translation_domain), | ||
} %} | ||
{% endif %} | ||
{% endfor %} | ||
|
||
{% if value is empty %} | ||
{% if multiple %} | ||
<li class="ibexa-dropdown__selected-item ibexa-dropdown__selected-item--predefined ibexa-dropdown__selected-placeholder"> | ||
{% if placeholder is defined %} | ||
{{ _self.get_translated_label(placeholder, translation_domain )}} | ||
{% else %} | ||
{{ 'dropdown.placeholder'|trans|desc("Choose an option") }} | ||
{% endif %} | ||
</li> | ||
{% else %} | ||
{% if placeholder is not none %} | ||
{% include '@ibexadesign/ui/component/dropdown/dropdown_selected_item.html.twig' with { | ||
value: '', | ||
label: _self.get_translated_label(placeholder, translation_domain), | ||
} %} | ||
{% else %} | ||
{% set first_choice = choices_flat|first %} | ||
|
||
{% include '@ibexadesign/ui/component/dropdown/dropdown_selected_item.html.twig' with { | ||
value: first_choice.value, | ||
label: _self.get_translated_label(first_choice.label), | ||
} %} | ||
{% endif %} | ||
{% endif %} | ||
{% endif %} | ||
{% endif %} | ||
|
||
<li class="ibexa-dropdown__selected-item ibexa-dropdown__selected-item--predefined ibexa-dropdown__selected-overflow-number" hidden></li> | ||
</ul> | ||
<div class="ibexa-dropdown__items {{ choices_flat|length < min_search_items ? 'ibexa-dropdown__items--search-hidden' }}"> | ||
{%- embed '@ibexadesign/ui/component/input_text.html.twig' with { has_search: true } -%} | ||
{% block content %} | ||
<input | ||
type="text" | ||
placeholder="{{ 'dropdown.search'|trans|desc('Search...') }}" | ||
class="ibexa-dropdown__items-filter ibexa-input ibexa-input--text ibexa-input--small form-control" | ||
/> | ||
{% endblock %} | ||
{%- endembed -%} | ||
<ul | ||
class="ibexa-dropdown__items-list" | ||
data-template="{{ include('@ibexadesign/ui/component/dropdown/dropdown_item.html.twig', { | ||
custom_form: true, | ||
choice: { | ||
value: '{{ value }}', | ||
label: '{{ label }}', | ||
}, | ||
})|e('html_attr') }}" | ||
> | ||
{% if not multiple and placeholder is defined %} | ||
{% set placeholder_choice = { | ||
value: '', | ||
label: _self.get_translated_label(placeholder, translation_domain), | ||
} %} | ||
{% include '@ibexadesign/ui/component/dropdown/dropdown_item.html.twig' with { choice: placeholder_choice, custom_form: true } %} | ||
{% endif %} | ||
{% for choice in preferred_choices %} | ||
{% include '@ibexadesign/ui/component/dropdown/dropdown_item.html.twig' with { choice, preferred_choice: true, custom_form } %} | ||
{% endfor %} | ||
{% if preferred_choices|length > 0 %} | ||
<hr class="ibexa-dropdown__separator" /> | ||
{% endif %} | ||
{% for choice in choices %} | ||
{% include '@ibexadesign/ui/component/dropdown/dropdown_item.html.twig' with { choice, custom_form } %} | ||
{% endfor %} | ||
</ul> | ||
</div> | ||
</div> | ||
</div> |
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
File renamed without changes.
Oops, something went wrong.