КОНТРОЛЫ/deadline_select.md
Исходный код
Twig код
{% set choosed_item_text = "" %}
{% set delimeter = " " %}
{% set deadline_within = "" %}
{% set deadline_value = "0" %} {# Default #}
{% if ( trigger_params.days_later and trigger_params.days_later != "0" and trigger_params.days_later != "1" and trigger_params.days_later != "3" and trigger_params.week_later != "true"and trigger_params.week_later != true and trigger_params.today != "true" and trigger_params.today != true ) or trigger_params.hours_later or trigger_params.minutes_later %}
{% set days_later = "" %}
{% set hours_later = "" %}
{% set minutes_later = "" %}
{% set deadline_value = 'custom' %}
{% set choosed_item_text = lang.triggers.during.task_in ~ ' ' %}
{% if trigger_params.days_later and trigger_params.days_later != 0 %}
{% set deadline_within = trigger_params.days_later ~ 'd' %}
{% if (trigger_params.hours_later and trigger_params.hours_later != 0) and (trigger_params.min_later and trigger_params.min_later != 0) %}
{% set delimeter = ", " %}
{% elseif (trigger_params.hours_later and trigger_params.hours_later != 0) or (trigger_params.min_later and trigger_params.min_later != 0) %}
{% set deadline_within = deadline_within ~ '_' %}
{% set delimeter = ' ' ~ lang.triggers.during.task_and ~ ' ' %}
{% endif %}
{% set days_later = trigger_params.days_later %}
{% set choosed_item_text = choosed_item_text ~ trigger_params.days_later ~ ' ' ~ lang.triggers.during.task_days|numeral(trigger_params.days_later) ~ delimeter %}
{% endif %}
{% if trigger_params.hours_later and trigger_params.hours_later != 0 %}
{% set deadline_within = deadline_within ~ trigger_params.hours_later ~ 'h' %}
{% if trigger_params.min_later and trigger_params.min_later != 0 %}
{% set deadline_within = deadline_within ~ '_' %}
{% set delimeter = ' ' ~ lang.triggers.during.task_and ~ ' ' %}
{% else %}
{% set delimeter = "" %}
{% endif %}
{% set hours_later = trigger_params.hours_later %}
{% set choosed_item_text = choosed_item_text ~ trigger_params.hours_later ~ ' ' ~ lang.triggers.during.task_hours|numeral(trigger_params.hours_later) ~ delimeter %}
{% endif %}
{% if trigger_params.min_later and trigger_params.min_later != 0 %}
{% set deadline_within = trigger_params.min_later ~ 'm' %}
{% set minutes_later = trigger_params.min_later %}
{% set choosed_item_text = choosed_item_text ~ trigger_params.min_later ~ ' ' ~ lang.triggers.during.task_minutes|numeral(trigger_params.min_later) %}
{% endif %}
{% else %}
{% if trigger_params.week_later %}
{% set deadline_value = 'week' %}
{% set choosed_item = "week" %}
{% elseif trigger_params.today %}
{% set deadline_value = 'today' %}
{% set choosed_item = "today" %}
{% else %}
{% if trigger_params.days_later %}
{% set deadline_value = trigger_params.days_later %}
{% else %}
{% set deadline_value = 0 %}
{% endif %}
{% set choosed_item = trigger_params.days_later %}
{% endif %}
{% for item in items if item.value == choosed_item %}
{% set choosed_item_text = item.task_option %}
{% endfor %}
{% endif %}
{% if not choosed_item_text or choosed_item_text == " " %}
{% for item in items %}
{% if loop.first %}
{% set choosed_item_text = item.option %}
{% endif %}
{% endfor %}
{% endif %}
{% set max_lenght_hours = "2" %}
{% set max_lenght_minutes = "2" %}
{% if close_delay %}
{% set max_lenght_hours = "5" %}
{% set max_lenght_minutes = "2" %}
{% set choosed_item = close_delay %}
{% set choosed_item_text = "" %}
{% for item in items %}
{% if choosed_item == item.value %}
{% set choosed_item_text = item.option %}
{% endif %}
{% endfor %}
{% if choosed_item_text == "" %}
{% set hours_later = (choosed_item / 3600)|round(0, 'floor') %}
{% set minutes_later = ((choosed_item / 60) % 60)|round(0, 'floor') %}
{% if hours_later == 0 %}
{% set hours_later = '' %}
{% endif %}
{% if minutes_later == 0 %}
{% set minutes_later = '' %}
{% endif %}
{# сохраняем в час,часа,часов #}
{% if hours_later > 0 %}
{% if hours_later % 10 == 1 and hours_later % 100 != 11 %}
{% set hourse_format = lang.triggers.during.task_hours|numeral(1)|lower %}
{% elseif (hours_later % 10 >= 2 and hours_later % 10 <= 4) %}
{% set hourse_format = lang.triggers.during.task_hours|numeral(3)|lower %}
{% else %}
{% set hourse_format = lang.triggers.during.task_hours|numeral(15)|lower %}
{% endif %}
{% set choosed_item_text = hours_later ~ ' ' ~ hourse_format %}
{% endif %}
{# сохраняем в минут,минута,минуты #}
{% if minutes_later > 0 %}
{% if minutes_later % 10 == 1 and minutes_later != 11 %}
{% set minutes_format = lang.triggers.during.task_minutes|numeral(1)|lower %}
{% elseif minutes_later % 10 >= 2 and minutes_later % 10 <= 4 %}
{% set minutes_format = lang.triggers.during.task_minutes|numeral(3)|lower %}
{% else %}
{% set minutes_format = lang.triggers.during.task_minutes|numeral(15)|lower %}
{% endif %}
{% if hours_later > 0 and minutes_later > 0 %}
{% set choosed_item_text = hours_later ~ ' ' ~ hourse_format ~ ' ' ~ 'and'|i18n|lower ~ ' ' ~ minutes_later ~ ' ' ~ minutes_format %}
{% else %}
{% set choosed_item_text = minutes_later ~ ' ' ~ minutes_format %}
{% endif %}
{% endif %}
{% endif %}
{% endif %}
<div class="control--deadline_select deadline_select" id="dl_select_{{trigger_params.id}}">
<div class="deadline_select__caption">
<span class="deadline_select__caption-calendar icon icon-inline icon-calendar-2"></span>
<span class="tasks-date__caption__text">{{ lang.triggers.with_deadline }}: </span><span class="js-deadline-additional-caption">{{choosed_item_text|capitalize}}</span>
<b class="tasks-date__caption__icon"></b>
</div>
<div class="deadline_select__list">
{% for item in items %}
<div class="deadline_select__list__item js-deadline_select-item {% if choosed_item == item.value %}selected{% endif %}" data-deadline="{{item.value}}">{{item.option}}</div>
{% endfor %}
<div class="deadline_select__list__item deadline_select__list__item-custom clearfix" data-deadline="custom">
<span class="deadline_select__header">{{ lang.triggers.during.text }}:</span>
<div class="deadline_select__input">
{% include "interface/controls/input.twig" with {
class_name: "js-deadline-input js-control-allow-numeric",
name: "deadline-days",
max_length: "3",
value: days_later
} %}
<span class="deadline_select__input_descr">{{ lang.triggers.during.days }}</span>
</div>
<div class="deadline_select__input">
{% include "interface/controls/input.twig" with {
class_name: "js-deadline-input js-deadline-input-hours js-control-allow-numeric",
name: "deadline-hours",
max_length: max_lenght_hours,
value: hours_later,
} %}
<span class="deadline_select__input_descr">{{ lang.triggers.during.hours }}</span>
</div>
<div class="deadline_select__input">
{% include "interface/controls/input.twig" with {
class_name: "js-deadline-input js-deadline-input-minutes js-control-allow-numeric",
name: "deadline-minutes",
max_length: max_lenght_minutes,
value: minutes_later,
} %}
<span class="deadline_select__input_descr">{{ lang.triggers.during.minutes }}</span>
</div>
{% include "interface/controls/button.twig" with {
text: lang.page.buttons.ok,
class_name: 'js-deadline_select-custom_item deadline_select__btn'
} %}
</div>
</div>
{% include "interface/controls/input.twig" with {
name: "within-deadline",
type: "hidden",
additional_data: "data-deadline-within=" ~ deadline_within,
value: close_delay|default(deadline_value)
} %}
</div>
Ссылка на вики репозиторий
- Страницы
- add_button
- budget
- button
- cancel_button
- chained_list
- checkbox
- checkboxes_dropdown
- checkboxes_dropdown_single
- checkboxes_string
- color_picker
- contenteditable
- date_field
- date_filter
- date_time_field
- deadline_select
- delete_button
- drive_field
- feed_note_main_buttons
- file
- input
- legal_entity
- line_toggler
- multiselect
- payer
- phone
- pipeline_toggler
- radio
- responsive_toggler
- select
- select_with_subtext
- smart_address
- status_chat
- suggest
- supplier
- switcher
- tags
- textarea
- textarea_code
- time
- time_field
- toggler
- updater
- users
- wysiwyg
Ссылка на вики репозиторий
- add_button
- budget
- button
- cancel_button
- chained_list
- checkbox
- checkboxes_dropdown
- checkboxes_dropdown_single
- checkboxes_string
- color_picker
- contenteditable
- date_field
- date_filter
- date_time_field
- deadline_select
- delete_button
- drive_field
- feed_note_main_buttons
- file
- input
- legal_entity
- line_toggler
- multiselect
- payer
- phone
- pipeline_toggler
- radio
- responsive_toggler
- select
- select_with_subtext
- smart_address
- status_chat
- suggest
- supplier
- switcher
- tags
- textarea
- textarea_code
- time
- time_field
- toggler
- updater
- users
- wysiwyg