1
0
Fork 0
mirror of synced 2024-07-05 06:20:55 +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 bb7947bb94
commit 1a59f9c8ac
2 changed files with 17 additions and 2 deletions

View file

@ -1511,6 +1511,7 @@
"icon": "Date", "icon": "Date",
"styleable": true, "styleable": true,
"hasChildren": false, "hasChildren": false,
"info": "Your data provider will be automatically filtered to the given date range.",
"settings": [ "settings": [
{ {
"type": "dataProvider", "type": "dataProvider",
@ -1521,6 +1522,20 @@
"type": "field", "type": "field",
"label": "Date field", "label": "Date field",
"key": "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 dataProvider
export let field export let field
export let defaultValue
const dataContext = getContext("context") const dataContext = getContext("context")
const component = getContext("component") const component = getContext("component")
const { styleable, builderStore, ActionTypes } = getContext("sdk") const { styleable, builderStore, ActionTypes } = getContext("sdk")
let value = "Last 30 days"
const options = [ const options = [
"Last 1 day", "Last 1 day",
"Last 7 days", "Last 7 days",
@ -23,6 +22,7 @@
"Last 6 months", "Last 6 months",
"Last 1 year", "Last 1 year",
] ]
let value = options.includes(defaultValue) ? defaultValue : "Last 30 days"
const updateDateRange = option => { const updateDateRange = option => {
const query = dataProvider?.state?.query const query = dataProvider?.state?.query