Skip to content

Commit fee3746

Browse files
committed
Make described checkboxes a lot more clear
Instead of a weirdly located "hover over the checkbox to get a description" message, put the actual description underneath the checkboxes. This removes the need for javascript for it, and make the description a lot more readily available. This applies only to news tags for now, since that's the only use of described checkboxes, but hopefully it will make those more clear to people submitting. In passing, fix how help_text for multi-checkbox field is shown -- it was previously shown almost as part of the field name itself, making it very hard to make out. Now make it look like all other form field help texts.
1 parent 8de3732 commit fee3746

File tree

5 files changed

+14
-10
lines changed

5 files changed

+14
-10
lines changed

media/css/main.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,6 +1235,11 @@ th.formfieldnamecontainer {
12351235
margin: 0.5em 0;
12361236
}
12371237

1238+
.form-check div.describedcheckbox {
1239+
margin-left: 3rem;
1240+
font-style: italic;
1241+
}
1242+
12381243
.form-check-input[type=radio] {
12391244
margin-top: .4rem;
12401245
}

media/js/forms.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@ $(document).ready(function(){
1010
update_form_toggles($(e));
1111
});
1212

13-
$('div.form-group[data-cbtitles]').each(function(idx, e) {
14-
var d = $(e).data('cbtitles');
15-
$.each(d, function(k,v) {
16-
$(e).find('input[type=checkbox][value=' + k + ']').parent('div').prop('title', v);
17-
});
18-
});
1913
});
2014

2115
function update_form_toggles(e) {

pgweb/news/migrations/0003_news_tags.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ class Migration(migrations.Migration):
2929
migrations.AddField(
3030
model_name='newsarticle',
3131
name='tags',
32-
field=models.ManyToManyField(help_text='Hover mouse over tags to view full description', to='news.NewsTag'),
32+
field=models.ManyToManyField(help_text='Select the tags appropriate for this post', to='news.NewsTag'),
3333
),
3434
]

pgweb/news/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class NewsArticle(models.Model):
2222
title = models.CharField(max_length=200, null=False, blank=False)
2323
content = models.TextField(null=False, blank=False)
2424
tweeted = models.BooleanField(null=False, blank=False, default=False)
25-
tags = models.ManyToManyField(NewsTag, blank=False, help_text="Hover mouse over tags to view full description")
25+
tags = models.ManyToManyField(NewsTag, blank=False, help_text="Select the tags appropriate for this post")
2626

2727
send_notification = True
2828
send_m2m_notification = True

templates/base/form_contents.html

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
</div>
2626
</div>
2727
{% else %}{# field|ischeckbox #}
28-
<div class="form-group"{%if field|ismultiplecheckboxes%} data-cbtitles="{{described_checkboxes|dictlookup:field.name|json}}"{%endif%}>
28+
<div class="form-group">
2929
<div class="col-lg-12 {%if field|isrequired_error%} alert alert-danger{%endif%}">
3030
{% if not field|ismultiplecheckboxes %}
3131
<div class="form-check">
@@ -38,11 +38,16 @@
3838
{%endif%}
3939
</div>
4040
{% else %}
41-
{{ field.label_tag }} {{field.help_text|safe}}
41+
{{ field.label_tag }}
42+
{%if field.help_text%}<small class="form-text">{{field.help_text|safe}}</small>{%endif%}
4243
{% for cb in field %}
4344
<div class="form-check">
4445
{{ cb.tag }}
4546
<label for="{{ cb.id_for_label }}" class="form-check-label">{{ cb.choice_label }}</label>
47+
{%if described_checkboxes|dictlookup:field.name%}
48+
49+
<div class="describedcheckbox">{{described_checkboxes|dictlookup:field.name|dictlookup:cb.data.value}}</div>
50+
{%endif%}
4651
</div>
4752
{% endfor %}
4853
{% endif %}

0 commit comments

Comments
 (0)