Home Information - Your home, your data, organized.
Python
Adding entity support. Beginnings of path editing JS. WIP
Anthony Cassandraad22e1667037
diff --git a/src/hi/apps/entity/edit/forms.py b/src/hi/apps/entity/edit/forms.pynew file mode 100644index 00000000..d20127e6--- /dev/null+++ b/src/hi/apps/entity/edit/forms.py@@ -0,0 +1,31 @@+from django import forms++from hi.apps.entity.enums import EntityType+++class EntityForm(forms.Form):++ name = forms.CharField(+ label = 'Name',+ max_length = 64,+ required = False,+ )++ entity_type = forms.ChoiceField(+ label = 'Entity Type',+ choices = EntityType.choices,+ initial = EntityType.default_value(),+ required = True,+ widget = forms.Select( attrs = { 'class' : 'custom-select' } ),+ )++ def clean(self):+ cleaned_data = super().clean()++ name = cleaned_data.get( 'name', '' )+ if not name:+ entity_type_str = cleaned_data.get( 'entity_type' )+ entity_type = EntityType.from_name_safe( entity_type_str )+ cleaned_data['name'] = entity_type.label++ return cleaned_datadiff --git a/src/hi/apps/entity/edit/helpers.py b/src/hi/apps/entity/edit/helpers.pynew file mode 100644index 00000000..4d2947d3--- /dev/null+++ b/src/hi/apps/entity/edit/helpers.py@@ -0,0 +1,20 @@+from django.http import HttpRequest++from hi.apps.entity.enums import EntityType+from hi.apps.entity.models import Entity+from hi.integrations.core.enums import IntegrationType+++class EntityEditHelpers:++ @classmethod+ def create_entity( cls,+ request : HttpRequest,+ entity_type : EntityType,+ name : str ) -> Entity:+ return Entity.objects.create(+ name = name,+ entity_type_str = str(entity_type),+ integration_type_str = str(IntegrationType.NONE),+ integration_key = None,+ )diff --git a/src/hi/apps/entity/templates/entity/edit/modals/entity_add.html b/src/hi/apps/entity/templates/entity/edit/modals/entity_add.htmlnew file mode 100644index 00000000..be503b50--- /dev/null+++ b/src/hi/apps/entity/templates/entity/edit/modals/entity_add.html@@ -0,0 +1,28 @@+{% extends "modals/action_with_cancel.html" %}++{% block preamble %}+<form action="{% url 'entity_edit_entity_add' %}" method="post"+ class="form" data-async="modal">+ {% csrf_token %}+{% endblock %}++{% block title_text %}+New Entity+{% endblock %}++{% block body %}+<div>+{% include "entity/edit/panes/entity_form.html" %}+</div>+{% endblock %}++{% block action_right %}+<button id="hi-add-entity-button" type="submit" class="btn btn-lg btn-success"+ name="action" value="add">+ ADD+</button>+{% endblock %}++{% block postamble %}+</form>+{% endblock %}diff --git a/src/hi/apps/entity/templates/entity/edit/panes/entity_form.html b/src/hi/apps/entity/templates/entity/edit/panes/entity_form.htmlnew file mode 100644index 00000000..4fb4a634--- /dev/null+++ b/src/hi/apps/entity/templates/entity/edit/panes/entity_form.html@@ -0,0 +1,28 @@+{% for hidden in entity_form.hidden_fields %}+{{ hidden }}+{% endfor %}++{% if entity_form.non_field_errors %}+<div class="non-field-errors">+ {% for err in entity_form.non_field_errors %}+ <p class="form-error text-danger">ERROR: {{ err }}</p>+ {% endfor %}+</div>+{% endif %}++<div>+ <div class="input-group mb-2 mr-sm-2">+ <div class="input-group-prepend">+ <div class="input-group-text">{{ entity_form.entity_type.label_tag }}</div>+ </div>+ {{ entity_form.entity_type }}+ </div>+ {{ ollection_form.entity_type.errors }}+</div>++<div>+ {{ entity_form.name.label }}+ {{ entity_form.name }}+ {{ entity_form.name.errors }}+</div>+diff --git a/src/hi/apps/location/templates/location/svg_icon_item.html b/src/hi/apps/location/templates/location/svg_icon_item.htmlnew file mode 100644index 00000000..a810efa5--- /dev/null+++ b/src/hi/apps/location/templates/location/svg_icon_item.html@@ -0,0 +1,4 @@+<g id="{{ svg_icon_item.html_id }}" class="selectable draggable" data-type="svg-icon"+ transform="{{ svg_icon_item.transform_str }}">+ {% include svg_icon_item.template_name %}+</g>diff --git a/src/hi/apps/location/templates/location/svg_path_item.html b/src/hi/apps/location/templates/location/svg_path_item.htmlnew file mode 100644index 00000000..53836245--- /dev/null+++ b/src/hi/apps/location/templates/location/svg_path_item.html@@ -0,0 +1,7 @@+<g id="{{ svg_path_item.html_id }}" class="selectable" data-type="svg-path">+ <path fill="{{ svg_path_item.path_style.fill_color }}"+ stroke="{{ svg_path_item.path_style.stroke_color }}"+ stroke-width="{{ svg_path_item.path_style.stroke_width }}"+ vector-effect="non-scaling-stroke"+ d="{{ svg_path_item.svg_path }}"></path>+</g>