Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes couple of Flatpickr related issues #495

Merged
merged 3 commits into from
Dec 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ All notable changes to this project will be documented in this file.
- Fix URL decoding in query parameters plausible/analytics#416
- Fix overly-sticky date in query parameters plausible/analytics/#439
- Prevent picking dates before site insertion plausible/analtics#446
- Fix overly-sticky from and to in query parameters plausible/analytics#495
- Adds support for single-day date selection plausible/analytics#495

### Security
- Do not run the plausible Docker container as root plausible/analytics#362
Expand Down
33 changes: 23 additions & 10 deletions assets/js/dashboard/datepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,16 +223,29 @@ class DatePicker extends React.Component {
setCustomDate(dates) {
if (dates.length === 2) {
const [from, to] = dates
navigateToQuery(
this.props.history,
this.props.query,
{
period: 'custom',
date: false,
from: formatISO(from),
to: formatISO(to),
}
)
if (formatISO(from) === formatISO(to)) {
navigateToQuery(
this.props.history,
this.props.query,
{
period: 'day',
date: formatISO(from),
from: false,
to: false,
}
)
} else {
navigateToQuery(
this.props.history,
this.props.query,
{
period: 'custom',
date: false,
from: formatISO(from),
to: formatISO(to),
}
)
}
this.close()
}
}
Expand Down
2 changes: 2 additions & 0 deletions assets/js/dashboard/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ export function parseQuery(querystring, site) {
function generateQueryString(data) {
const query = new URLSearchParams(window.location.search)
query.delete("date");
query.delete("from");
query.delete("to");
Object.keys(data).forEach(key => {
if (!data[key]) {
query.delete(key)
Expand Down