fill and stroke opacity for data overlays

This commit is contained in:
Gwendolyn 2024-12-16 15:54:45 +01:00
parent de50691c85
commit 4536390eba
4 changed files with 34 additions and 27 deletions

View file

@ -397,33 +397,28 @@ class EditorFormBase(I18nModelFormMixin, ModelForm):
def create_editor_form(editor_model):
possible_fields = ['slug', 'name', 'title', 'title_plural', 'help_text', 'position_secret', 'icon', 'join_edges',
'up_separate', 'bssid', 'main_point', 'external_url', 'hub_import_type', 'walk', 'ordering',
'category', 'width', 'groups', 'height', 'color', 'in_legend', 'priority', 'hierarchy',
'icon_name', 'base_altitude', 'waytype', 'access_restriction', 'default_height', 'door_height',
'outside', 'can_search', 'can_describe', 'geometry', 'single', 'altitude', 'short_label',
'origin_space', 'target_space', 'data', 'comment', 'slow_down_factor', 'groundaltitude',
'node_number', 'wifi_bssid', 'bluetooth_address', "group",
'ibeacon_uuid', 'ibeacon_major', 'ibeacon_minor', 'uwb_address',
'extra_seconds', 'speed', 'can_report_missing', "can_report_mistake",
'description', 'speed_up', 'description_up', 'avoid_by_default',
'report_help_text', 'enter_description', 'level_change_description', 'base_mapdata_accessible',
'label_settings', 'label_override', 'min_zoom', 'max_zoom', 'font_size', 'members',
'allow_levels', 'allow_spaces', 'allow_areas', 'allow_pois', 'allow_dynamic_locations',
'left', 'top', 'right', 'bottom', 'import_tag', 'import_block_data', 'import_block_geom',
'public', 'default', 'dark', 'high_contrast', 'funky', 'randomize_primary_color', 'color_logo',
'color_css_initial', 'color_css_primary', 'color_css_secondary', 'color_css_tertiary',
'color_css_quaternary', 'color_css_quinary', 'color_css_header_background',
'color_css_header_text', 'color_css_header_text_hover',
'color_css_shadow', 'color_css_overlay_background', 'color_css_grid',
'color_css_modal_backdrop', 'color_css_route_dots_shadow', 'extra_css',
'icon_path', 'leaflet_marker_config',
'color_background', 'color_wall_fill', 'color_wall_border', 'color_door_fill',
'color_ground_fill', 'color_obstacles_default_fill', 'color_obstacles_default_border',
'stroke_color', 'stroke_width', 'fill_color', 'interactive', 'point_icon', 'extra_data',
'show_label', 'show_geometry', 'external_url',
'show_label', 'show_geometry', 'external_url', 'default_geomtype',
]
possible_fields = [
'slug', 'name', 'title', 'title_plural', 'help_text', 'position_secret', 'icon', 'join_edges',
'up_separate', 'bssid', 'main_point', 'external_url', 'hub_import_type', 'walk', 'ordering',
'category', 'width', 'groups', 'height', 'color', 'in_legend', 'priority', 'hierarchy', 'icon_name',
'base_altitude', 'waytype', 'access_restriction', 'default_height', 'door_height', 'outside', 'can_search',
'can_describe', 'geometry', 'single', 'altitude', 'short_label', 'origin_space', 'target_space', 'data',
'comment', 'slow_down_factor', 'groundaltitude', 'node_number', 'wifi_bssid', 'bluetooth_address', "group",
'ibeacon_uuid', 'ibeacon_major', 'ibeacon_minor', 'uwb_address', 'extra_seconds', 'speed', 'can_report_missing',
"can_report_mistake", 'description', 'speed_up', 'description_up', 'avoid_by_default', 'report_help_text',
'enter_description', 'level_change_description', 'base_mapdata_accessible', 'label_settings', 'label_override',
'min_zoom', 'max_zoom', 'font_size', 'members', 'allow_levels', 'allow_spaces', 'allow_areas', 'allow_pois',
'allow_dynamic_locations', 'left', 'top', 'right', 'bottom', 'import_tag', 'import_block_data',
'import_block_geom', 'public', 'default', 'dark', 'high_contrast', 'funky', 'randomize_primary_color',
'color_logo', 'color_css_initial', 'color_css_primary', 'color_css_secondary', 'color_css_tertiary',
'color_css_quaternary', 'color_css_quinary', 'color_css_header_background', 'color_css_header_text',
'color_css_header_text_hover', 'color_css_shadow', 'color_css_overlay_background', 'color_css_grid',
'color_css_modal_backdrop', 'color_css_route_dots_shadow', 'extra_css', 'icon_path', 'leaflet_marker_config',
'color_background', 'color_wall_fill', 'color_wall_border', 'color_door_fill', 'color_ground_fill',
'color_obstacles_default_fill', 'color_obstacles_default_border', 'stroke_color', 'stroke_width',
'stroke_opacity', 'fill_color', 'fill_opacity', 'interactive', 'point_icon', 'extra_data', 'show_label',
'show_geometry', 'external_url', 'show_label', 'show_geometry', 'external_url', 'default_geomtype',
]
field_names = [field.name for field in editor_model._meta.get_fields()
if not field.one_to_many and not isinstance(field, ManyToManyRel)]
existing_fields = [name for name in possible_fields if name in field_names]

View file

@ -21,7 +21,9 @@ class DataOverlay(TitledMixin, AccessRestrictionMixin, models.Model):
description = models.TextField(blank=True, verbose_name=_('Description'))
stroke_color = models.CharField(max_length=255, blank=True, null=True, verbose_name=_('default stroke color'))
stroke_width = models.FloatField(blank=True, null=True, verbose_name=_('default stroke width'))
stroke_opacity = models.FloatField(blank=True, null=True, verbose_name=_('stroke opacity'))
fill_color = models.CharField(max_length=255, blank=True, null=True, verbose_name=_('default fill color'))
fill_opacity = models.FloatField(blank=True, null=True, verbose_name=_('fill opacity'))
default_geomtype = models.CharField(max_length=255, blank=True, null=True, choices=GeometryType, verbose_name=_('default geometry type'))
@ -43,7 +45,9 @@ class DataOverlayFeature(TitledMixin, GeometryMixin, models.Model):
external_url = models.URLField(blank=True, null=True, verbose_name=_('external URL'))
stroke_color = models.CharField(max_length=255, blank=True, null=True, verbose_name=_('stroke color'))
stroke_width = models.FloatField(blank=True, null=True, verbose_name=_('stroke width'))
stroke_opacity = models.FloatField(blank=True, null=True, verbose_name=_('stroke opacity'))
fill_color = models.CharField(max_length=255, blank=True, null=True, verbose_name=_('fill color'))
fill_opacity = models.FloatField(blank=True, null=True, verbose_name=_('fill opacity'))
show_label = models.BooleanField(default=False, verbose_name=_('show label'))
show_geometry = models.BooleanField(default=True, verbose_name=_('show geometry'))
interactive = models.BooleanField(default=True, verbose_name=_('interactive'),

View file

@ -368,7 +368,9 @@ class DataOverlaySchema(TitledSchema, DjangoModelSchema):
description: Optional[str]
stroke_color: Optional[str]
stroke_width: Optional[float]
stroke_opacity: Optional[float]
fill_color: Optional[str]
fill_opacity: Optional[float]
@ -380,7 +382,9 @@ class DataOverlayFeatureSchema(TitledSchema, WithGeometrySchema, DjangoModelSche
level_id: PositiveInt
stroke_color: Optional[str]
stroke_width: Optional[float]
stroke_opacity: Optional[float]
fill_color: Optional[str]
fill_opacity: Optional[float]
show_label: bool
show_geometry: bool
interactive: bool

View file

@ -2859,7 +2859,9 @@ class DataOverlay {
this.group = options.group;
this.default_stroke_color = options.stroke_color;
this.default_stroke_width = options.stroke_width;
this.default_stroke_opacity = options.stroke_opacity;
this.default_fill_color = options.fill_color;
this.default_fill_opacity = options.fill_opacity;
}
async create() {
@ -2874,7 +2876,9 @@ class DataOverlay {
const style = {
'color': feature.stroke_color ?? this.default_stroke_color ?? 'var(--color-map-overlay)',
'weight': feature.stroke_width ?? this.default_stroke_width ?? 1,
'opacity': feature.stroke_opacity ?? this.default_stroke_opacity ?? 1,
'fillColor': feature.fill_color ?? this.default_fill_color ?? 'var(--color-map-overlay)',
'fillOpacity': feature.fill_opacity ?? this.default_fill_opacity ?? 0.2,
};
const layer = L.geoJson(feature.geometry, {
style,