feat: allow date range to be selected as timespan
This commit is contained in:
parent
558630486c
commit
08da73cddf
3 changed files with 20 additions and 3 deletions
|
|
@ -40,6 +40,7 @@ frappe.ui.form.on('Dashboard Chart', {
|
|||
|
||||
timespan: function(frm) {
|
||||
const time_interval_options = {
|
||||
"Select Date Range": ["Quarterly", "Monthly", "Weekly", "Daily"],
|
||||
"Last Year": ["Quarterly", "Monthly", "Weekly", "Daily"],
|
||||
"Last Quarter": ["Monthly", "Weekly", "Daily"],
|
||||
"Last Month": ["Weekly", "Daily"],
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@
|
|||
"number_of_groups",
|
||||
"column_break_6",
|
||||
"timespan",
|
||||
"from_date",
|
||||
"to_date",
|
||||
"time_interval",
|
||||
"timeseries",
|
||||
"filters_section",
|
||||
|
|
@ -80,7 +82,7 @@
|
|||
"fieldname": "timespan",
|
||||
"fieldtype": "Select",
|
||||
"label": "Timespan",
|
||||
"options": "Last Year\nLast Quarter\nLast Month\nLast Week"
|
||||
"options": "Last Year\nLast Quarter\nLast Month\nLast Week\nSelect Date Range"
|
||||
},
|
||||
{
|
||||
"depends_on": "timeseries",
|
||||
|
|
@ -171,9 +173,21 @@
|
|||
"fieldname": "number_of_groups",
|
||||
"fieldtype": "Int",
|
||||
"label": "Number of Groups"
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:doc.timespan === 'Choose Time Span'",
|
||||
"fieldname": "from_date",
|
||||
"fieldtype": "Date",
|
||||
"label": "From Date"
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:doc.timespan === 'Choose Time Span'",
|
||||
"fieldname": "to_date",
|
||||
"fieldtype": "Date",
|
||||
"label": "To Date"
|
||||
}
|
||||
],
|
||||
"modified": "2019-10-11 16:11:17.051669",
|
||||
"modified": "2019-10-29 02:26:14.838057",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Desk",
|
||||
"name": "Dashboard Chart",
|
||||
|
|
|
|||
|
|
@ -12,13 +12,15 @@ from frappe.model.document import Document
|
|||
|
||||
@frappe.whitelist()
|
||||
@cache_source
|
||||
def get(chart_name = None, chart = None, no_cache = None, from_date=None, to_date=None, refresh = None):
|
||||
def get(chart_name = None, chart = None, no_cache = None, from_date = None, to_date = None, refresh = None):
|
||||
if chart_name:
|
||||
chart = frappe.get_doc('Dashboard Chart', chart_name)
|
||||
else:
|
||||
chart = frappe._dict(frappe.parse_json(chart))
|
||||
|
||||
timespan = chart.timespan
|
||||
from_date = chart.from_date
|
||||
to_date = chart.to_date
|
||||
timegrain = chart.time_interval
|
||||
filters = frappe.parse_json(chart.filters_json)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue