Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions grumpy/meetings/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Meta:
queryset=Book.objects.unread(),
required=True,
to_field_name="title",
widget=forms.TextInput(attrs={"readonly": "readonly"}),
widget=forms.TextInput(attrs={"readonly": "readonly", "type": "password"}),
)

location = gis_forms.PointField(
Expand All @@ -59,7 +59,7 @@ def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# make sure all the widgets make good use of the available space
for field_name, field_obj in self.fields.items():
if field_name == "date":
if field_name in ["book", "date"]:
field_obj.widget.attrs["class"] = "w-75"
else:
field_obj.widget.attrs["class"] = "w-100"
24 changes: 23 additions & 1 deletion grumpy/meetings/templates/meetings/meeting_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,14 @@
<div class="form-group row">
<div class="col-sm-2">{{ field.label_tag }}</div>
<div class="col-sm-10">
{{ field }}
<div class="input-group">
{{ field }}
{% if field.name == "book" %}
<span class="input-group-text" id="toggleBookVisibility">
<i class="bi bi-eye"></i>
</span>
{% endif %}
</div>
<div class="help form-text text-muted">{{ field.field.help_text|safe }}</div>
<div class="text-danger">{{ field.errors }}</div>
</div>
Expand All @@ -44,3 +51,18 @@
</div>

{% endblock content %}

{% block scripts %}
{{ block.super }}
<script type='text/javascript'>
$(document).ready(function() {
// toggle visibility of book...
const bookField = $("#id_book");
$("#toggleBookVisibility").on("click", function() {
bookFieldType = $(bookField).attr("type") === "password" ? "text" : "password";
$(bookField).attr("type", bookFieldType);
$(this).find(".bi").toggleClass("bi-eye-slash bi-eye")
});
});
</script>
{% endblock scripts %}
Loading