diff options
| author | Terry Truong <terry06890@gmail.com> | 2023-01-06 02:32:59 +1100 |
|---|---|---|
| committer | Terry Truong <terry06890@gmail.com> | 2023-01-06 02:45:26 +1100 |
| commit | 559902e0211a06b349c4c2f50b0882a8d314f8b7 (patch) | |
| tree | ecdfcb0983454044ecb28ca8f8f4d781b1124047 /src/lib.ts | |
| parent | 442c0bbffc5c372c7ec3510914968f75ab6e4a4f (diff) | |
Jump to and highlight search results
Use a 'searchTarget' prop of Timeline to trigger jumping to a search result.
Make TimeLine prioritise search result in layout.
When querying for events in App, check for a search target, and use incl= to retrieve it.
On server, for the incl= query param, don't include the event if outside specified range.
Diffstat (limited to 'src/lib.ts')
| -rw-r--r-- | src/lib.ts | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -565,6 +565,21 @@ export function dateToUnit(date: HistDate, scale: number): number { } } } +export function dateToScaleDate(date: HistDate, scale: number): HistDate { + // Returns a date representing the unit on 'scale' that 'date' is within + if (scale == DAY_SCALE){ + return new CalDate(date.year, date.month, date.day); + } else if (scale == MONTH_SCALE){ + return new CalDate(date.year, date.month, 1); + } else { + const year = Math.floor(date.year / scale) * scale; + if (year < MIN_CAL_YEAR){ + return new YearDate(year); + } else { + return new CalDate(year == 0 ? 1 : year, 1, 1); + } + } +} // For sending timeline-bound data to BaseLine export class TimelineState { |
