1.1.3 rising and highlight my_route
This commit is contained in:
@@ -616,18 +616,24 @@ function confirmUpgrade(el, routeID){
|
||||
event.preventDefault()
|
||||
el.disabled = true
|
||||
|
||||
let remainsRisingCount = parseInt(document.getElementById('remains_route_rising_count').innerText);
|
||||
let remainsHighlightCount = parseInt(document.getElementById('remains_route_highlight_count').innerText);
|
||||
|
||||
let form = el.form
|
||||
let formData = new FormData(form);
|
||||
formData.set('route_id', routeID)
|
||||
formData.set('remainsRisingCount', remainsRisingCount)
|
||||
formData.set('remainsHighlightCount', remainsHighlightCount)
|
||||
let url = '/routes/'
|
||||
let checkboxes = document.querySelectorAll('input[name="route_option"]');
|
||||
// let checkboxes = document.querySelectorAll('input[name="route_option"]');
|
||||
let checkboxes = document.querySelectorAll('input[name="route_option"][data-routeid="' + routeID + '"]');
|
||||
|
||||
|
||||
for (let i = 0; i < checkboxes.length; i++) {
|
||||
|
||||
if (checkboxes[i].checked && checkboxes[i].id === "highlight_route" ) {
|
||||
if (checkboxes[i].checked && checkboxes[i].id === "highlight_route_" + routeID ) {
|
||||
url = '/routes/highlight_route/'
|
||||
}else if(checkboxes[i].checked && checkboxes[i].id === "raise_route"){
|
||||
}else if(checkboxes[i].checked && checkboxes[i].id === "raise_route_" + routeID){
|
||||
url = '/routes/raise_route/'
|
||||
}
|
||||
}
|
||||
@@ -645,10 +651,31 @@ function confirmUpgrade(el, routeID){
|
||||
data: formData,
|
||||
success: function(data){
|
||||
|
||||
if(url === '/routes/raise_route/' && remainsRisingCount > 0 ){
|
||||
remainsRisingCount -= 1;
|
||||
} else if(url === '/routes/highlight_route/' && remainsHighlightCount > 0){
|
||||
remainsHighlightCount -= 1;
|
||||
}
|
||||
|
||||
|
||||
// for (let i = 0; i < checkboxes.length; i++) {
|
||||
//
|
||||
// if (checkboxes[i].checked && remainsRisingCount > 0 ) {
|
||||
// remainsRisingCount -= 1;
|
||||
// }else if(checkboxes[i].checked && remainsHighlightCount > 0){
|
||||
// remainsHighlightCount -= 1;
|
||||
// }
|
||||
// }
|
||||
|
||||
document.getElementById('remains_route_rising_count').innerText = remainsRisingCount.toString();
|
||||
document.getElementById('remains_route_highlight_count').innerText = remainsHighlightCount;
|
||||
|
||||
let data_route_id = data.route_id
|
||||
// location.href = '/profile'
|
||||
// document.querySelector(".info_profile").innerHTML = data.html
|
||||
|
||||
if(!data.status){
|
||||
document.querySelector('[data-number-of-route="' + routeID + '"]').innerHTML = data.html
|
||||
}
|
||||
|
||||
|
||||
let el_route = document.querySelector(`[data-number-of-route="${data_route_id}"]`);
|
||||
|
||||
@@ -59,26 +59,30 @@
|
||||
<div class="checkbox_wrapper">
|
||||
<input type="radio"
|
||||
name="route_option"
|
||||
data-routeid="{{ route.id }}"
|
||||
class="custom-checkbox round"
|
||||
|
||||
id="raise_route">
|
||||
<label for="raise_route" class="route_label">
|
||||
id="raise_route_{{ route.id }}">
|
||||
<label for="raise_route_{{ route.id }}" class="route_label">
|
||||
<div class="label_text">{% trans "Поднять объявление" %}</div>
|
||||
</label>
|
||||
</div>
|
||||
<div class="sub_label_text">{% trans "Осталось поднятий " %} {{ remains_route_rising_count }}</div>
|
||||
<div class="sub_label_text">{% trans "Осталось поднятий " %} <span
|
||||
id="remains_route_rising_count"
|
||||
>{% if form.data.remainsRisingCount %}{{ form.data.remainsRisingCount }}{% else %}{{ remains_route_rising_count }}{% endif %}</span></div>
|
||||
|
||||
<div class="checkbox_wrapper">
|
||||
<input type="radio"
|
||||
name="route_option"
|
||||
data-routeid="{{ route.id }}"
|
||||
class="custom-checkbox round"
|
||||
{# checked="checked"#}
|
||||
id="highlight_route">
|
||||
<label for="highlight_route" class="route_label">
|
||||
id="highlight_route_{{ route.id }}">
|
||||
<label for="highlight_route_{{ route.id }}" class="route_label">
|
||||
<div class="label_text">{% trans "Выделить объявление цветом " %}</div>
|
||||
</label>
|
||||
</div>
|
||||
<div class="sub_label_text">{% trans "Осталось выделений " %}{{ remains_route_highlight_count }}</div>
|
||||
<div class="sub_label_text">{% trans "Осталось выделений " %}<span id="remains_route_highlight_count">{{ remains_route_highlight_count }}</span></div>
|
||||
|
||||
<button onclick="confirmUpgrade(this,{{ route.id }} )" id="send_upgrade"> {% trans "Подтвердить" %}</button>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user