diff --git a/static/js/range_calendar.js b/static/js/range_calendar.js index 6dd4a66..545714d 100644 --- a/static/js/range_calendar.js +++ b/static/js/range_calendar.js @@ -143,108 +143,69 @@ function init_arrival_DT (date=null,single=true,hour=true){ } +function init_departure_DT() { + let place_1 = document.querySelector("#id_departure_DT"); + if (!place_1) return; -function init_departure_DT (){ + let hiddenTime = document.querySelector('.local_city_time').innerText; + let startDate; - let place_1 = document.querySelector("#id_departure_DT") - let onl_param = "" - if (window.location.href === "http://localhost:8016/ru/profile/page/create_route_for_mover/" || window.location.href === "http://localhost:8016/ru/profile/page/create_route_for_customer/"){ - onl_param = "singleDatePicker" - } - if (place_1) { - $(place_1).daterangepicker({ - "autoapply": true, - "linkedCalendars": false, - "singleDatePicker":true, - "timePicker":true, - "timePicker24Hour":true, - "locale": changeLangForDateTimePicker(), - }, - function(start, end, label) { - // $('#displayRegervation').text('Registration date is: ' + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD')); - // $('#regervation')[0].dataset['departure_DT'] = start.format('YYYY-MM-DD'); - // $('#regervation')[0].dataset['arrival_DT'] = end.format('YYYY-MM-DD'); - $('#id_departure_DT').val(start.format('DD.MM.YYYY HH:mm')) + if (window.location.href.includes("/ru/")) { - }); + startDate = moment(hiddenTime, "D MMMM YYYY г. HH:mm", 'ru'); + } else { - $(`${place_1.id} .drp-calendar.right`).hide(); - $(`${place_1.id} .drp-calendar.left`).addClass('single'); - - $(`${place_1.id} .calendar-table`).on('DOMSubtreeModified', function() { - var el = $(`${place_1.id} .prev.available`).parent().children().last(); - if (el.hasClass('next available')) { - return; - } - el.addClass('next available'); - el.append(''); - }); + startDate = moment(hiddenTime, "MMMM D, YYYY, h:mm a", 'en'); } + + $(place_1).daterangepicker({ + "autoapply": true, + "linkedCalendars": false, + "singleDatePicker": true, + "timePicker": true, + "timePicker24Hour": true, + "minDate": startDate, + "locale": changeLangForDateTimePicker(), + }, function (start, end, label) { + $('#id_departure_DT').val(start.format('DD.MM.YYYY HH:mm')); + }); + + $(`${place_1.id} .drp-calendar.right`).hide(); + $(`${place_1.id} .drp-calendar.left`).addClass('single'); + + $(`${place_1.id} .calendar-table`).on('DOMSubtreeModified', function () { + var el = $(`${place_1.id} .prev.available`).parent().children().last(); + if (el.hasClass('next available')) { + return; + } + el.addClass('next available'); + el.append(''); + }); } $(function () { - let onl_param = "" - if (window.location.href === "http://localhost:8016/ru/profile/page/create_route_for_mover/" || window.location.href === "http://localhost:8016/ru/profile/page/create_route_for_customer/"){ - onl_param = "singleDatePicker: true" - } - let place_1 = document.querySelector("#id_arrival_DT") - if (place_1) { - $(place_1).daterangepicker({ - "autoapply": true, - "linkedCalendars": false, - "locale": changeLangForDateTimePicker(), - - }, - function (start, end, label) { - - // $('#displayRegervation').text('Registration date is: ' + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD')); - $('#id_arrival_DT').val(start.format('DD.MM.YYYY') + " - " + end.format('DD.MM.YYYY')) - }); - - $(`${place_1.id} .drp-calendar.right`).hide(); - $(`${place_1.id} .drp-calendar.left`).addClass('single'); - - $(`${place_1.id} .calendar-table`).on('DOMSubtreeModified', function () { - var el = $(`${place_1.id} .prev.available`).parent().children().last(); - if (el.hasClass('next available')) { - return; - } - el.addClass('next available'); - el.append(''); - }); - } - }); - -$(function() { - let place_1 = document.querySelector("#id_departure_DT") - let onl_param = "" - if (window.location.href === "http://localhost:8016/ru/profile/page/create_route_for_mover/" || window.location.href === "http://localhost:8016/ru/profile/page/create_route_for_customer/"){ - onl_param = "singleDatePicker: true" + let onl_param = {}; + if (window.location.href.includes("/ru/profile/page/create_route_for_mover/") || window.location.href.includes("/ru/profile/page/create_route_for_customer/")) { + onl_param = { singleDatePicker: true }; } + + let place_1 = document.querySelector("#id_arrival_DT"); if (place_1) { $(place_1).daterangepicker({ "autoapply": true, "linkedCalendars": false, "locale": changeLangForDateTimePicker(), - onl_param - }, - function(start, end, label) { - // $('#displayRegervation').text('Registration date is: ' + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD')); - // $('#regervation')[0].dataset['departure_DT'] = start.format('YYYY-MM-DD'); - // $('#regervation')[0].dataset['arrival_DT'] = end.format('YYYY-MM-DD'); - $('#id_departure_DT').val(start.format('DD.MM.YYYY') + " - " + end.format('DD.MM.YYYY')) - // init_arrival_DT(start.format('DD.MM.YYYY'),false,false) - $('#id_arrival_DT').val('') - init_arrival_DT(start.format('DD.MM.YYYY'),false,false) - + ...onl_param + }, function (start, end, label) { + $('#id_arrival_DT').val(start.format('DD.MM.YYYY') + " - " + end.format('DD.MM.YYYY')); }); $(`${place_1.id} .drp-calendar.right`).hide(); $(`${place_1.id} .drp-calendar.left`).addClass('single'); - $(`${place_1.id} .calendar-table`).on('DOMSubtreeModified', function() { + $(`${place_1.id} .calendar-table`).on('DOMSubtreeModified', function () { var el = $(`${place_1.id} .prev.available`).parent().children().last(); if (el.hasClass('next available')) { return; @@ -253,4 +214,37 @@ $(function() { el.append(''); }); } -}); \ No newline at end of file +}); + +$(function() { + let place_1 = document.querySelector("#id_departure_DT"); + let onl_param = {}; + if (window.location.href.includes("/ru/profile/page/create_route_for_mover/") || window.location.href.includes("/ru/profile/page/create_route_for_customer/")) { + onl_param = { singleDatePicker: true }; + } + + if (place_1) { + $(place_1).daterangepicker({ + "autoapply": true, + "linkedCalendars": false, + "locale": changeLangForDateTimePicker(), + ...onl_param + }, function (start, end, label) { + $('#id_departure_DT').val(start.format('DD.MM.YYYY') + " - " + end.format('DD.MM.YYYY')); + $('#id_arrival_DT').val(''); + init_arrival_DT(start.format('DD.MM.YYYY'), false, false); + }); + + $(`${place_1.id} .drp-calendar.right`).hide(); + $(`${place_1.id} .drp-calendar.left`).addClass('single'); + + $(`${place_1.id} .calendar-table`).on('DOMSubtreeModified', function () { + var el = $(`${place_1.id} .prev.available`).parent().children().last(); + if (el.hasClass('next available')) { + return; + } + el.addClass('next available'); + el.append(''); + }); + } +}); diff --git a/static/js/user_profile.js b/static/js/user_profile.js index f0101cd..37a5633 100644 --- a/static/js/user_profile.js +++ b/static/js/user_profile.js @@ -346,13 +346,18 @@ function searchTown(el){ -function selectItemAddrPoint(id, name, ctrl_name,){ +function selectItemAddrPoint(id, name, ctrl_name, city_DT){ let input_list = document.getElementsByName(ctrl_name + '_list')[0]; let tap_txt_cont = document.querySelector("#id_" + ctrl_name); + let local_city_time = document.querySelector(".local_city_time"); + local_city_time.innerHTML = city_DT; tap_txt_cont.value = name; tap_txt_cont.setAttribute('title',name) let tap_cont = document.querySelector("#id_" + ctrl_name.slice(0, -4)); tap_cont.value = id; + + init_departure_DT() + if (tap_txt_cont.classList.contains('red_text')){ tap_txt_cont.classList.remove('red_text') } diff --git a/templates/blocks/profile/b_new_route.html b/templates/blocks/profile/b_new_route.html index c59fd3e..36e5abb 100644 --- a/templates/blocks/profile/b_new_route.html +++ b/templates/blocks/profile/b_new_route.html @@ -74,92 +74,9 @@ {% if form.initial and form.initial.type_transport and form.initial.type_transport != '' %}