fix: use is_public and don't set as hidden
This commit is contained in:
parent
785593681b
commit
9c7763ee21
10 changed files with 34 additions and 42 deletions
|
|
@ -8,7 +8,7 @@ frappe.ui.form.on('Dashboard', {
|
|||
frm.set_query("chart", "charts", function() {
|
||||
return {
|
||||
filters: {
|
||||
is_standard: 1
|
||||
is_public: 1
|
||||
}
|
||||
};
|
||||
});
|
||||
|
|
@ -16,7 +16,7 @@ frappe.ui.form.on('Dashboard', {
|
|||
frm.set_query("card", "cards", function() {
|
||||
return {
|
||||
filters: {
|
||||
is_standard: 1
|
||||
is_public: 1
|
||||
}
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -9,11 +9,6 @@ frappe.ui.form.on('Dashboard Chart', {
|
|||
frm.add_fetch('source', 'timeseries', 'timeseries');
|
||||
},
|
||||
|
||||
before_save: function(frm) {
|
||||
if (frm.is_new() && (frappe.user.has_role('System Manager') || frappe.user.has_role('Dashboard Manager'))) {
|
||||
frm.doc.is_standard = 1;
|
||||
}
|
||||
},
|
||||
|
||||
refresh: function(frm) {
|
||||
frm.chart_filters = null;
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
"aggregate_function_based_on",
|
||||
"number_of_groups",
|
||||
"column_break_6",
|
||||
"is_public",
|
||||
"timespan",
|
||||
"from_date",
|
||||
"to_date",
|
||||
|
|
@ -35,8 +36,7 @@
|
|||
"color",
|
||||
"custom_options",
|
||||
"section_break_10",
|
||||
"last_synced_on",
|
||||
"is_standard"
|
||||
"last_synced_on"
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
|
|
@ -100,7 +100,7 @@
|
|||
},
|
||||
{
|
||||
"default": "0",
|
||||
"depends_on": "eval:doc.chart_type !== 'Group By'",
|
||||
"depends_on": "eval: ['Count', 'Sum', 'Average'].includes(doc.chart_type)",
|
||||
"fieldname": "timeseries",
|
||||
"fieldtype": "Check",
|
||||
"label": "Time Series"
|
||||
|
|
@ -224,15 +224,15 @@
|
|||
},
|
||||
{
|
||||
"default": "0",
|
||||
"fieldname": "is_standard",
|
||||
"description": "This chart will be public to all Users if this is set",
|
||||
"fieldname": "is_public",
|
||||
"fieldtype": "Check",
|
||||
"hidden": 1,
|
||||
"label": "Is Standard",
|
||||
"label": "Is Public",
|
||||
"permlevel": 1
|
||||
}
|
||||
],
|
||||
"links": [],
|
||||
"modified": "2020-04-17 18:11:33.486037",
|
||||
"modified": "2020-04-23 13:01:07.178866",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Desk",
|
||||
"name": "Dashboard Chart",
|
||||
|
|
@ -263,6 +263,7 @@
|
|||
"write": 1
|
||||
},
|
||||
{
|
||||
"create": 1,
|
||||
"email": 1,
|
||||
"export": 1,
|
||||
"print": 1,
|
||||
|
|
|
|||
|
|
@ -96,8 +96,6 @@ def create_dashboard_chart(args):
|
|||
args = frappe.parse_json(args)
|
||||
doc = frappe.new_doc('Dashboard Chart')
|
||||
roles = frappe.get_roles(frappe.session.user)
|
||||
if 'Sytem Manager' in roles or 'Dashboard Manager' in roles:
|
||||
doc.is_standard = 1
|
||||
|
||||
doc.update(args)
|
||||
|
||||
|
|
@ -364,6 +362,13 @@ def get_year_ending(date):
|
|||
# last day of this month
|
||||
return add_to_date(date, days=-1)
|
||||
|
||||
def get_charts_for_user(doctype, txt, searchfield, start, page_len, filters):
|
||||
or_filters = {'owner': frappe.session.user, 'is_public': 1}
|
||||
return frappe.db.get_list('Dashboard Chart',
|
||||
fields=['name'],
|
||||
filters=filters,
|
||||
or_filters=or_filters,
|
||||
as_list = 1)
|
||||
|
||||
class DashboardChart(Document):
|
||||
|
||||
|
|
|
|||
|
|
@ -8,12 +8,6 @@ frappe.ui.form.on('Number Card', {
|
|||
frm.trigger('render_filters_table');
|
||||
},
|
||||
|
||||
before_save: function(frm) {
|
||||
if (frm.is_new() && (frappe.user.has_role('System Manager') || frappe.user.has_role('Dashboard Manager'))) {
|
||||
frm.doc.is_standard = 1;
|
||||
}
|
||||
},
|
||||
|
||||
document_type: function(frm) {
|
||||
frm.set_query('document_type', function() {
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -9,12 +9,12 @@
|
|||
"label",
|
||||
"function",
|
||||
"column_break_2",
|
||||
"is_public",
|
||||
"document_type",
|
||||
"aggregate_function_based_on",
|
||||
"filters_section",
|
||||
"filters_json",
|
||||
"color",
|
||||
"is_standard"
|
||||
"color"
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
|
|
@ -58,14 +58,6 @@
|
|||
"fieldtype": "Color",
|
||||
"label": "Color"
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"fieldname": "is_standard",
|
||||
"fieldtype": "Check",
|
||||
"hidden": 1,
|
||||
"label": "Is Standard",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break_2",
|
||||
"fieldtype": "Column Break"
|
||||
|
|
@ -74,10 +66,18 @@
|
|||
"fieldname": "filters_section",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Filters Section"
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"description": "This card will be public to all Users if this is set",
|
||||
"fieldname": "is_public",
|
||||
"fieldtype": "Check",
|
||||
"label": "Is Public",
|
||||
"permlevel": 1
|
||||
}
|
||||
],
|
||||
"links": [],
|
||||
"modified": "2020-04-18 14:12:06.949445",
|
||||
"modified": "2020-04-23 13:03:57.103284",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Desk",
|
||||
"name": "Number Card",
|
||||
|
|
|
|||
|
|
@ -73,14 +73,13 @@ def create_number_card(args):
|
|||
args = frappe.parse_json(args)
|
||||
doc = frappe.new_doc('Number Card')
|
||||
roles = frappe.get_roles(frappe.session.user)
|
||||
if 'Sytem Manager' in roles or 'Dashboard Manager' in roles:
|
||||
doc.is_standard = 1
|
||||
|
||||
doc.update(args)
|
||||
doc.insert(ignore_permissions=True)
|
||||
return doc
|
||||
|
||||
def get_cards_for_user(doctype, txt, searchfield, start, page_len, filters):
|
||||
or_filters = {'owner': frappe.session.user, 'is_standard': 1}
|
||||
or_filters = {'owner': frappe.session.user, 'is_public': 1}
|
||||
return frappe.db.get_list('Number Card',
|
||||
fields=['name', 'label'],
|
||||
filters=filters,
|
||||
|
|
|
|||
|
|
@ -273,4 +273,4 @@ execute:frappe.delete_doc_if_exists('DocType', 'GCalendar Settings')
|
|||
frappe.patches.v12_0.remove_parent_and_parenttype_from_print_formats
|
||||
execute:from frappe.desk.page.setup_wizard.install_fixtures import update_genders;update_genders()
|
||||
frappe.patches.v13_0.website_theme_custom_scss
|
||||
frappe.patches.v13_0.set_existing_dashboard_charts_as_standard
|
||||
frappe.patches.v13_0.set_existing_dashboard_charts_as_public
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ def execute():
|
|||
UPDATE
|
||||
`tabDashboard Chart`
|
||||
SET
|
||||
`tabDashboard Chart`.`is_standard`=1
|
||||
`tabDashboard Chart`.`is_public`=1
|
||||
WHERE
|
||||
`tabDashboard Chart`.owner in {users}
|
||||
""".format(users=users)
|
||||
|
|
@ -71,14 +71,12 @@ frappe.views.DashboardView = class DashboardView extends frappe.views.ListView {
|
|||
{
|
||||
chart_type: ['in', ['Count', 'Sum', 'Group By']],
|
||||
document_type: this.doctype,
|
||||
is_standard: true
|
||||
},
|
||||
'charts'
|
||||
),
|
||||
() => this.fetch_dashboard_items('Number Card',
|
||||
{
|
||||
document_type: this.doctype,
|
||||
is_standard: true
|
||||
},
|
||||
'number_cards'
|
||||
),
|
||||
|
|
@ -258,9 +256,9 @@ frappe.views.DashboardView = class DashboardView extends frappe.views.ListView {
|
|||
fieldtype: 'Link',
|
||||
get_query: () => {
|
||||
return {
|
||||
'query': 'frappe.desk.doctype.dashboard_chart.dashboard_chart.get_charts_for_user',
|
||||
filters: {
|
||||
document_type: this.doctype,
|
||||
is_standard: 1,
|
||||
document_type: this.doctype,
|
||||
}
|
||||
};
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue