diff --git a/static/js/user_profile.js b/static/js/user_profile.js index 7c2872e..a3d9081 100644 --- a/static/js/user_profile.js +++ b/static/js/user_profile.js @@ -153,8 +153,52 @@ function myProfile(el){ +function removeRoute(el) { + let remove_item = el.currentTarget.parentNode.parentNode.parentNode.parentNode.parentNode.dataset.numberOfRoute + let remove_data = {} + let name_route = 'route.id' + remove_data[name_route] = remove_item + + // console.log(remove_item) + + $.ajax({ + headers: { "X-CSRFToken": $('input[name=csrfmiddlewaretoken]').val() }, + url: '/ru/routes/del_route/', + type: "POST", + // async: true, + cache: false, + processData: false, + contentType: false, + // enctype: 'json', + data: JSON.stringify(remove_data) , + success: function(data){ + if (data.user_alerts) { + getNewMessageSession() + } + + // location.href = '/profile' + document.querySelector(".info_profile").innerHTML = data.html; + + // let list_div = document.querySelectorAll('.menu_profile div'); + // list_div.forEach(el=>{ el.classList.remove('selected'); }); + // el.classList.add('selected') + + //updating the url without reloading + window.history.pushState(null, null, '/ru/profile/page/change_profile/') + + + }, + error: function (data, exception){ + console.log(400) + + } + }); + + +} + function confirmRemove(el) { @@ -166,7 +210,7 @@ function confirmRemove(el) { el.setAttribute("id", "select-remove"); let btn = document.querySelector("#select-remove"); - if(!btn.classList.contains('confirm_remove')){ + if (!btn.classList.contains('confirm_remove')) { btn.classList.add('confirm_remove') btn.innerText = 'Подтвердить удаление' // let place = document.querySelector('.button_remove_route') @@ -175,10 +219,16 @@ function confirmRemove(el) { cancel_button.innerText = "Отменить удаление"; let place = btn.closest(".button_remove_route") place.insertBefore(cancel_button, btn.nextSibling); + + btn.addEventListener('click', removeRoute, { once: true }) + btn.removeAttribute("id", "select-remove") + + } - btn.removeAttribute("id", "select-remove") } + + function searchTown(el){ if (el.value.length > 0){ diff --git a/templates/widgets/w_route_info.html b/templates/widgets/w_route_info.html index 5022f94..6d7ed4a 100644 --- a/templates/widgets/w_route_info.html +++ b/templates/widgets/w_route_info.html @@ -108,21 +108,21 @@ {#
#} {#
#} -
- - Тип:{{ route.get_cargo_type_display }} - - - - Вес:{{ route.weight }} кг - - - - - {{ route.get_type_transport_display }} - - -
+{#
#} +{# #} +{# Тип:{{ route.get_cargo_type_display }}#} +{# #} +{##} +{# #} +{# Вес:{{ route.weight }} кг#} +{# #} +{##} +{# #} +{##} +{# {{ route.get_type_transport_display }}#} +{# #} +{##} +{#
#} {##} {#
#} {##}