[Fixes] Defaults and User-Permission based fixes in treeview (#14501)
* utility function added for treeview function to distinguish defaults from user permission and return appropriate data * make use of utility function for treeview
This commit is contained in:
@@ -182,6 +182,25 @@ $.extend(erpnext.utils, {
|
||||
}
|
||||
return rows;
|
||||
},
|
||||
get_tree_options: function(option) {
|
||||
// get valid options for tree based on user permission & locals dict
|
||||
let unscrub_option = frappe.model.unscrub(option);
|
||||
let user_permission = frappe.defaults.get_user_permissions();
|
||||
if(user_permission && user_permission[unscrub_option]) {
|
||||
return user_permission[unscrub_option]["docs"];
|
||||
} else {
|
||||
return $.map(locals[`:${unscrub_option}`], function(c) { return c.name; }).sort();
|
||||
}
|
||||
},
|
||||
get_tree_default: function(option) {
|
||||
// set default for a field based on user permission
|
||||
let options = this.get_tree_options(option);
|
||||
if(options.includes(frappe.defaults.get_default(option))) {
|
||||
return frappe.defaults.get_default(option);
|
||||
} else {
|
||||
return options[0];
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
erpnext.utils.select_alternate_items = function(opts) {
|
||||
|
||||
Reference in New Issue
Block a user