1
0
Fork 0
mirror of synced 2024-06-02 02:25:17 +12:00

Add default setting to date range picker and add info text

This commit is contained in:
Andrew Kingston 2021-06-02 08:38:19 +01:00
parent c67dc0b439
commit 32d76ea9b1
2 changed files with 17 additions and 2 deletions

View file

@ -1511,6 +1511,7 @@
"icon": "Date",
"styleable": true,
"hasChildren": false,
"info": "Your data provider will be automatically filtered to the given date range.",
"settings": [
{
"type": "dataProvider",
@ -1521,6 +1522,20 @@
"type": "field",
"label": "Date field",
"key": "field"
},
{
"type": "select",
"label": "Default range",
"key": "defaultValue",
"options": [
"Last 1 day",
"Last 7 days",
"Last 30 days",
"Last 3 months",
"Last 6 months",
"Last 1 year"
],
"defaultValue": "Last 30 days"
}
]
}

View file

@ -9,12 +9,11 @@
export let dataProvider
export let field
export let defaultValue
const dataContext = getContext("context")
const component = getContext("component")
const { styleable, builderStore, ActionTypes } = getContext("sdk")
let value = "Last 30 days"
const options = [
"Last 1 day",
"Last 7 days",
@ -23,6 +22,7 @@
"Last 6 months",
"Last 1 year",
]
let value = options.includes(defaultValue) ? defaultValue : "Last 30 days"
const updateDateRange = option => {
const query = dataProvider?.state?.query