kopia lustrzana https://github.com/wagtail/wagtail
Revise the human_readable_date arg (rename position to placement)
- Add unit tests
- Move changelog entry to features, not maintenance
- See #10871 & 0a977cc54d
pull/10869/head
rodzic
51df7b51d0
commit
e317ac482b
|
@ -25,6 +25,7 @@ Changelog
|
|||
* When adding a panel within `InlinePanel`, focus will now shift to that content similar to `StreamField` (Faishal Manzar)
|
||||
* Show the full first published at date within a tooltip on the Page status sidebar on the relative date (Rohit Sharma)
|
||||
* Extract generic breadcrumbs functionality from page breadcrumbs (Sage Abdullah)
|
||||
* Add support for `placement` in the `human_readable_date` tooltip template tag (Rohit Sharma)
|
||||
* Fix: Ensure that StreamField's `FieldBlock`s correctly set the `required` and `aria-describedby` attributes (Storm Heg)
|
||||
* Fix: Avoid an error when the moderation panel (admin dashboard) contains both snippets and private pages (Matt Westcott)
|
||||
* Fix: When deleting collections, ensure the collection name is correctly shown in the success message (LB (Ben) Johnston)
|
||||
|
@ -47,7 +48,6 @@ Changelog
|
|||
* Maintenance: Migrate form submission listing checkbox toggling to the shared `w-bulk` Stimulus implementation (LB (Ben) Johnston)
|
||||
* Maintenance: Allow viewsets to define a common set of view kwargs (Matt Westcott)
|
||||
* Maintenance: Migrate the editor unsaved messages popup to be driven by Stimulus using the shared `w-message` controller (LB (Ben) Johnston, Hussain Saherwala)
|
||||
* Maintenance: Add support for tooltip position in `human_readable_date` tooltip (Rohit Sharma)
|
||||
* Maintenance: Do not use jest inside `stubs.js` to prevent Storybook from crashing (LB (Ben) Johnston)
|
||||
* Maintenance: Refactor snippets templates to reuse the shared `slim_header.html` template (Sage Abdullah)
|
||||
* Maintenance: Refactor `slim_header.html` template to reduce code duplication (Sage Abdullah)
|
||||
|
|
|
@ -35,6 +35,7 @@ depth: 1
|
|||
* When adding a panel within `InlinePanel`, focus will now shift to that content similar to `StreamField` (Faishal Manzar)
|
||||
* Show the full first published at date within a tooltip on the Page status sidebar on the relative date (Rohit Sharma)
|
||||
* Extract generic breadcrumbs functionality from page breadcrumbs (Sage Abdullah)
|
||||
* Add support for `placement` in `human_readable_date` the tooltip template tag (Rohit Sharma)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
|
@ -66,7 +67,6 @@ depth: 1
|
|||
* Migrate form submission listing checkbox toggling to the shared `w-bulk` Stimulus implementation (LB (Ben) Johnston)
|
||||
* Allow viewsets to define a common set of view kwargs (Matt Westcott)
|
||||
* Migrate the editor unsaved messages popup to be driven by Stimulus using the shared `w-message` controller (LB (Ben) Johnston, Hussain Saherwala)
|
||||
* Add support for tooltip position in `human_readable_date` tooltip (Rohit Sharma)
|
||||
* Do not use jest inside `stubs.js` to prevent Storybook from crashing (LB (Ben) Johnston)
|
||||
* Refactor snippets templates to reuse the shared `slim_header.html` template (Sage Abdullah)
|
||||
* Refactor `slim_header.html` template to reduce code duplication (Sage Abdullah)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{% load wagtailadmin_tags i18n %}
|
||||
|
||||
<button type="button" class="w-human-readable-date" data-tippy-content="{{ date|date:"DATETIME_FORMAT" }}" data-tippy-placement="{{ position }}">
|
||||
<button type="button" class="w-human-readable-date" data-tippy-content="{{ date|date:"DATETIME_FORMAT" }}" data-tippy-placement="{{ placement }}">
|
||||
<time class="w-human-readable-date__date" datetime="{{ date|date:"c" }}">
|
||||
{{ date|timesince_simple|capfirst }}
|
||||
</time>
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
</div>
|
||||
{% if object.first_published_at %}
|
||||
<div class="w-help-text">
|
||||
{% trans 'First published' %} {% human_readable_date object.first_published_at position="bottom" %}
|
||||
{% trans 'First published' %} {% human_readable_date object.first_published_at placement="bottom" %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
|
|
@ -1201,9 +1201,9 @@ def workflow_status_with_date(workflow_state):
|
|||
|
||||
|
||||
@register.inclusion_tag("wagtailadmin/shared/human_readable_date.html")
|
||||
def human_readable_date(date, description=None, position="top"):
|
||||
def human_readable_date(date, description=None, placement="top"):
|
||||
return {
|
||||
"date": date,
|
||||
"description": description,
|
||||
"position": position,
|
||||
"placement": placement,
|
||||
}
|
||||
|
|
|
@ -206,6 +206,21 @@ class TestTimesinceTags(SimpleTestCase):
|
|||
Context({"date": now - timedelta(hours=1, minutes=10)})
|
||||
)
|
||||
self.assertIn("1\xa0hour ago", html)
|
||||
self.assertIn('data-tippy-placement="top"', html)
|
||||
|
||||
def test_human_readable_date_with_args(self):
|
||||
now = timezone.now()
|
||||
template = """
|
||||
{% load wagtailadmin_tags %}
|
||||
{% human_readable_date date "The clock ticked" "bottom" %}
|
||||
"""
|
||||
|
||||
html = Template(template).render(Context({"date": now}))
|
||||
self.assertIn(
|
||||
'<span class="w-human-readable-date__description">The clock ticked</span>',
|
||||
html,
|
||||
)
|
||||
self.assertIn('data-tippy-placement="bottom"', html)
|
||||
|
||||
|
||||
class TestComponentTag(SimpleTestCase):
|
||||
|
|
Ładowanie…
Reference in New Issue