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 bb7947bb94
commit 1a59f9c8ac
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