From ee803a94e2be5fb1d89432395c0098927d5816d8 Mon Sep 17 00:00:00 2001 From: SBD Date: Mon, 13 Jan 2025 17:32:19 +0300 Subject: [PATCH 1/2] 0.0.14 form mover --- templates/v2/blocks/b_make_mover_order.html | 4 +-- templates/v2/forms/f_make_mover_order.html | 37 ++++++++++++--------- templates/v2/forms/f_make_poster_order.html | 2 +- 3 files changed, 24 insertions(+), 19 deletions(-) diff --git a/templates/v2/blocks/b_make_mover_order.html b/templates/v2/blocks/b_make_mover_order.html index 3fae2c7..37678d2 100644 --- a/templates/v2/blocks/b_make_mover_order.html +++ b/templates/v2/blocks/b_make_mover_order.html @@ -11,6 +11,6 @@
-
{% trans "Заполните форму, чтобы отправить посылку" %}
- {% include 'v2/forms/f_make_poster_order.html' %} +
{% trans "Заполните форму, чтобы перевезти посылку" %}
+ {% include 'v2/forms/f_make_mover_order.html' %}
\ No newline at end of file diff --git a/templates/v2/forms/f_make_mover_order.html b/templates/v2/forms/f_make_mover_order.html index e71bcf6..0171c98 100644 --- a/templates/v2/forms/f_make_mover_order.html +++ b/templates/v2/forms/f_make_mover_order.html @@ -2,41 +2,46 @@ {% load i18n %}
- {% trans "Укажите город" as placeholder_for_city %} +
+
+ {% trans "Обязательно учитывайте Правила и особенности перевозки выбранным Вами видом транспорта" as attention_type_transport %} + + {% include 'v2/widgets/w_radio_inputs.html' with name='type_transport' list=form.fields.type_transport.choices initial=form.initial.type_transport %} + {% include 'v2/widgets/w_pay_attention.html' with text=attention_type_transport %} + {% if form.errors.type_transport %}
{{ form.errors.type_transport.0 }}
{% endif %} +
+
+ {% trans "Укажите город" as placeholder_for_city %}
- + {% 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 %}
{{ form.errors.from_city.0 }}
{% endif %}
- + {% 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 %}
{{ form.errors.to_city.0 }}
{% endif %}
-
-
- - {% include 'v2/widgets/w_radio_inputs.html' with name='cargo_type' list=form.fields.cargo_type.choices initial=form.initial.cargo_type %} - {% if form.errors.cargo_type %}
{{ form.errors.cargo_type.0 }}
{% endif %} -
-
{% include 'v2/widgets/w_daterangepicker.html' with name='arrival_DT' initial=form.initial.arrival_DT %} {% if form.errors.arrival_DT %}
{{ form.errors.arrival_DT.0 }}
{% endif %}
+
+ + {% include 'v2/widgets/w_daterangepicker.html' with name='departure_DT' initial=form.initial.departure_DT %} + {% if form.errors.departure_DT %}
{{ form.errors.departure_DT.0 }}
{% endif %} +
-
- {% trans "Обязательно учитывайте Правила и особенности перевозки выбранным Вами видом транспорта" as attention_type_transport %} - - {% include 'v2/widgets/w_radio_inputs.html' with name='type_transport' list=form.fields.type_transport.choices initial=form.initial.type_transport %} - {% include 'v2/widgets/w_pay_attention.html' with text=attention_type_transport %} - {% if form.errors.type_transport %}
{{ form.errors.type_transport.0 }}
{% endif %} +
+ + {% include 'v2/widgets/w_radio_inputs.html' with name='cargo_type' list=form.fields.cargo_type.choices initial=form.initial.cargo_type %} + {% if form.errors.cargo_type %}
{{ form.errors.cargo_type.0 }}
{% endif %}
diff --git a/templates/v2/forms/f_make_poster_order.html b/templates/v2/forms/f_make_poster_order.html index f6199b9..557f4e3 100644 --- a/templates/v2/forms/f_make_poster_order.html +++ b/templates/v2/forms/f_make_poster_order.html @@ -18,7 +18,7 @@
- + {% include 'v2/widgets/w_radio_inputs.html' with name='cargo_type' list=form.fields.cargo_type.choices initial=form.initial.cargo_type %} {% if form.errors.cargo_type %}
{{ form.errors.cargo_type.0 }}
{% endif %}
From 6947d1c9588c4acf15da2e20dec36fdde4a6bae4 Mon Sep 17 00:00:00 2001 From: SBD Date: Mon, 13 Jan 2025 19:43:02 +0300 Subject: [PATCH 2/2] 0.0.15 form mover --- static/v2/js/forms/f_make_mover_order.js | 50 +++++++++++++++++++++ templates/pages/profile/p_user_profile.html | 1 + templates/v2/forms/f_make_mover_order.html | 2 +- 3 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 static/v2/js/forms/f_make_mover_order.js diff --git a/static/v2/js/forms/f_make_mover_order.js b/static/v2/js/forms/f_make_mover_order.js new file mode 100644 index 0000000..584998c --- /dev/null +++ b/static/v2/js/forms/f_make_mover_order.js @@ -0,0 +1,50 @@ +function makeMoverOrder(form) { + event.preventDefault() + + let formData = getFormData(form); + formData.append('owner_type', 'mover'); + + let request = new api({ + url: '/routes/create_or_change_route/', + data: formData, + data_type: 'formData', + success: function (res) { + if (!res) return; + let created_route_id = res.route_id; + if (!created_route_id) return; + + let profile_root = document.querySelector(".info_profile") + if (!profile_root) return; + profile_root.innerHTML = res.html + + let created_route = document.querySelector(`[data-number-of-route="${created_route_id}"]`); + created_route.scrollIntoView({ + behavior:"smooth", + block:'start', + inline:'start' + }); + + let new_url = window.location.pathname + new_url.replace('/create_route_for_customer', '/my_routes'); + new_url.replace('/create_route_for_mover', '/my_routes'); + + window.location.pathname.replace(new_url, '') + + }, error: function (res) { + if (!res.responseJSON) return; + + let $parent = form.closest('.b_make_poster_order') + let $title = $parent.querySelector(".make_poster_order_title") + let $form = $parent.querySelector(".f_make_poster_order") + $form.remove() + + $('body')[0].scrollIntoView({behavior: 'smooth', top: 0}); + + $(res.responseJSON.html).insertAfter($($title)) + + daterangepickerInit($('.w_daterangepicker'), daterangepickerInit) + } + }) + + request.ajaxRequest() +} \ No newline at end of file diff --git a/templates/pages/profile/p_user_profile.html b/templates/pages/profile/p_user_profile.html index 698e878..eaa5701 100644 --- a/templates/pages/profile/p_user_profile.html +++ b/templates/pages/profile/p_user_profile.html @@ -35,6 +35,7 @@ + {% include "connect_ws_js.html" %} diff --git a/templates/v2/forms/f_make_mover_order.html b/templates/v2/forms/f_make_mover_order.html index 0171c98..bd16896 100644 --- a/templates/v2/forms/f_make_mover_order.html +++ b/templates/v2/forms/f_make_mover_order.html @@ -70,5 +70,5 @@
- +
\ No newline at end of file