TRI-293: add custom and mover handler + mover page poster

This commit is contained in:
2024-12-21 22:24:15 +03:00
parent 6044b302bb
commit b867ab7d02
15 changed files with 607 additions and 102 deletions

View File

@@ -111,7 +111,7 @@ def profile_page_View(request, page_name, id=None):
page_html = get_profile_page_content_html(request, page_name, id)
if not page_html:
raise Http404
if page_name == 'create_route_for_customer':
if page_name == 'create_route_for_customer' or page_name == 'create_route_for_mover':
tag = 'tb_base2.html'
else:
tag = 'tb_base.html'

View File

@@ -379,7 +379,7 @@ def create_or_change_route_ajax(request, route_id=None):
form.initial = form.cleaned_data
Dict.update({'form': form})
html = render_to_string('blocks/profile/b_new_route.html', Dict, request=request)
html = render_to_string('blocks/profile/b_create_form_poster.html', Dict, request=request)
return JsonResponse({'html': html}, status=400)
obj = form.save(commit=False)
@@ -417,7 +417,7 @@ def create_or_change_route_ajax(request, route_id=None):
if 'errors' in routes_Dict:
form.errors.update(routes_Dict['errors'])
Dict.update({'form': form})
html = render_to_string('blocks/profile/b_new_route.html', Dict, request=request)
html = render_to_string('blocks/profile/b_create_form_poster.html', Dict, request=request)
return JsonResponse({'html': html}, status=400)
html = render_to_string('blocks/profile/b_my_routes.html', routes_Dict, request=request)
@@ -440,5 +440,5 @@ def create_or_change_route_ajax(request, route_id=None):
}
# Dict = {'form': errors_Dict}
Dict.update({'form': errors_Dict})
html = render_to_string('blocks/profile/b_new_route.html', Dict, request=request)
html = render_to_string('blocks/profile/b_create_form_poster.html', Dict, request=request)
return JsonResponse({'html': html}, status=400)

View File

@@ -0,0 +1 @@
:root{--brand-primary: #FF613A;--brand-white: #fff;--brand-black: #000;--brand-black2: #272424;--brand-grey: #F1F1F1;--brand-grey2: #E6E6E6;--brand-grey3: #7A7979;--brand-orange: #FF613A;--box-shadow-primary: -1px 4px 10px 0 rgba(198,199,203,0.2),0 -1px 10px 0 rgba(198,199,203,0.2);--base-border-radius: 10px;--base-border: 2.5px solid #E6E6E6;--base-input-height: 60px;text-align:center;color:var(--brand-black2)}html,body{max-width:100vw;max-height:initial;height:initial;overflow-x:hidden}label{display:inline-block}label[required]:before{content:"*";color:var(--brand-primary)}input,textarea{outline:none;border:var(--base-border);border-radius:var(--base-border-radius);height:var(--base-input-height);width:100%;font-size:16px;line-height:22px;cursor:pointer;padding:10px 40px 10px 7px;box-sizing:border-box;max-width:100%}input.date,textarea.date{background:white url(/static/img/svg/Calendar.svg) right 2% bottom 45% no-repeat}input.locate,textarea.locate{background:white url(/static/img/svg/MapPinLine.svg) right 2% bottom 45% no-repeat}input.loading,textarea.loading{background:white url(/static/img/svg/loader.svg) no-repeat calc(100% - 15px) center}input.is-items,textarea.is-items{background:url(/static/img/png/icon-arrow.svg) calc(100% - 15px) center no-repeat white}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
.poster{text-align:left;box-sizing:border-box;padding-top:31px}@media (max-width: 1319.98px){.poster{max-width:65%}}@media (max-width: 991.98px){.poster{max-width:55%}}@media (max-width: 767.98px){.poster{max-width:100%}}@media (max-width: 575.98px){.poster{padding-top:44px}}.poster__title{max-width:95%;margin:0 auto 5px;font-size:44px;font-weight:700;line-height:52px;text-align:center}@media (min-width: 1320px){.poster__title{max-width:100%;margin-bottom:21px}}@media (max-width: 1319.98px){.poster__title{font-size:32px;line-height:38.73px;margin-bottom:0}}@media (max-width: 575.98px){.poster__title{max-width:100%}}.poster__row{display:flex;padding:40px 0;border-bottom:1px solid #E6E6E6;gap:40px}@media (min-width: 1320px){.poster__row{padding:39px 0}}@media (max-width: 1319.98px){.poster__row{display:block}}.poster__row--from-to{flex-wrap:wrap}@media (max-width: 991.98px){.poster__row--from-to{padding-top:14px}}@media (max-width: 767.98px){.poster__row--from-to{padding-top:30px}}@media (max-width: 575.98px){.poster__row--from-to{padding-top:40px}}.poster__row--from-to label{padding-left:9px}@media (max-width: 1319.98px){.poster__row--from-to label{padding-left:0}}@media (max-width: 991.98px){.poster__row--from-to label{padding-left:11px}}@media (max-width: 575.98px){.poster__row--cargo{padding-bottom:29px}}@media (max-width: 1319.98px){.poster__row--date{padding-bottom:20px}}.poster__row--date label{padding-left:9px}@media (max-width: 1319.98px){.poster__row--date label{margin-bottom:20px}}@media (max-width: 575.98px){.poster__row--date label{padding-left:0}}@media (max-width: 1319.98px){.poster__row--transport{padding-bottom:50px}}@media (max-width: 991.98px){.poster__row--transport{padding-bottom:39px}}@media (max-width: 575.98px){.poster__row--transport{padding-top:42px}}.poster__row--transport label{margin-bottom:20px}@media (max-width: 575.98px){.poster__row--transport label{margin-bottom:19px}}@media (max-width: 1319.98px){.poster__row--phone{padding-top:29px}}@media (max-width: 991.98px){.poster__row--phone{padding-top:38px}}@media (max-width: 575.98px){.poster__row--phone{padding-top:40px;padding-bottom:39px}}.poster__row--phone label{padding-left:9px;margin-bottom:11px}@media (max-width: 1319.98px){.poster__row--phone label{padding-left:0;margin-bottom:20px}}.poster__row--phone input{margin-bottom:21px}@media (max-width: 991.98px){.poster__row--description{padding-top:30px}}@media (max-width: 575.98px){.poster__row--description{padding-top:39px}}.poster__row--description label{padding-left:9px;margin-bottom:10px}@media (max-width: 1319.98px){.poster__row--description label{padding-left:0;margin-bottom:20px}}.poster__row--description textarea{min-height:128px;padding-top:18px;margin-bottom:3px}@media (max-width: 1319.98px){.poster__row--description textarea{min-height:210px;margin-bottom:6px}}@media (max-width: 991.98px){.poster__row--description textarea{min-height:305px}}.poster__row--distribution{border-bottom:0}@media (max-width: 1319.98px){.poster__row--distribution{padding-bottom:30px}}@media (max-width: 991.98px){.poster__row--distribution{padding-top:38px;padding-bottom:40px}}.poster__row--distribution label{letter-spacing:-0.08px}.poster__col{flex:1;position:relative}@media (max-width: 1319.98px){.poster__col:not(:last-child){margin-bottom:20px}}.poster__col--inner{display:flex;min-width:100%;gap:40px}.poster__grid{display:grid;grid-template-columns:repeat(3, 1fr)}@media (min-width: 1320px){.poster__grid{max-width:80%;margin-bottom:37px}}@media (max-width: 1319.98px){.poster__grid{grid-template-columns:repeat(auto-fill, 261px)}}.poster__grid label{margin-bottom:0;padding-top:10px;padding-bottom:10px}.poster__info{padding-left:30px;background:url(/static/img/svg/Info3.svg) left top no-repeat;line-height:22px}@media (max-width: 1319.98px){.poster__info{font-size:12px;line-height:20px;max-width:90%}}.poster__label{margin-bottom:10px}.poster__area-descr{text-align:right;font-size:14px;line-height:20px;padding-right:11px;color:var(--brand-grey3)}@media (max-width: 767.98px){.poster__area-descr{padding-right:0}}@media (max-width: 1319.98px){.poster__errors{margin-bottom:2px}}.poster__towns-list{display:none;max-height:200px;width:100%;position:absolute;background-color:var(--brand-white);overflow:scroll;overflow-x:hidden;z-index:100}.poster__towns-list.show{display:block}.poster__towns-list::-webkit-scrollbar{width:10px}.poster__towns-list::-webkit-scrollbar-thumb{background-color:#FF613A;border-radius:20px;border:3px solid white}.poster__locate{appearance:none}.poster .btn{margin:0}@media (max-width: 575.98px){.poster .btn{padding-left:5px;padding-right:5px}}@media (max-width: 767.98px){.poster .cargo--inline{width:100%}}

View File

@@ -1 +1 @@
.container{margin:0 auto;max-width:1280px;position:relative;box-sizing:border-box}.container.black{background-color:#0088cc;height:200px;margin:0}@media (min-width: 1760px){.container{max-width:1720px}}@media (max-width: 1319.98px){.container{max-width:952px}}@media (max-width: 991.98px){.container{width:728px}}@media (max-width: 767.98px){.container{width:536px}}@media (max-width: 575.98px){.container{max-width:100vw;margin:0;padding:0 16px}}.col-12{width:100%}.col-11{width:91.66666667%}.col-10{width:83.33333333%}.col-9{width:75%}.col-8{width:66.66666667%}.col-7{width:58.33333333%}.col-6{width:50%}.col-5{width:41.66666667%}.col-4{width:33.33333333%}.col-3{width:25%}.col-2{width:16.66666667%}.col-1{width:8.33333333%}@media (min-width: 576px){.col-sm-12{width:100%}.col-sm-11{width:91.66666667%}.col-sm-10{width:83.33333333%}.col-sm-9{width:75%}.col-sm-8{width:66.66666667%}.col-sm-7{width:58.33333333%}.col-sm-6{width:50%}.col-sm-5{width:41.66666667%}.col-sm-4{width:33.33333333%}.col-sm-3{width:25%}.col-sm-2{width:16.66666667%}.col-sm-1{width:8.33333333%}}@media (min-width: 768px){.col-md-12{width:100%}.col-md-11{width:91.66666667%}.col-md-10{width:83.33333333%}.col-md-9{width:75%}.col-md-8{width:66.66666667%}.col-md-7{width:58.33333333%}.col-md-6{width:50%}.col-md-5{width:41.66666667%}.col-md-4{width:33.33333333%}.col-md-3{width:25%}.col-md-2{width:16.66666667%}.col-md-1{width:8.33333333%}}@media (min-width: 992px){.col-lg-12{width:100%}.col-lg-11{width:91.66666667%}.col-lg-10{width:83.33333333%}.col-lg-9{width:75%}.col-lg-8{width:66.66666667%}.col-lg-7{width:58.33333333%}.col-lg-6{width:50%}.col-lg-5{width:41.66666667%}.col-lg-4{width:33.33333333%}.col-lg-3{width:25%}.col-lg-2{width:16.66666667%}.col-lg-1{width:8.33333333%}}@media (min-width: 1320px){.col-xl-12{width:100%}.col-xl-11{width:91.66666667%}.col-xl-10{width:83.33333333%}.col-xl-9{width:75%}.col-xl-8{width:66.66666667%}.col-xl-7{width:58.33333333%}.col-xl-6{width:50%}.col-xl-5{width:41.66666667%}.col-xl-4{width:33.33333333%}.col-xl-3{width:25%}.col-xl-2{width:16.66666667%}.col-xl-1{width:8.33333333%}}@media (min-width: 1760px){.col-xxl-12{width:100%}.col-xxl-11{width:91.66666667%}.col-xxl-10{width:83.33333333%}.col-xxl-9{width:75%}.col-xxl-8{width:66.66666667%}.col-xxl-7{width:58.33333333%}.col-xxl-6{width:50%}.col-xxl-5{width:41.66666667%}.col-xxl-4{width:33.33333333%}.col-xxl-3{width:25%}.col-xxl-2{width:16.66666667%}.col-xxl-1{width:8.33333333%}}:root{--brand-primary: #FF613A;--brand-white: #fff;--brand-black: #000;--brand-black2: #272424;--brand-grey: #F1F1F1;--brand-grey2: #E6E6E6;--brand-grey3: #7A7979;--brand-orange: #FF613A;--box-shadow-primary: -1px 4px 10px 0 rgba(198,199,203,0.2),0 -1px 10px 0 rgba(198,199,203,0.2);--base-border-radius: 10px;--base-border: 2.5px solid #E6E6E6;--base-input-height: 60px;text-align:center;color:var(--brand-black2)}html,body{max-width:100vw;max-height:initial;overflow-x:hidden}html{overflow:hidden}label{display:inline-block}label[required]:before{content:"*";color:var(--brand-primary)}input,textarea{outline:none;border:var(--base-border);border-radius:var(--base-border-radius);height:var(--base-input-height);width:100%;font-size:16px;line-height:22px;cursor:pointer;padding:10px 40px 10px 7px;box-sizing:border-box;max-width:100%}input.date,textarea.date{background:white url(/static/img/svg/Calendar.svg) right 2% bottom 45% no-repeat}input.locate,textarea.locate{background:white url(/static/img/svg/MapPinLine.svg) right 2% bottom 45% no-repeat}.btn{display:inline-flex;text-decoration:none;color:black;line-height:22px;border-radius:10px;padding:20px 76px 18px;justify-content:center;align-items:center;margin:0 3px;letter-spacing:0.2px;font-size:18px}.btn--primary{background:var(--brand-primary);color:var(--brand-white)}
.container{margin:0 auto;max-width:1280px;position:relative;box-sizing:border-box}.container.black{background-color:#0088cc;height:200px;margin:0}@media (min-width: 1760px){.container{max-width:1720px}}@media (max-width: 1319.98px){.container{max-width:952px}}@media (max-width: 991.98px){.container{width:728px}}@media (max-width: 767.98px){.container{width:536px}}@media (max-width: 575.98px){.container{max-width:100vw;margin:0;padding:0 16px}}.col-12{width:100%}.col-11{width:91.66666667%}.col-10{width:83.33333333%}.col-9{width:75%}.col-8{width:66.66666667%}.col-7{width:58.33333333%}.col-6{width:50%}.col-5{width:41.66666667%}.col-4{width:33.33333333%}.col-3{width:25%}.col-2{width:16.66666667%}.col-1{width:8.33333333%}@media (min-width: 576px){.col-sm-12{width:100%}.col-sm-11{width:91.66666667%}.col-sm-10{width:83.33333333%}.col-sm-9{width:75%}.col-sm-8{width:66.66666667%}.col-sm-7{width:58.33333333%}.col-sm-6{width:50%}.col-sm-5{width:41.66666667%}.col-sm-4{width:33.33333333%}.col-sm-3{width:25%}.col-sm-2{width:16.66666667%}.col-sm-1{width:8.33333333%}}@media (min-width: 768px){.col-md-12{width:100%}.col-md-11{width:91.66666667%}.col-md-10{width:83.33333333%}.col-md-9{width:75%}.col-md-8{width:66.66666667%}.col-md-7{width:58.33333333%}.col-md-6{width:50%}.col-md-5{width:41.66666667%}.col-md-4{width:33.33333333%}.col-md-3{width:25%}.col-md-2{width:16.66666667%}.col-md-1{width:8.33333333%}}@media (min-width: 992px){.col-lg-12{width:100%}.col-lg-11{width:91.66666667%}.col-lg-10{width:83.33333333%}.col-lg-9{width:75%}.col-lg-8{width:66.66666667%}.col-lg-7{width:58.33333333%}.col-lg-6{width:50%}.col-lg-5{width:41.66666667%}.col-lg-4{width:33.33333333%}.col-lg-3{width:25%}.col-lg-2{width:16.66666667%}.col-lg-1{width:8.33333333%}}@media (min-width: 1320px){.col-xl-12{width:100%}.col-xl-11{width:91.66666667%}.col-xl-10{width:83.33333333%}.col-xl-9{width:75%}.col-xl-8{width:66.66666667%}.col-xl-7{width:58.33333333%}.col-xl-6{width:50%}.col-xl-5{width:41.66666667%}.col-xl-4{width:33.33333333%}.col-xl-3{width:25%}.col-xl-2{width:16.66666667%}.col-xl-1{width:8.33333333%}}@media (min-width: 1760px){.col-xxl-12{width:100%}.col-xxl-11{width:91.66666667%}.col-xxl-10{width:83.33333333%}.col-xxl-9{width:75%}.col-xxl-8{width:66.66666667%}.col-xxl-7{width:58.33333333%}.col-xxl-6{width:50%}.col-xxl-5{width:41.66666667%}.col-xxl-4{width:33.33333333%}.col-xxl-3{width:25%}.col-xxl-2{width:16.66666667%}.col-xxl-1{width:8.33333333%}}:root{--brand-primary: #FF613A;--brand-white: #fff;--brand-black: #000;--brand-black2: #272424;--brand-grey: #F1F1F1;--brand-grey2: #E6E6E6;--brand-grey3: #7A7979;--brand-orange: #FF613A;--box-shadow-primary: -1px 4px 10px 0 rgba(198,199,203,0.2),0 -1px 10px 0 rgba(198,199,203,0.2);--base-border-radius: 10px;--base-border: 2.5px solid #E6E6E6;--base-input-height: 60px;text-align:center;color:var(--brand-black2)}html,body{max-width:100vw;max-height:initial;height:initial;overflow-x:hidden}label{display:inline-block}label[required]:before{content:"*";color:var(--brand-primary)}input,textarea{outline:none;border:var(--base-border);border-radius:var(--base-border-radius);height:var(--base-input-height);width:100%;font-size:16px;line-height:22px;cursor:pointer;padding:10px 40px 10px 7px;box-sizing:border-box;max-width:100%}input.date,textarea.date{background:white url(/static/img/svg/Calendar.svg) right 2% bottom 45% no-repeat}input.locate,textarea.locate{background:white url(/static/img/svg/MapPinLine.svg) right 2% bottom 45% no-repeat}input.loading,textarea.loading{background:white url(/static/img/svg/loader.svg) no-repeat calc(100% - 15px) center}input.is-items,textarea.is-items{background:url(/static/img/png/icon-arrow.svg) calc(100% - 15px) center no-repeat white}.btn{display:inline-flex;text-decoration:none;color:black;line-height:22px;border-radius:10px;padding:20px 76px 18px;justify-content:center;align-items:center;margin:0 3px;letter-spacing:0.2px;font-size:18px}.btn--primary{background:var(--brand-primary);color:var(--brand-white)}

309
static/js/form-poster.js Normal file
View File

@@ -0,0 +1,309 @@
!function () {
'use strict';
var posterApp = {
initDatePickerr: function () {
const _this = this;
[this._selector.inpDeparture, this._selector.inpArrival].forEach(i => {
let date = i.val();
if (!i.length) return false
let startDate = null
if (window.location.href.includes("/ru/")) {
startDate = moment(date, "D MMMM YYYY г. HH:mm", 'ru');
} else {
startDate = moment(date, "MMMM D, YYYY, h:mm a", 'en');
}
if (!i.attr('hidden')) {
i.daterangepicker({
"autoapply": true,
"linkedCalendars": false,
"singleDatePicker": true,
"timePicker": true,
"timePicker24Hour": true,
"minDate": startDate,
"locale": changeLangForDateTimePicker(),
}, function (start, end, label) {
i.val(start.format('DD.MM.YYYY HH:mm'));
});
}
});
},
changeCargoType: function () {
let inpTypeAvia = this._selector.typeItems.filter((d,i)=>i.value === 'avia');
let inpTypePassenger = this._selector.cargoItems.filter((d,i)=>i.value === 'passenger');
this._selector.cargoItems.off('change.i-disable').on('change.i-disable', (e)=>{
this.handlerDisabled(e.target,inpTypeAvia,'passenger')
})
// change other type
this.handlerDisabled(inpTypePassenger,inpTypeAvia,'passenger')
},
handlerDisabled: function (el,el2,text) {
if($(el).val() === text) {
$(el2).attr('disabled', true);
} else {
$(el2).attr('disabled', false);
}
},
changeTransportType: function () {
let inpTypePassenger = this._selector.cargoItems.filter((d,i)=>i.value === 'passenger');
this._selector.typeItems.off('change.i-disable').on('change.i-disable', (e)=>{
this.handlerDisabled(e.target,inpTypePassenger,'avia')
})
},
initHandlerItemsTowns: function (el) {
el.list.off('click.item').on('click.item', (e) => {
let target = $(e.target)
let item = target.hasClass('autocomplete-result') ? target : target.parents('.autocomplete-result')
let dataStr = item.data('attr')
if (!dataStr.length) return
dataStr = dataStr.slice(1, -1).replace(/"/g, '');
let [id, txt, name, date] = dataStr.split(', ');
let inpNames = {
id: 'from_address_point',
txt: 'from_address_point_txt',
date: 'departure_DT'
}
if (name.match(/to/)) {
inpNames = {
id: 'to_address_point',
txt: 'to_address_point_txt',
date: 'arrival_DT'
}
}
const collection = this._selector.root[0].elements;
collection[inpNames.id].value = id;
collection[inpNames.txt].value = txt;
collection[inpNames.date].value = date;
this.handlerShowList(el)
})
},
setDataTowns: function (data, inp) {
if (!data.res_search_list.length) return
const newSearchlist = data.res_search_list.replace(/onmousedown=\'selectItemAddrPoint/g, 'data-attr=\'')
inp.list.html(newSearchlist);
},
handlerPageOut: function () {
let observer = new MutationObserver((e) => {
for (let mutation of e) {
for (let node of mutation.addedNodes) {
if (!(node instanceof HTMLElement)) continue;
if (node.classList.contains('poster')) {
posterApp.init()
observer.disconnect();
}
}
}
});
observer.observe(this._selector.wrapper[0], {
childList: true,
subtree: false,
characterDataOldValue: false
});
},
handlerShowList: function (i, isHide) {
if (!isHide && i.list.text()) {
i.list.toggleClass('show')
} else {
i.list.removeClass('show')
}
},
getDataForm: function (isObj) {
let formData = new FormData(this._selector.root[0]);
if (isObj) return Object.fromEntries(formData)
return formData;
},
initSubmit: function () {
const _this = this;
this._selector.root.off('submit').on('submit', function (e) {
e.preventDefault();
let routeId = _this._selector.submitBtn.data('routeId');
var formData = _this.getDataForm();
let url = '/routes/create_or_change_route/'
if (routeId) {
url = '/routes/change_route/' + routeId + '/'
}
$.ajax({
headers: {"X-CSRFToken": $('input[name=csrfmiddlewaretoken]').val()},
url: url,
type: "POST",
cache: false,
processData: false,
contentType: false,
data: formData,
success: function (data) {
return
let data_route_id = data.route_id
document.querySelector(".info_profile").innerHTML = data.html
let el_route = document.querySelector(`[data-number-of-route="${data_route_id}"]`);
if (routeId) {
el_route = document.querySelector(`[data-number-of-route="${routeId}"]`);
}
if(el_route) {
el_route.scrollIntoView({
behavior: "smooth",
block: 'start',
inline: 'start'
});
}
let currentUrl = window.location.pathname;
let newUrl = '';
if (currentUrl.includes('/create_route_for_customer')) {
newUrl = currentUrl.replace('/create_route_for_customer', '/my_routes');
} else if (currentUrl.includes('/create_route_for_mover')) {
newUrl = currentUrl.replace('/create_route_for_mover', '/my_routes');
}
window.history.replaceState(null, '', newUrl);
},
error: function (data, exception) {
document.querySelector(".info_profile").innerHTML = data.responseJSON.html;
document.getElementById('departure_DT')?.scrollIntoView({
behavior: "smooth",
block: 'nearest',
inline: 'nearest'
});
}
});
});
},
getTowns: function (el) {
const _this = this;
let timer = null
if (timer) {
clearTimeout(timer);
}
timer = setTimeout(function () {
timer = null;
let data = _this.getDataForm(true);
let getTownData = {
type_transport: data.type_transport,
search_str: el.val(),
ctrl_name: el.attr('name')
}
$.ajax({
headers: {"X-CSRFToken": $('input[name=csrfmiddlewaretoken]').val()},
url: '/reference_data/get_address_point/',
type: "POST",
cache: false,
processData: false,
contentType: false,
data: JSON.stringify(getTownData),
success: function (data) {
el.removeClass('loading');
const {res_search_list, unanswered_msgs_count} = data;
_this.setDataTowns(data, el)
_this.initHandlerItemsTowns(el)
_this.handlerShowList(el)
if (res_search_list.length) {
el.addClass('is-items')
el.parent().addClass('is-items')
el.list.addClass('is-items')
} else {
el.parent().removeClass('is-items')
el.removeClass('is-items')
el.list.removeClass('is-items')
}
console.log('fetch', data)
},
error: function (data) {
console.log('Error')
}
});
}, 500);
},
handlerSearchTown: function (e, i) {
this._cl('handlerSearchTown');
let el = i;
if (el.val().length > 2) {
el.addClass('loading');
this.getTowns(el);
} else {
el.removeClass('loading');
}
},
initHandlerRoute: function () {
this._cl('initHandlerRoute');
const _this = this;
[this._selector.inpFrom, this._selector.inpTo].forEach(i => {
if (!i.length) return false
i.off('input.routes').on('input.routes', (e) => _this.handlerSearchTown(e, i));
i.off('click.routes').on('click.routes', () => _this.handlerShowList(i));
i.list.off('mouseleave.routes').on('mouseleave.routes', () => _this.handlerShowList(i, true));
});
},
_cl: function (description, obj, debug) {
if (debug || this._data.debug) {
if (obj === undefined) {
console.log(description);
} else {
console.log(obj, description);
}
}
},
initData: function (root) {
window.posterApp = this;
this._data = {
debug: true
};
this._selector = {
root: root,
wrapper: $('.info_profile'),
inpFrom: root.find('#from'),
inpFromList: root.find('#from').siblings('.poster__towns-list'),
inpTo: root.find('#to'),
inpToList: root.find('#to').siblings('.poster__towns-list'),
cargoItems: root.find('.cargo__inp[name="cargo_type"]'),
typeItems: root.find('.cargo__inp[name="type_transport"]'),
inpDeparture: root.find('#departure_DT'),
inpArrival: root.find('#arrival_DT'),
submitBtn: root.find('button')
};
this._selector.inpFrom.list = this._selector.inpFromList
this._selector.inpFrom.date = this._selector.inpDeparture
this._selector.inpTo.list = this._selector.inpToList
this._selector.inpTo.date = this._selector.inpArrival
},
init: function () {
let root = $('#poster__form');
if (!root.length) return false
this.initData(root);
this._cl('posterApp init');
this._cl(this);
this.handlerPageOut();
this.initHandlerRoute();
this.initDatePickerr()
this.initSubmit();
this.changeCargoType();
this.changeTransportType()
},
};
$(function () {
posterApp.init();
});
}();

View File

@@ -281,13 +281,9 @@ function searchTown(el){
if (el.value.length > 2){
el.style.background = 'white url("/static/img/svg/loader.svg") no-repeat calc(100% - 15px) center';
}else {
el.style.background = 'white url("/static/img/png/icon-arrow.svg") no-repeat calc(100% - 15px) center';
}
if(el.value.length>=3){
let timer = null
if (timer) {
@@ -319,10 +315,6 @@ function searchTown(el){
success: function(data){
el.style.background = 'white url("/static/img/png/icon-arrow.svg") no-repeat calc(100% - 15px) center';
loader_place_ins_boris(el,"el")
return insertSearchList(data, el.name + '_list');
middleWareJS()
},

View File

@@ -52,13 +52,19 @@ function select_tab_profile (el,url,owner_type=null, check_orders_required) {
let confirm_url_f_lang_ru = ''
let confirm_url_f_lang_en = ''
if (owner_type){
window.history.pushState(null, null, `/${document.documentElement.lang}/profile/page/${profile_tabs_f_static_map.get(`${url}_${owner_type}`)}`)
window.history.pushState({ prevUrl: window.location.href }, null, `/${document.documentElement.lang}/profile/page/${profile_tabs_f_static_map.get(`${url}_${owner_type}`)}`)
confirm_url_f_lang_ru = `/ru/profile/page/${profile_tabs_f_static_map.get(`${url}_${owner_type}`)}/`
confirm_url_f_lang_en = `/en/profile/page/${profile_tabs_f_static_map.get(`${url}_${owner_type}`)}/`
if(!window.history.state.prevUrl.match(/create/)) {
window.location.reload()
}
} else {
window.history.pushState(null, null, `/${document.documentElement.lang}/profile/page/${profile_tabs_f_static_map.get(url)}/`)
window.history.pushState({ prevUrl: window.location.href }, null, `/${document.documentElement.lang}/profile/page/${profile_tabs_f_static_map.get(url)}/`)
confirm_url_f_lang_ru = `/ru/profile/page/${profile_tabs_f_static_map.get(url)}/`
confirm_url_f_lang_en = `/en/profile/page/${profile_tabs_f_static_map.get(url)}/`
if(window.history.state.prevUrl.match(/create/)) {
window.location.reload()
}
}
document.querySelector("#ru_lang").href = confirm_url_f_lang_ru
document.querySelector("#en_lang").href = confirm_url_f_lang_en

View File

@@ -1,3 +1,4 @@
@import "variables";
.cargo {
&--inline {
@@ -28,6 +29,13 @@
border-color: var(--brand-primary);
}
}
&:disabled {
+ label {
color: var(--brand-grey3);
cursor: not-allowed;
}
}
}
&__label {

View File

@@ -25,13 +25,10 @@ html,
body {
max-width: 100vw;
max-height: initial;
height: initial;
overflow-x: hidden;
}
html {
overflow: hidden;
}
label {
display: inline-block;
@@ -64,4 +61,12 @@ input, textarea {
&.locate {
background: white url(/static/img/svg/MapPinLine.svg) right 2% bottom 45% no-repeat;
}
&.loading {
background: white url(/static/img/svg/loader.svg) no-repeat calc(100% - 15px) center;
}
&.is-items {
background: url(/static/img/png/icon-arrow.svg) calc(100% - 15px) center no-repeat white;
}
}

View File

@@ -1,5 +1,7 @@
@import "../base/variables";
$row-gap: 40px;
.poster {
text-align: left;
box-sizing: border-box;
@@ -49,7 +51,7 @@
display: flex;
padding: 40px 0;
border-bottom: 1px solid #E6E6E6;
gap: 40px;
gap: $row-gap;
@media (min-width: $screen-xl-min) {
padding: 39px 0;
@@ -59,8 +61,8 @@
display: block;
}
&--from-to {
flex-wrap: wrap;
@media (max-width: $screen-md-max) {
padding-top: 14px
@@ -74,7 +76,6 @@
padding-top: 40px;
}
label {
padding-left: 9px;
@@ -222,6 +223,7 @@
&__col {
flex: 1;
position: relative;
@media (max-width: $screen-lg-max) {
&:not(:last-child) {
@@ -229,6 +231,12 @@
margin-bottom: 20px;
}
}
&--inner {
display: flex;
min-width: 100%;
gap: $row-gap;
}
}
&__grid {
@@ -286,6 +294,36 @@
}
}
&__towns-list {
display: none;
max-height: 200px;
width: 100%;
position: absolute;
background-color: var(--brand-white);
overflow: scroll;
overflow-x: hidden;
z-index: 100;
&.show {
display: block;
}
&::-webkit-scrollbar {
width: 10px;
}
&::-webkit-scrollbar-thumb {
background-color: #FF613A;
border-radius: 20px;
border: 3px solid white;
}
}
&__locate {
appearance: none;
}
.btn {
margin: 0;

View File

@@ -4,15 +4,30 @@
{% if owner_type == 'customer' %}
{% trans "Заполните форму, чтобы отправить посылку" as p_title %}
{% trans "Откуда забрать посылку" as l_from %}
{% trans "Куда доставить посылку" as l_to %}
{% trans "Каким способом Вы хотите отправить?" as l_transport %}
{% trans "Выберите кого (что) вы можете перевезти:" as l_cargo %}
{% trans "Дата отправления" as l_date_from %}
{% trans "Дата доставки посылки" as l_date_to %}
{% elif owner_type == 'mover' %}
{% trans "Заполните форму, чтобы перевезти посылку" as p_title %}
{% trans "Пункт отправления" as l_from %}
{% trans "Пункт прибытия" as l_to %}
{% trans "Укажите способ, которым вы можете перевезти" as l_transport %}
{% trans "Выберите кого (что) вы можете перевезти:" as l_cargo %}
{% trans "Дата отправления" as l_date_from %}
{% trans "Дата прибытия" as l_date_to %}
{% endif %}
<link rel="stylesheet" href="{% static 'css/ion.rangeSlider.min.css' %}">
<link rel="stylesheet" href="{% static 'css/create_poster.css' %}">
<div hidden>
csrfmiddlewaretoken: eoN2nLYYo46PpDIhi82dmTFASHH4ONiBdEQOz1jQNyUpsHJ4RrvcmFwfnM45TNtl
type_transport: road
from_address_point: 59613
from_address_point: 59613 4267
from_address_point_txt: Москаленки / Россия
to_address_point: 2824
to_address_point_txt: Берлар / Бельгия
@@ -28,81 +43,56 @@
owner_type: customer
hiddenTime: 16 декабря 2024 г. 23:04
</div>
<div class="poster">
<div class="poster poster--{% if owner_type == 'customer' %}customer{% else %}mover{% endif %}">
<h1 class="poster__title">{{ p_title }}</h1>
<form class="poster__form"
name="new_route"
method="post"
id="new_route"
id="poster__form"
>
{% csrf_token %}
{#from-to#}
<div class="poster__row poster__row--from-to">
<div class="poster__col">
<label for="from" class="poster__label " required>
{% translate "Откуда забрать посылку" %}
</label>
<input type="text" name="from" id="from" class="locate" placeholder="{% translate "Укажите город" %}">
</div>
<div class="poster__col">
<label for="to" class="poster__label " required>
{% translate "Куда доставить посылку" %}
</label>
<input type="text" name="to" id="to" class="locate" placeholder="{% translate "Укажите город" %}">
</div>
</div>
{#cargo-type#}
<div class="poster__row poster__row--cargo">
<div class="poster__col col-12">
<label class="poster__label col-12" required>
{% translate "Выберите кого (что) вы можете перевезти:" %}
</label>
<div class="poster__grid">
{% for item in form.fields.cargo_type.choices %}
<div class="cargo">
<input
class="cargo__inp"
type="radio"
name="cargo_type"
id="cargo_type_{{ forloop.counter }}"
required
value="{{ item.0 }}"
{% if item.checked %}
checked="checked"
{% endif %}
/>
<label class="cargo__label"
for="cargo_type_{{ forloop.counter }}">
<span>{{ item.1 }}</span>
</label>
</div>
{% endfor %}
</div>
</div>
</div>
{#date-poster#}
<div class="poster__row poster__row--date">
<div class="poster__col">
<label from="date-to" required class="poster__label col-12 ">
{% translate "Дата доставки посылки" %}
</label>
<input type="text" name="date-to" class="poster__date date">
</div>
<div class="poster__col"></div>
</div>
<input
type="number"
name="from_address_point"
id="from_address_point"
hidden
{% if form.initial.from_address_point %}value="{{ form.initial.from_address_point }}"{% endif %}
/>
<input
type="number"
name="to_address_point"
id="to_address_point"
hidden
{% if form.initial.to_address_point %}value="{{ form.initial.to_address_point }}"{% endif %}
/>
<input
id="hide_owner_type"
name="owner_type"
hidden
{% if form.initial.owner_type %}
value="{{ form.initial.owner_type }}"
{% elif form.data.owner_type %}
value="{{ form.data.owner_type }}"
{% endif %}
>
<input
id="hiddenTime"
type="text"
name="hiddenTime"
hidden
{% if route.departure_DT %}
value="{{ route.from_city.get_current_datetime }}"
{% elif form.initial.departure_DT %}
value="{{ form.initial.departure_DT }}"
{% endif %}
>
{#type-transport#}
<div class="poster__row poster__row--transport">
<div class="poster__col col-12">
<label for="type_transport" class="poster__label col-12" required>
{% translate "Каким способом Вы хотите отправить?" %}
{{ l_transport }}
</label>
{% for item in form.fields.type_transport.choices %}
<div class="cargo cargo--inline">
@@ -122,14 +112,158 @@
</label>
</div>
{% endfor %}
<div class="poster__errors">
</div>
{% if not errors_off and form.errors and form.errors.type_transport %}
<span>{{ form.errors.type_transport }}</span>
{% endif %}
<div class="poster__info">
{% translate "Обязательно учитывайте Правила и особенности перевозки выбранным Вами видом транспорта" %}
</div>
</div>
</div>
{#from-to#}
<div class="poster__row poster__row--from-to">
<div class="poster__col">
<label for="from" class="poster__label " required>
{{ l_from }}
</label>
<input type="text" autocomplete="off" name="from_address_point_txt" id="from" class="poster__locate locate"
placeholder="{% translate "Укажите город" %}" required>
<div class="poster__towns-list"></div>
{% if not errors_off and form.errors and form.errors.from_address_point %}
<span id="error_from_address_point">{{ form.errors.from_address_point }}</span>
{% endif %}
</div>
<div class="poster__col">
<label for="to" class="poster__label " required>
{{ l_to }}
</label>
<input type="text" autocomplete="off" name="to_address_point_txt" id="to" class="poster__locate locate"
placeholder="{% translate "Укажите город" %}" required>
<div class="poster__towns-list"></div>
{% if not errors_off and form.errors and form.errors.from_address_point %}
<span id="error_to_address_point">{{ form.errors.from_address_point }}</span>
{% endif %}
</div>
{% if owner_type == 'mover' %}
<div class="poster__col poster__col--inner">
{#date-from#}
<div class="poster__col">
<label for="departure_DT" required class="poster__label col-12 ">
{{ l_date_from }}
</label>
<input
type="text"
class="poster__date date"
id="departure_DT"
name="departure_DT"
readonly
value="{% if route.departure_DT %}
{{ route.from_city.get_current_datetime }}{% elif form.initial.departure_DT %}{{ form.initial.departure_DT }}{% endif %}"
/>
{% if not errors_off and form.errors and form.errors.departure_DT %}
<span id="error_arrival_DT">{{ form.errors.departure_DT }}</span>
{% endif %}
</div>
{#date-to#}
<div class="poster__col">
<label for="arrival_DT" required class="poster__label col-12 ">
{{ l_date_to }}
</label>
<input
type="text"
class="poster__date date"
id="arrival_DT"
name="arrival_DT"
readonly
value="{% if route.departure_DT %}
{{ route.from_city.get_current_datetime }}
{% elif form.initial.arrival_DT %}
{{ form.initial.arrival_DT }}
{% endif %}"
/>
{% if not errors_off and form.errors and form.errors.arrival_DT %}
<span id="error_arrival_DT">{{ form.errors.arrival_DT }}</span>
{% endif %}
</div>
</div>
{% endif %}
</div>
{#cargo-type#}
<div class="poster__row poster__row--cargo">
<div class="poster__col col-12">
<label class="poster__label col-12" required>
{{ l_cargo }}
</label>
<div class="poster__grid">
{% for item in form.fields.cargo_type.choices %}
<div class="cargo">
<input
class="cargo__inp"
type="radio"
name="cargo_type"
id="cargo_type_{{ forloop.counter }}"
required
value="{{ item.0 }}"
{% if forloop.first %}
checked
{% endif %}
/>
<label class="cargo__label"
for="cargo_type_{{ forloop.counter }}">
<span>{{ item.1 }}</span>
</label>
</div>
{% endfor %}
</div>
{% if not errors_off and form.errors and form.errors.cargo_type %}
<span id="error_cargo_type">{{ form.errors.cargo_type }}</span>
{% endif %}
</div>
</div>
{#date-poster#}
{% if owner_type == 'customer' %}
<div class="poster__row poster__row--date">
{#date-to#}
<div class="poster__col">
<label for="arrival_DT" required class="poster__label col-12 ">
{{ l_date_to }}
</label>
<input
type="text"
class="poster__date date"
id="arrival_DT"
name="arrival_DT"
readonly
value="{% if route.arrival_DT %}
{{ route.from_city.get_current_datetime }}
{% elif form.initial.arrival_DT %}
{{ form.initial.arrival_DT }}
{% endif %}"
/>
{% if not errors_off and form.errors and form.errors.arrival_DT %}
<span id="error_arrival_DT">{{ form.errors.arrival_DT }}</span>
{% endif %}
</div>
<div class="poster__col">
<input
type="text"
id="departure_DT"
name="departure_DT"
hidden
value="
{% if route.departure_DT %}
{{ route.from_city.get_current_datetime }}
{% elif form.initial.departure_DT %}
{{ form.initial.departure_DT }}
{% endif %}"
/>
</div>
</div>
{% endif %}
{#phone#}
<div class="poster__row poster__row--phone">
<div class="poster__col col-12">
@@ -137,10 +271,14 @@
<label for="phone" class="col-12">
{% translate "Контактный номер телефона, по которому с Вами могут связаться перевозчики" %}
</label>
<input class="col-12 col-xl-6" type="tel" placeholder="{% translate "Укажите телефон" %}">
<input class="col-12 col-xl-6" type="text" pattern="[0-9\-+]{5,}" maxlength="30"
placeholder="{% translate "Укажите телефон" %}" title="{% translate "Только цифры или - или +" %}">
<div class="poster__info">
{% translate "Если вы оставите это поле пустым - перевозчики смогут только написать вам в личные сообщения на нашем сайте TripWB.com" %}
</div>
{% if not errors_off and form.errors and form.errors.phone %}
<span id="error_id_phone">{{ form.errors.phone|safe }}</span>
{% endif %}
</div>
</div>
{#description#}
@@ -174,15 +312,12 @@
{% if form.initial.receive_msg_by_email == True %}
checked="checked"
{% endif %}
id="id_receive_msg_by_email">
id="receive_msg_by_email">
<label class="cargo__label" for="id_receive_msg_by_email">
<label class="cargo__label" for="receive_msg_by_email">
{% translate "Хочу получать уведомления на E-mail о появлении перевозчика по моим критериям" %}
</label>
</div>
{% if not errors_off and form.errors and form.errors.receive_msg_by_email %}
{{ form.errors.receive_msg_by_email }}
{% endif %}
@@ -190,11 +325,15 @@
<button type="submit"
class="btn btn--primary col-12"
onclick="sendRoute(this,
{% if route.id %}{{ route.id }}{% endif %})"
data-routeId="{% if route.id %}{{ route.id }}{% endif %}"
>
{% translate "Разместить объявление" %}
</button>
</form>
</div>
<script src="{% static 'js/form-poster.js' %}">
</script>

View File

@@ -88,6 +88,10 @@ function gtag_report_conversion(url) {
<link rel="stylesheet" href="{% static 'css/styles(boris).css' %}" >
<link rel="stylesheet" href="{% static 'css/mobile_styles.css' %}">
{% if page_type == 'profile' %}
<link rel="stylesheet" href="{% static 'css/create_poster.css' %}">
{% endif %}
<script src='{% static "js/find_route.js" %}'></script>
<script src="{% static "js/filters_functions_find_route.js" %}"></script>
<script src="{% static "js/dynamic_loading_routes.js" %}"></script>

View File

@@ -84,12 +84,14 @@
<link rel="stylesheet" href="{% static 'css/critical.css' %}">
<link rel="stylesheet" href="{% static 'css/create_poster.css' %}">
<script src='{% static "js/find_route.js" %}'></script>
<script src="{% static "js/filters_functions_find_route.js" %}"></script>
<script src="{% static "js/dynamic_loading_routes.js" %}"></script>
<script src="{% static "js/user_profile.js" %}"></script>
<script src="{% static "js/user_profile_2.js" %}"></script>
{# <script src="{% static "js/user_profile.js" %}"></script>#}
{# <script src="{% static "js/user_profile_2.js" %}"></script>#}
<script src="{% static "js/ion.rangeSlider.min.js" %}"></script>
<link rel="stylesheet" href="{% static "css/ion.rangeSlider.min.css" %}">