Focus important fields on forms
This commit is contained in:
parent
8293737058
commit
552d4bee9e
|
@ -7,6 +7,7 @@
|
|||
* Add copy button on Add session page to copy times between fields
|
||||
* Use the same form when editing a session as when adding a session
|
||||
* Add a hacky way not to reload a page when starting or ending a session (https://git.kucharczyk.xyz/lukas/timetracker/issues/52)
|
||||
* Focus important fields on forms
|
||||
|
||||
## 1.0.3 / 2023-02-20 17:16+01:00
|
||||
|
||||
|
|
|
@ -6,6 +6,8 @@ custom_date_widget = forms.DateInput(attrs={"type": "date"})
|
|||
custom_datetime_widget = forms.DateTimeInput(
|
||||
attrs={"type": "datetime-local"}, format="%Y-%m-%d %H:%M"
|
||||
)
|
||||
autofocus_select_widget = forms.Select(attrs={"autofocus": "autofocus"})
|
||||
autofocus_input_widget = forms.TextInput(attrs={"autofocus": "autofocus"})
|
||||
|
||||
|
||||
class SessionForm(forms.ModelForm):
|
||||
|
@ -13,7 +15,8 @@ class SessionForm(forms.ModelForm):
|
|||
# queryset=Purchase.objects.filter(date_refunded=None).order_by("edition__name")
|
||||
# )
|
||||
purchase = forms.ModelChoiceField(
|
||||
queryset=Purchase.objects.order_by("edition__name")
|
||||
queryset=Purchase.objects.order_by("edition__name"),
|
||||
widget=autofocus_select_widget,
|
||||
)
|
||||
|
||||
class Meta:
|
||||
|
@ -38,7 +41,9 @@ class EditionChoiceField(forms.ModelChoiceField):
|
|||
|
||||
|
||||
class PurchaseForm(forms.ModelForm):
|
||||
edition = EditionChoiceField(queryset=Edition.objects.order_by("name"))
|
||||
edition = EditionChoiceField(
|
||||
queryset=Edition.objects.order_by("name"), widget=autofocus_select_widget
|
||||
)
|
||||
platform = forms.ModelChoiceField(queryset=Platform.objects.order_by("name"))
|
||||
|
||||
class Meta:
|
||||
|
@ -59,7 +64,9 @@ class PurchaseForm(forms.ModelForm):
|
|||
|
||||
|
||||
class EditionForm(forms.ModelForm):
|
||||
game = forms.ModelChoiceField(queryset=Game.objects.order_by("name"))
|
||||
game = forms.ModelChoiceField(
|
||||
queryset=Game.objects.order_by("name"), widget=autofocus_select_widget
|
||||
)
|
||||
platform = forms.ModelChoiceField(queryset=Platform.objects.order_by("name"))
|
||||
|
||||
class Meta:
|
||||
|
@ -71,15 +78,18 @@ class GameForm(forms.ModelForm):
|
|||
class Meta:
|
||||
model = Game
|
||||
fields = ["name", "wikidata"]
|
||||
widgets = {"name": autofocus_input_widget}
|
||||
|
||||
|
||||
class PlatformForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = Platform
|
||||
fields = ["name", "group"]
|
||||
widgets = {"name": autofocus_input_widget}
|
||||
|
||||
|
||||
class DeviceForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = Device
|
||||
fields = ["name", "type"]
|
||||
widgets = {"name": autofocus_input_widget}
|
||||
|
|
Loading…
Reference in New Issue