Настройка на отображение и сокрытие номера тега

This commit is contained in:
zakhy 2025-05-19 12:00:29 +07:00
parent c6a3dc002e
commit 8381ae2b73
6 changed files with 72 additions and 12 deletions

View File

@ -52,6 +52,9 @@
{% endblock %}
{% block script_footer %}
<script>
const showTagSnOnMarker = Boolean(Number('{{ show_tag_sn_on_marker|safe }}'))
</script>
<script>
let buildingsLayer
let streetZonesLayer
@ -163,7 +166,6 @@
setInterval(updateMarkers, 3000);
function polygonGrayStyleFunction(feature, resolution) {
return new ol.style.Style({
stroke: new ol.style.Stroke({

View File

@ -0,0 +1,30 @@
# Generated by Django 4.2.19 on 2025-05-19 04:25
from django.db import migrations
def create_base_settings(apps, schema_editor): # type: ignore
Settings = apps.get_model("settings", "Settings")
Subsystem = apps.get_model("settings", "Subsystem")
subsystem, _ = Subsystem.objects.get_or_create(name="Общие параметры")
setting, _ = Settings.objects.get_or_create(
name="show_tag_sn_on_marker",
read_name="Показывать номер тега на карте",
data_type="bool",
subsystem=subsystem,
show_in_admin=True,
value="1",
)
class Migration(migrations.Migration):
dependencies = [
("settings", "0001_initial"),
]
operations = [
migrations.RunPython(
create_base_settings, reverse_code=migrations.RunPython.noop
),
]

View File

@ -0,0 +1,23 @@
# Generated by Django 4.2.19 on 2025-05-19 04:59
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("settings", "0002_auto_20250519_0425"),
]
operations = [
migrations.AlterField(
model_name="settings",
name="name",
field=models.CharField(max_length=60, verbose_name="Наименование"),
),
migrations.AlterField(
model_name="settings",
name="read_name",
field=models.CharField(blank=True, max_length=250, verbose_name="Перевод"),
),
]

View File

@ -21,11 +21,9 @@ class Settings(models.Model):
("bool", "Булево"),
)
name = models.CharField(
max_length=60, help_text="", default=" ", verbose_name="Наименование"
)
name = models.CharField(max_length=60, help_text="", verbose_name="Наименование")
read_name = models.CharField(
max_length=250, help_text="", default="", verbose_name="Перевод", blank=True
max_length=250, help_text="", verbose_name="Перевод", blank=True
)
data_type = models.CharField(
max_length=5,
@ -48,7 +46,7 @@ class Settings(models.Model):
)
ordering = models.SmallIntegerField(verbose_name="Порядок", default=0)
def get_value(self) -> int | float | str | datetime.datetime:
def get_value(self) -> int | float | str | datetime.datetime: # noqa: CFQ004
# Возможное место для ошибок, поскольку тип может выдать ошибку при приведении
# Если настройка создана некорректно (тип в data_type отличается от фактического содержимого value)
try:
@ -65,7 +63,7 @@ class Settings(models.Model):
return bool(self.value)
case _:
return self.value
except Exception:
except Exception: # noqa: B902
logger.error(traceback.format_exc())
return self.value

View File

@ -134,7 +134,16 @@ function VlocationStyleFunction(feature, resolution) {
width: 1
})
});
let textStyle
if (showTagSnOnMarker) {
textStyle = new ol.style.Style({
text: createFeatureTextStyle(feature, resolution, new ol.style.Fill({color: bgFill}), textFill)
})
} else {
textStyle = new ol.style.Style({
text: undefined
})
}
return [
new ol.style.Style({
image: backgroundStyle
@ -146,9 +155,7 @@ function VlocationStyleFunction(feature, resolution) {
height: 30
})
}),
new ol.style.Style({
text: createFeatureTextStyle(feature, resolution, new ol.style.Fill({color: bgFill}), textFill)
})
textStyle
];
}

View File

@ -17,7 +17,7 @@ const propertiesTranslate = {
uid: "Идентификатор",
description: "Описание"
}
const invisibleProperties = ['id', 'geometry', 'icon', 'condition', 'style', 'layer', 'pk', "colorIndex"]
const invisibleProperties = ['id', 'geometry', 'icon', 'condition', 'style', 'layer', 'pk', "colorIndex", "iso_time"]
let popover;
function disposePopover() {