0.0.48 w route card

This commit is contained in:
SBD
2025-01-18 15:08:26 +03:00
parent 2a7a666f7d
commit feb2b9d697
3 changed files with 14 additions and 8 deletions

View File

@@ -6,6 +6,9 @@ from django.conf import settings
from django.shortcuts import render from django.shortcuts import render
from uuid import uuid1 from uuid import uuid1
from twisted.web.http import stringToDatetime
from .models import * from .models import *
from django.contrib import auth from django.contrib import auth
from django.http import HttpResponse, Http404, JsonResponse from django.http import HttpResponse, Http404, JsonResponse
@@ -195,7 +198,9 @@ def edit_route_ajax(request):
print(msg) print(msg)
return JsonResponse({'errors': msg}) return JsonResponse({'errors': msg})
html = render_to_string('blocks/profile/b_new_route.html', Dict, request=request) tpl_name = f'v2/blocks/b_create_{ route.owner_type }_route.html'
html = render_to_string(tpl_name, Dict, request=request)
res_Dict = { res_Dict = {
'html': html, 'html': html,
'btn_title': _('Сохранить изменения') 'btn_title': _('Сохранить изменения')

View File

@@ -12,7 +12,8 @@ function changeRoute(el) {
data: data, data: data,
data_type: 'json', data_type: 'json',
success: (res) => { success: (res) => {
if (!res.html) return;
$(".info_profile")[0].innerHTML = res.html;
}, error: (res) => { }, error: (res) => {
} }
@@ -45,7 +46,7 @@ function deleteRoute(el) {
} }
function raiseRoute(el) { function raiseRoute(el) {
if (!el) return; if (!el || el.dataset.actions_count === '0') return;
let $parent = el.closest(".w_route_card") let $parent = el.closest(".w_route_card")
if (!$parent) return; if (!$parent) return;
@@ -68,7 +69,7 @@ function raiseRoute(el) {
} }
function highlightRoute(el) { function highlightRoute(el) {
if (!el) return; if (!el || el.dataset.actions_count === '0') return;
let $parent = el.closest(".w_route_card") let $parent = el.closest(".w_route_card")
if (!$parent) return; if (!$parent) return;

View File

@@ -155,13 +155,13 @@
<div class="route_btn_title">{% trans "Редактировать" %}</div> <div class="route_btn_title">{% trans "Редактировать" %}</div>
</div> </div>
<div class="container_actions_mobile"> <div class="container_actions_mobile">
<div class="route_btn" style="--route-btn-height: fit-content;--route-btn-width: auto;" data-action="raise" onclick="raiseRoute(this)"> <div class="route_btn" data-actions_count="{{ used_route_rising_count }}" style="--route-btn-height: fit-content;--route-btn-width: auto;" data-action="raise" onclick="raiseRoute(this)">
<div class="route_btn_title">{% trans "Поднять" %}</div> <div class="route_btn_title">{% trans "Поднять" %}</div>
<div class="route_btn_data">Осталось поднятий: 2</div> <div class="route_btn_data">Осталось поднятий: {{ used_route_rising_count }}</div>
</div> </div>
<div class="route_btn" style="--route-btn-height: fit-content;--route-btn-width: auto;" data-action="highlight" onclick="highlightRoute(this)"> <div class="route_btn" data-actions_count="{{ used_route_highlight_count }}" style="--route-btn-height: fit-content;--route-btn-width: auto;" data-action="highlight" onclick="highlightRoute(this)">
<div class="route_btn_title">{% trans "Выделить цветом" %}</div> <div class="route_btn_title">{% trans "Выделить цветом" %}</div>
<div class="route_btn_data">Осталось выделений: 0</div> <div class="route_btn_data">Осталось выделений: {{ used_route_highlight_count }}</div>
</div> </div>
</div> </div>
<div class="delete_route" onclick="deleteRoute(this)">{% trans "Удалить" %}</div> <div class="delete_route" onclick="deleteRoute(this)">{% trans "Удалить" %}</div>