{# dropdown_target should be:
1 or 'left' to select translation in left column of two-column view (without changing right column)
2 or 'right' to select translation in right column of two-column view (without changing left column)
'index' to link to index page for translations (not displaying a passage)
null or undefined to link to translations of the current passage in a one-column view
'add' to link from a one-column view to a two-column view (with the current translation in the left column and the new translation in the right column)
'multicolumn' to change one column of an arbitrary multicolumn view (the column_num variable will indicate which column)
#}
{% if dropdown_target is not defined %}
{% set dropdown_target = null %}
{% elseif dropdown_target|lower == 'left' %}
{% set dropdown_target = 1 %}
{% elseif dropdown_target|lower == 'right' %}
{% set dropdown_target = 2 %}
{% elseif dropdown_target|lower == '3col' %}
{% set dropdown_target = 3 %}
{% endif %}
{% set nTransUrlPos = 3 %}
{% if current_locale_code != 'en' %}
{% set nTransUrlPos = 4 %}
{% endif %}
{% set three_column = (compare_to2 is defined and compare_to2 is not null) %}
{% set two_column = (not three_column and (compare_to is defined and compare_to is not null)) %}
{% set multicolumn = (dropdown_target == 'multicolumn') %}
<!-- 5/15: dt: {{ dropdown_target }} // 2c:{{ two_column }}, 3c: {{ three_column }}, mc:{{ multicolumn }} -->
{% set currently_selected = (dropdown_target == 3) ? compare_to2 : ((dropdown_target == 2) ? compare_to : translation) %}
{% set sLabelName = "" %}
{% if is_swedenborg is defined and is_swedenborg %}
{% set sLabelName = (dropdown_target == 3) ? translation_shortname3 : ((dropdown_target == 2) ? translation_shortname2 : translation_shortname) %}
{% else %}
{% set sLabelName = translation.getLanguage().getPrimaryName() %}
{% endif %}
{% if dropdown_target == 'add' %}
<option selected value="#">{{ app.session.get('ui_str')["exposition.translate.comparetranslations"] }}</option>
{% elseif two_column %}
{# Dropdown menu item to remove this column, showing only the other one #}
{% set force_translation = (dropdown_target == 1) ? compare_to : translation %}
{% set url_1col = path('exposition_translation_division_passage', {'translationUrl': force_translation.url, 'divisionUrls': passage.getDivision().getUrl(), 'passageNumber': passage.ordering}) %}
<script>
aRemoveLink[{{ dropdown_target }}] = "{{ url_1col }}";
</script>
{% elseif three_column %}
{# Dropdown menu item to remove this column, showing the other two #}
{% set currentPath = path(app.request.attributes.get('_route'), app.request.attributes.get('_route_params')) %}
{% set queryParams = app.request.query.all %}
{% set aPath = currentPath |split('/') %}
{% set aPath2 = queryParams['compareTo'] |split(';;') %}
{% set url_3col = '' %}
{% if dropdown_target == 1 %}
{% for item in aPath %}
{% if url_3col == '' %}
{% set url_3col = url_3col~item %}
{% else %}
{% if loop.index0 == nTransUrlPos %}
{% set url_3col = url_3col~'/'~compare_to.url %}
{% else %}
{% set url_3col = url_3col~'/'~item %}
{% endif %}
{% endif %}
{% endfor %}
{% set url_3col = url_3col|replace({'/work/': "/translation/"}) %}
{% set url_3col = '/'~url_3col ~ '?compareTo=' ~ aPath2[1]%}
{% elseif dropdown_target == 2 %}
{% set url_3col = currentPath ~ '?compareTo=' ~ aPath2[1] %}
{% else %}
{% set url_3col = currentPath ~ '?compareTo=' ~ aPath2[0] %}
{% endif %}
<script>
aRemoveLink[{{ dropdown_target }}] = "{{ url_3col }}";
</script>
{% endif %}
{% set nColNum = 0 %}
{% if column_num is defined %}
{% set nColNum = column_num %}
{% endif %}
{% set nTarget = 0 %}
{% if dropdown_target is defined and dropdown_target is not null %}
{% set nTarget = dropdown_target %}
{% endif %}
{% set sTranslationUrl = translation.url %}
{% set sUrlEnd = '?col='~nColNum~'&target='~nTarget %}
{% set sUrlEnd = sUrlEnd~'&divurl='~passage.getDivision().getUrl() %}
{% if(compare_to is defined and compare_to is not null) %}
{% set sUrlEnd = sUrlEnd~'&c1='~compare_to.getUrl() %}
{% endif %}
{% if(compare_to2 is defined and compare_to2 is not null) %}
{% set sUrlEnd = sUrlEnd~'&c2='~compare_to2.getUrl() %}
{% endif %}
{% if(multicolumn_route_params is defined and multicolumn_route_params is not null) %}
{% set sParam = multicolumn_route_params|join(';;') %}
{% set sUrlEnd = sUrlEnd~'&multi='~sParam~'&col='~nColNum %}
{% endif %}
{% if is_swedenborg %}
{% set sUrlEnd = sUrlEnd~'&sw=1' %}
{% else %}
{% set sUrlEnd = sUrlEnd~'&sw=0' %}
{% endif %}
{% if bInFrame %}
{% set sUrlEnd = sUrlEnd~'&inframe=1' %}
{% endif %}
{% set sPathStr = "select_work_translation" %}
{% set sPassageNum = passage.swedenborgSection %}
{% if sPassageNum is empty %}
{% set sPassageNum = '0' %}
{% endif %}
{% set sUrl = path(sPathStr, {'workID': work.id, 'translationUrl': sTranslationUrl, 'passageNumber': sPassageNum, 'passageOrder': passage.ordering}) ~ sUrlEnd %}
<button type="button" class="btn btn-link" style="font-weight:400;" onclick='openNav("{{ app.session.get('ui_str')["popup.worktranslationheader"] }}","{{ sUrl }}")'>
{{ sLabelName }} <i class="fas fa-angle-down"></i>
</button>