mirror of
https://github.com/enso-org/enso.git
synced 2024-12-19 04:01:46 +03:00
Add date support for filter drilldown (#11626)
![filter-drilldown-date](https://github.com/user-attachments/assets/9574a172-95af-41c6-aef1-a586ee6cda98) ![filter-drilldown-time](https://github.com/user-attachments/assets/9fd5c3f0-0594-4d9c-8c00-c9616ae997be) Date Time using Date_Time.parse ![date-drilldown-date-time-1](https://github.com/user-attachments/assets/9960cdba-8f13-4f72-9c11-b681ae63e988) ![date-drilldown-date-time-2](https://github.com/user-attachments/assets/caaeb53d-8d2e-4332-aaa4-3d3e210a0893)
This commit is contained in:
parent
2e6d4b2695
commit
008a7fb85e
@ -616,6 +616,26 @@ const getColumnValueToEnso = (columnName: string) => {
|
||||
if (isNumber.indexOf(columnType) != -1) {
|
||||
return (item: string, module: Ast.MutableModule) => Ast.tryNumberToEnso(Number(item), module)!
|
||||
}
|
||||
const createDateTimePattern = (pattern: string, numberOfParts: number) => {
|
||||
const dateOrTimePattern = Pattern.parseExpression(pattern)
|
||||
return (item: string, module: Ast.MutableModule) => {
|
||||
const dateTimeParts = item.match(/\d+/g)!.map(Number)
|
||||
const dateTimePartsNumeric = []
|
||||
for (let i = 0; i < numberOfParts; i++) {
|
||||
dateTimePartsNumeric.push(Ast.tryNumberToEnso(Number(dateTimeParts[i] ?? 0), module)!)
|
||||
}
|
||||
return dateOrTimePattern.instantiateCopied(dateTimePartsNumeric)
|
||||
}
|
||||
}
|
||||
if (columnType === 'Date') {
|
||||
return createDateTimePattern('(Date.new __ __ __)', 3)
|
||||
}
|
||||
if (columnType === 'Time') {
|
||||
return createDateTimePattern('(Time_Of_Day.new __ __ __ __ __ __)', 6)
|
||||
}
|
||||
if (columnType === 'Date_Time') {
|
||||
return (item: string) => Ast.parseExpression(`(Date_Time.parse '${item}')`)!
|
||||
}
|
||||
return (item: string) => Ast.TextLiteral.new(item)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user