Skip to content

Commit

Permalink
Merge pull request #283 from myii/myii-patch-1
Browse files Browse the repository at this point in the history
Improve consistency of reset value handling for `date`
  • Loading branch information
camilonova authored May 12, 2018
2 parents df30bcd + c9916c7 commit fd7c4e8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions constance/static/admin/js/constance.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@

if (fieldType === 'checkbox') {
field.prop('checked', this.dataset.default === 'true');
} else if (fieldType === 'date') {
var defaultDate = new Date(this.dataset.default * 1000);
$('#' + this.dataset.fieldId).val(defaultDate.strftime(get_format('DATE_INPUT_FORMATS')[0]));}
} else if (fieldType === 'datetime') {
var defaultDate = new Date(this.dataset.default * 1000);
$('#' + this.dataset.fieldId + '_0').val(defaultDate.strftime(get_format('DATE_INPUT_FORMATS')[0]));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@
data-field-id="{{ item.form_field.auto_id }}"
data-field-type="{% spaceless %}
{% if item.is_checkbox %}checkbox
{% elif item.is_date %}date
{% elif item.is_datetime %}datetime
{% endif %}
{% endspaceless %}"
data-default="{% spaceless %}
{% if item.is_checkbox %}{% if item.raw_default %} true {% else %} false {% endif %}
{% elif item.is_date %}{{ item.raw_default|date:"U" }}
{% elif item.is_datetime %}{{ item.raw_default|date:"U" }}
{% elif item.is_date %}{{ item.raw_default.isoformat }}
{% else %}{{ item.default }}
{% endif %}
{% endspaceless %}">{% trans "Reset to default" %}</a>
Expand Down

0 comments on commit fd7c4e8

Please sign in to comment.