-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feature/tag-incident-commander
- Loading branch information
Showing
54 changed files
with
1,693 additions
and
1,512 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,37 @@ | ||
from __future__ import annotations | ||
|
||
import logging | ||
from typing import TYPE_CHECKING, Any | ||
from typing import Any, NotRequired, Required, TypedDict | ||
|
||
from django_components import component | ||
from django_components import EmptyTuple, component | ||
|
||
if TYPE_CHECKING: | ||
from firefighter.incidents.models.user import User | ||
from firefighter.incidents.models.user import User | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class Data(TypedDict): | ||
user: User | ||
size_tailwind: int | ||
size_px: int | ||
|
||
|
||
Args = tuple[User] | ||
|
||
|
||
class Kwargs(TypedDict, total=False): | ||
user: Required[User] | ||
size: NotRequired[str] | ||
|
||
|
||
@component.register("avatar") | ||
class Avatar(component.Component): | ||
class Avatar(component.Component[EmptyTuple, Kwargs, Data, Any]): | ||
template_name = "avatar/avatar.html" | ||
|
||
def get_context_data(self, user: User, *args: Any, **kwargs: Any) -> dict[str, Any]: | ||
def get_context_data(self, user: User, **kwargs: Any) -> Data: | ||
size_px, size_tailwind = (40, 10) if kwargs.get("size") == "md" else (80, 20) | ||
return {"user": user, "size_tailwind": size_tailwind, "size_px": size_px} | ||
return { | ||
"user": user, | ||
"size_tailwind": size_tailwind, | ||
"size_px": size_px, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,21 @@ | ||
from __future__ import annotations | ||
|
||
import logging | ||
from typing import Any | ||
from typing import Any, NotRequired, Required, TypedDict, Unpack | ||
|
||
from django_components import component | ||
from django_components import EmptyTuple, component | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class Data(TypedDict, total=False): | ||
id: Required[str] | ||
card_title: NotRequired[str] | ||
|
||
|
||
@component.register("card") | ||
class Card(component.Component): | ||
class Card(component.Component[EmptyTuple, Data, Data, Any]): | ||
template_name = "card/card.html" | ||
|
||
def get_context_data(self, *args: Any, **kwargs: dict[str, Any]) -> dict[str, Any]: | ||
def get_context_data(self, *args: Any, **kwargs: Unpack[Data]) -> Data: | ||
return kwargs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,26 @@ | ||
from __future__ import annotations | ||
|
||
import logging | ||
from typing import TYPE_CHECKING, Any | ||
from typing import Any, NotRequired, TypedDict | ||
|
||
from django_components import component | ||
|
||
if TYPE_CHECKING: | ||
from django import forms | ||
from django import forms | ||
from django_components import EmptyTuple, component | ||
from django_components.slots import SlotContent | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class Slots(TypedDict, total=False): | ||
form_footer: NotRequired[SlotContent[Any]] | ||
|
||
|
||
class Data(TypedDict): | ||
form: forms.Form | ||
|
||
|
||
@component.register("form") | ||
class Form(component.Component): | ||
class Form(component.Component[EmptyTuple, Data, Data, Slots]): # type: ignore[type-var] # type: ignore[override] | ||
template_name = "form/form.html" | ||
|
||
def get_context_data( | ||
self, form: forms.Form, *args: Any, **kwargs: Any | ||
) -> dict[str, Any]: | ||
return { | ||
"form": form, | ||
} | ||
def get_context_data(self, form: forms.Form, **kwargs: Any) -> Data: | ||
return Data(form=form) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,34 @@ | ||
from __future__ import annotations | ||
|
||
import logging | ||
from typing import TYPE_CHECKING, Any | ||
from typing import ( | ||
Any, | ||
Never, | ||
TypedDict, | ||
) | ||
|
||
from django_components import component | ||
|
||
if TYPE_CHECKING: | ||
from django import forms | ||
from django import forms | ||
from django_components import EmptyTuple, component | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class Data(TypedDict): | ||
field: forms.Field | forms.BoundField | ||
field_input_class: str | ||
|
||
|
||
class Kwargs(TypedDict, total=True): | ||
field: forms.Field | forms.BoundField | ||
|
||
|
||
@component.register("form_field") | ||
class FormField(component.Component): | ||
class FormField(component.Component[EmptyTuple, Kwargs, Data, Any]): | ||
template_name = "form_field/form_field.html" | ||
|
||
def get_context_data( | ||
self, field: forms.BoundField | forms.Field, *args: Any, **kwargs: Any | ||
) -> dict[str, Any]: | ||
if field is None: | ||
raise ValueError("Field not set!") | ||
|
||
self, field: forms.BoundField | forms.Field, **kwargs: Never | ||
) -> Data: | ||
input_class = "input-ff" | ||
|
||
return {"field": field, "field_input_class": input_class} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,21 @@ | ||
from __future__ import annotations | ||
|
||
import logging | ||
from typing import Any | ||
from typing import Any, TypedDict | ||
|
||
from django_components import component | ||
from django.contrib.messages.storage.base import BaseStorage | ||
from django_components import EmptyTuple, component | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class Data(TypedDict): | ||
messages: BaseStorage | ||
|
||
|
||
@component.register("messages") | ||
class Messages(component.Component): | ||
class Messages(component.Component[EmptyTuple, Data, Data, Any]): | ||
template_name = "messages/messages.html" | ||
|
||
def get_context_data(self, *args: Any, **kwargs: Any) -> dict[str, Any]: | ||
return kwargs | ||
def get_context_data(self, messages: BaseStorage, **kwargs: Any) -> Data: | ||
return Data(messages=messages) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,35 @@ | ||
from __future__ import annotations | ||
|
||
import logging | ||
from typing import Any | ||
from typing import Any, NotRequired, Required, TypedDict, Unpack | ||
|
||
from django_components import component | ||
from django.utils.safestring import SafeString | ||
from django_components import EmptyTuple, component | ||
from django_components.slots import SlotFunc | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
SlotContent = str | SafeString | SlotFunc[Any] | ||
|
||
|
||
class Kwargs(TypedDict, total=False): | ||
autoplay: Required[bool] | ||
header: NotRequired[bool] | ||
|
||
|
||
class Data(TypedDict): | ||
autoplay: bool | ||
|
||
|
||
class Slots(TypedDict): | ||
modal_header: NotRequired[SlotContent] | ||
modal_content: NotRequired[SlotContent] | ||
modal_enabler: NotRequired[SlotContent] | ||
|
||
|
||
@component.register("modal") | ||
class Modal(component.Component): | ||
class Modal(component.Component[EmptyTuple, Kwargs, Data, Any]): | ||
template_name = "modal/modal.html" | ||
|
||
def get_context_data( | ||
self, *args: Any, autoplay: bool = False, **kwargs: Any | ||
) -> dict[str, bool]: | ||
return { | ||
"autoplay": autoplay, | ||
} | ||
def get_context_data(self, *args: Any, **kwargs: Unpack[Kwargs]) -> Data: | ||
return Kwargs(autoplay=kwargs["autoplay"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.