Skip to content

Add date range filter with sidebar layout to audit log index#87

Draft
Copilot wants to merge 5 commits into
chore/craft5-supportfrom
copilot/add-date-range-filter
Draft

Add date range filter with sidebar layout to audit log index#87
Copilot wants to merge 5 commits into
chore/craft5-supportfrom
copilot/add-date-range-filter

Conversation

Copy link
Copy Markdown

Copilot AI commented Jan 11, 2026

Adds start/end date filtering to the audit log index page using Craft CMS's standard element index layout pattern with filters in a left sidebar.

Changes

Controller (DefaultController.php)

  • Accept startDate and endDate query parameters
  • Validate dates match Y-m-d format before applying to query
  • Set start date to 00:00:00 and end date to 23:59:59 for full-day coverage
  • Pass filter values to template for state persistence

Template (index.twig)

  • Add sidebar block with filter form using Craft's forms.dateField() macro
  • Submit via GET to preserve filter state in URL
  • Include clear button to reset filters

JavaScript (Index.js)

  • Clear filter button clears inputs and redirects to base URL
  • Null-safe element access

CSS (Index.css)

  • Style filter form with flexbox button layout

Tests (DateRangeFilterTest.php)

  • Verify start date, end date, and combined range filtering

Example Usage

// Filter logs from Jan 1 onward
GET /admin/audit?startDate=2024-01-01

// Filter logs up to Jan 31
GET /admin/audit?endDate=2024-01-31

// Filter logs within January
GET /admin/audit?startDate=2024-01-01&endDate=2024-01-31

Backward compatible - works without query parameters to show all logs.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • asset-packagist.org
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/lD8aGg /usr/bin/composer install --no-interaction (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>[PLU-20] Add date range filter</issue_title>
<issue_description>null

PLU-20</issue_description>

<agent_instructions>if possible, re-use the element index layout where the filters are on the left. hopefully we can reuse the html of theirs but implement our own js.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Add date range filter to the application Add date range filter with sidebar layout to audit log index Jan 11, 2026
Copilot AI requested a review from sjelfull January 11, 2026 22:33
sjelfull and others added 5 commits February 5, 2026 20:41
* chore: wip add snapshot json output

Signed-off-by: Fred Carlsen <fred@sjelfull.no>

* chore: add code analysis

Signed-off-by: Fred Carlsen <fred@sjelfull.no>

* chore: cleanup with ecs

Signed-off-by: Fred Carlsen <fred@sjelfull.no>

* chore: formatting + deps

Signed-off-by: Fred Carlsen <fred@sjelfull.no>

* refactor: misc fixes + refactoring

Signed-off-by: Fred Carlsen <fred@sjelfull.no>

* feat: add tests

Signed-off-by: Fred Carlsen <fred@sjelfull.no>

* fix: fix ecs issues

Signed-off-by: Fred Carlsen <fred@sjelfull.no>

* fix: fix phpstan issues

Signed-off-by: Fred Carlsen <fred@sjelfull.no>

* fix: param not null

Signed-off-by: Fred Carlsen <fred@sjelfull.no>

* fix: fix postgres incompat + add indexes

fixes #70

Signed-off-by: Fred Carlsen <fred@sjelfull.no>

* fixup! fix: fix postgres incompat + add indexes

Signed-off-by: Fred Carlsen <fred@sjelfull.no>

* feat: new events

Signed-off-by: Fred Carlsen <fred@sjelfull.no>

* fix: PHPStan error and composer version for Craft 5

* fix: sort use statements alphabetically (ECS)

* fix: remove version field from composer.json (strict validation)

* fix: correct import ordering by namespace (ECS)

* fix: update test fixture schema version to Craft 5.9

* fix: update tests to expect entry-specific event names

* fix: update tests to expect *_CREATED events when isNew=true

* fix: update field snapshot test to expect FIELD_CREATED event

---------

Signed-off-by: Fred Carlsen <fred@sjelfull.no>
Co-authored-by: mason <mason@craft-audit.dev>
Co-authored-by: sjelfull <10508+sjelfull@users.noreply.github.com>
Co-authored-by: sjelfull <10508+sjelfull@users.noreply.github.com>
Co-authored-by: sjelfull <10508+sjelfull@users.noreply.github.com>
- Change padding from 14px to 24px (Craft's --xl spacing)
- Change field/button margins to 24px for consistency
- Replace <nav> with <div> (semantic fix - it's a filter form, not navigation)

Co-authored-by: mason
@sjelfull sjelfull force-pushed the copilot/add-date-range-filter branch from 9faf330 to 2085be1 Compare February 6, 2026 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants