0.0.34 forms

This commit is contained in:
SBD
2025-01-15 20:51:50 +03:00
parent 575ee074b1
commit 8f3bba620c
10 changed files with 76 additions and 35 deletions

View File

@@ -12,6 +12,6 @@ register = template.Library()
@register.filter
@stringfilter
def get_cur_DT_by_tz(timezone, DT=None):
return get_cur_DT_by_timezone(timezone, DT)
return get_cur_DT_by_timezone(timezone, DT).strftime('%Y-%m-%d %H:%M:%S')

View File

@@ -26,6 +26,7 @@
--route-btn-border-radius: 10px;
--route-btn-padding: 7.5px 0;
--route-btn-width: 171px;
--route-btn-height: 100%;
--route-btn-bg: #FFFFFF;
--route-btn-hover-bg: #FF613A;
--route-btn-hover-text-color: #FFFFFF;
@@ -213,36 +214,53 @@
align-items: center;
gap: 20px;
}
.route_btn{
cursor: pointer;
&.solid{
--route-btn-width: 222px;
--route-btn-padding: 12px 0;
--route-btn-bg: #FF613A;
--route-btn-title-color: #ffffff;
}
width: var(--route-btn-width);
border: var(--route-btn-border);
border-radius: var(--route-btn-border-radius);
padding: var(--route-btn-padding);
background: var(--route-btn-bg);
height: 100%;
text-align: center;
transition: 200ms all;
}
.route_btn{
cursor: pointer;
&.solid{
--route-btn-width: 222px;
--route-btn-padding: 12px 0;
--route-btn-bg: #FF613A;
--route-btn-title-color: #ffffff;
}
&.inactive{
cursor: default;
--route-btn-title-color: #27242499;
--route-btn-border: 1.5px solid #FF613A99;
}
width: var(--route-btn-width);
border: var(--route-btn-border);
border-radius: var(--route-btn-border-radius);
padding: var(--route-btn-padding);
background: var(--route-btn-bg);
height: var(--route-btn-height);
text-align: center;
transition: 200ms all;
&:has(img){
display: flex;
gap: 5px;
align-items: center;
justify-content: center;
text-align: unset;
}
&:not(&.inactive){
&:hover{
background: var(--route-btn-hover-bg);
.route_btn_title{color: var(--route-btn-hover-text-color);}
.route_btn_data{color: var(--route-btn-hover-text-color);}
box-shadow: 0 4px 4px rgba(189, 104, 104, 0.25);
}
.route_btn_title{
color: var(--route-btn-title-color);
font-size: var(--medium-font-size);
}
.route_btn_data{
font-size: var(--small-font-size);
color: var(--route-btn-text-data-color);
}
.route_btn_title{
color: var(--route-btn-title-color);
font-size: var(--medium-font-size);
&.big{
font-size: var(--big-font-size);
}
}
.route_btn_data{
font-size: var(--small-font-size);
color: var(--route-btn-text-data-color);
}
}
}

View File

@@ -0,0 +1,3 @@
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M2.965 6.0925C4.045 8.215 5.785 9.9475 7.9075 11.035L9.5575 9.385C9.76 9.1825 10.06 9.115 10.3225 9.205C11.1625 9.4825 12.07 9.6325 13 9.6325C13.4125 9.6325 13.75 9.97 13.75 10.3825V13C13.75 13.4125 13.4125 13.75 13 13.75C5.9575 13.75 0.25 8.0425 0.25 1C0.25 0.5875 0.5875 0.25 1 0.25H3.625C4.0375 0.25 4.375 0.5875 4.375 1C4.375 1.9375 4.525 2.8375 4.8025 3.6775C4.885 3.94 4.825 4.2325 4.615 4.4425L2.965 6.0925Z" fill="#FF613A"/>
</svg>

After

Width:  |  Height:  |  Size: 545 B

View File

@@ -61,15 +61,18 @@ function updateCargoTypeInForm(el, type_transport='') {
let cargo_types = res.cargo_types
if (!cargo_types) return;
resetWRadioInputs('cargo_type');
let $widget = getWRadioInputsWidget('cargo_type');
let $selected_value = $widget.querySelector(".radio.checked")
resetWRadioInputs('cargo_type');
for (let cargo_type of cargo_types) {
let obj = {
name: cargo_type[0],
title: cargo_type[1],
}
let selected = false;
if ($selected_value && $selected_value.closest(".cw_w_radio_inputs_radio_input").dataset.name === obj.name) selected = true;
let html = generateRadioInput(obj)
let html = generateRadioInput(obj, selected)
if ($widget.lastElementChild){
$(html).insertAfter($($widget.lastElementChild))

View File

@@ -35,15 +35,19 @@ function datarangepickerinitAll(){
})
}
function daterangepickerInit(el, callback) {
function daterangepickerInit(el, callback, date) {
let $datarangepicker = el.querySelector('input')
let min_date = moment()
if (date){
min_date = moment(date);
}
$($datarangepicker).daterangepicker({
"autoapply": true,
"linkedCalendars": false,
"singleDatePicker": true,
"timePicker": false,
"timePicker24Hour": false,
"minDate": moment(),
"minDate": moment(date),
"locale": setLocalSets(),
}, function (start, end, label) {
let $parent = el.closest('.w_daterangepicker')

View File

@@ -19,10 +19,10 @@ function chooseRadioInput(el, callback){
if (callback) callback(el, el_name)
}
function generateRadioInput(data){
function generateRadioInput(data, selected){
let html = `
<div class="cw_w_radio_inputs_radio_input" data-name="${data.name}">
<div class="radio" onclick="chooseRadioInput(this, ${data.callback})"></div>
<div class="radio${selected? ' checked' : ''}" onclick="chooseRadioInput(this, ${data.callback})"></div>
<div class="radio_label" onclick="chooseRadioInput(this, ${data.callback})">${data.title}</div>
</div>
`

View File

@@ -87,6 +87,7 @@ function selectCountry(el, callback) {
id: el.dataset.id,
country_code: el.dataset.country_code,
flag: el.dataset.flag,
now: el.dataset.now
}
$flag.src = country_data.flag;
@@ -96,10 +97,21 @@ function selectCountry(el, callback) {
$input.dataset.name = country_data.full_name;
$input.dataset.id = country_data.id;
connectCountryWDateRangePicker(el, country_data)
closeSelectCountry(el);
resetFieldError(el);
}
function connectCountryWDateRangePicker (el, data) {
let $parent = el.closest(".field_container")
if (!$parent || !data || typeof daterangepickerInit === 'undefined') return;
let datepicker_name = $parent.dataset.datepicker;
let $datepicker = $(`.field_container[data-name="${datepicker_name}"]`)[0]
daterangepickerInit($datepicker, false, data.now)
}
function resetCountrySelect(el, callback) {
let $parent = el.closest('.w_select_country');
if (!$parent) return;

View File

@@ -2,7 +2,7 @@
{% load i18n %}
{% load reference_data_tags %}
<div class="cw_w_select_widget_for_select" data-id="{{ id }}" data-name="{{ name }}/{{ country__name }}" data-country_code="{{ country__short_code }}" data-flag="{{ MEDIA_URL }}{{ country__flag }}" onclick="selectCountry(this)">
<div class="cw_w_select_widget_for_select" data-id="{{ id }}" data-name="{{ name }}/{{ country__name }}" data-country_code="{{ country__short_code }}" data-flag="{{ MEDIA_URL }}{{ country__flag }}" onclick="selectCountry(this)" data-now="{{ timezone|get_cur_DT_by_tz }}">
<div class="cw_country_inf_part">
<img src="{{ MEDIA_URL }}{{ country__flag }}" alt="">
<div class="cw_country_code">{{ country__short_code }}</div>

View File

@@ -14,12 +14,12 @@
{% trans "Укажите город" as placeholder_for_city %}
<div class="form_line _50_grid">
<div class="field_container" data-type="location" data-name="from_city">
<div class="field_container" data-type="location" data-name="from_city" data-datepicker="departure_DT">
<label for="id_from_city"><div class="required_field_icon">*</div> {% trans "Пункт отправления" %}</label>
{% include 'v2/widgets/w_select_country.html' with name='from_city' placeholder=placeholder_for_city initial=form.initial.from_city %}
{% if form.errors.from_city %}<div class="error_container">{{ form.errors.from_city.0 }}</div>{% endif %}
</div>
<div class="field_container" data-type="location" data-name="to_city">
<div class="field_container" data-type="location" data-name="to_city" data-datepicker="arrival_DT">
<label for="id_from_city"><div class="required_field_icon">*</div> {% trans "Пункт прибытия" %}</label>
{% include 'v2/widgets/w_select_country.html' with name='to_city' placeholder=placeholder_for_city initial=form.initial.to_city %}
{% if form.errors.to_city %}<div class="error_container">{{ form.errors.to_city.0 }}</div>{% endif %}

View File

@@ -12,8 +12,9 @@
<div class="card_owner_type">Нужен перевозчик</div>
<div class="card_cargo_type">Тип посылки: <div class="orange">Документы</div></div>
</div>
<div class="">
<div class="route_btn inactive" style="--route-btn-width: 206px;--route-btn-height: min-content;">
<img src="{% static "v2/icons/widgets/w_route_card/phone.svg" %}" alt="">
<div class="title big">+ 6 (666) 666-66-66</div>
</div>
</div>
<div class="route_card_text_container">