Skip to content

Commit

Permalink
[#1635] Tweaked the edit profile form notifications email checkbox
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmartin committed Dec 18, 2012
1 parent ba4d6df commit 503cb9a
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 9 deletions.
7 changes: 7 additions & 0 deletions ckan/public/base/less/forms.less
Expand Up @@ -143,6 +143,13 @@ textarea {
margin-top: 6px;
}

.form-horizontal .info-help {
padding: 6px 0;
}
.form-horizontal .info-help-tight {
margin-top: -10px;
}

.form-horizontal .info-inline {
float: right;
width: 265px;
Expand Down
22 changes: 22 additions & 0 deletions ckan/templates/macros/form.html
Expand Up @@ -309,6 +309,28 @@
{%- endif -%}
{% endmacro %}

{#
Renders an small help box with a description. This will usually be used
with in a call block when creating an input element.

text - The text to include as a helper.
inline - If true displays the info box inline with the input.
classes - A list of classes to add to the info box.

Example

{% import 'macros/form.html' as form %}
{% call form.input('name') %}
{{ form.help(_('A little bit of text describing the input')) }}
{% endcall %}

#}
{% macro help(text='', inline=false, classes=[]) %}
{%- if text -%}
<div class="info-block info-help{{ " " ~ classes | join(' ') }}">{{ text }}</div>
{%- endif -%}
{% endmacro %}

{#
Builds a space seperated list of html attributes from a dict of key/value pairs.
Generally only used internally by macros.
Expand Down
16 changes: 7 additions & 9 deletions ckan/templates/user/edit_user_form.html
Expand Up @@ -13,6 +13,13 @@
{{ form.input('email', label=_('Email'), id='field-email', type='email', value=data.email, error=errors.email, placeholder=_('eg. joe@example.com'), classes=['control-medium']) }}

{{ form.markdown('about', label=_('About'), id='field-about', value=data.about, error=errors.about, placeholder=_('A little information about yourself')) }}

{% if c.show_email_notifications %}
{% call form.checkbox('email_notifications', label=_('Subscribe to activity notification emails'), id='field-email-notifications', value=True, checked=c.userobj.email_notifications) %}
{{ form.help(_('Whenever there\'s a new activity on the site related to a thing that you follow you\'ll get a notification email'), classes=['info-help-tight']) }}
{% endcall %}
{% endif %}

</fieldset>

<fieldset>
Expand All @@ -23,15 +30,6 @@
{{ form.input('password2', label=_('Confirm Password'), id='field-password-confirm', value=data.password2, error=errors.password2, classes=['control-medium']) }}
</fieldset>

{% if c.show_email_notifications %}
<fieldset>
<legend>{{ _('Change your preferences') }}</legend>

{{ form.checkbox('email_notifications', label=_('Email Notifications'), id='field-email-notifications', value=True, checked=c.userobj.email_notifications, classes=['control-medium']) }}

</fieldset>
{% endif %}

<div class="form-actions">
<button class="btn btn-primary" type="submit" name="save">{{ _('Update Profile') }}</button>
</div>
Expand Down

0 comments on commit 503cb9a

Please sign in to comment.