fix: only show public and user's private blocks in dropdown
This commit is contained in:
parent
07781eefe9
commit
474186c264
2 changed files with 22 additions and 1 deletions
|
|
@ -1,9 +1,25 @@
|
|||
# Copyright (c) 2023, Frappe Technologies and contributors
|
||||
# For license information, please see license.txt
|
||||
|
||||
# import frappe
|
||||
import frappe
|
||||
from frappe.model.document import Document
|
||||
from frappe.query_builder.utils import DocType
|
||||
|
||||
|
||||
class CustomHTMLBlock(Document):
|
||||
pass
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_custom_blocks_for_user(doctype, txt, searchfield, start, page_len, filters):
|
||||
# return logged in users private blocks and all public blocks
|
||||
customHTMLBlock = DocType("Custom HTML Block")
|
||||
|
||||
condition_query = frappe.qb.get_query(customHTMLBlock)
|
||||
|
||||
return (
|
||||
condition_query.select(customHTMLBlock.name).where(
|
||||
(customHTMLBlock.private == 0)
|
||||
| ((customHTMLBlock.owner == frappe.session.user) & (customHTMLBlock.private == 1))
|
||||
)
|
||||
).run()
|
||||
|
|
|
|||
|
|
@ -715,6 +715,11 @@ class CustomBlockDialog extends WidgetDialog {
|
|||
label: "Custom Block Name",
|
||||
options: "Custom HTML Block",
|
||||
reqd: 1,
|
||||
get_query: () => {
|
||||
return {
|
||||
query: "frappe.desk.doctype.custom_html_block.custom_html_block.get_custom_blocks_for_user",
|
||||
};
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue