|
|
@@ -113,42 +113,44 @@ frappe.ui.SortSelector = class SortSelector { |
|
|
|
if(!this.args.options) { |
|
|
|
// default options |
|
|
|
var _options = [ |
|
|
|
{'fieldname': 'modified'} |
|
|
|
{'fieldname': 'modified'}, |
|
|
|
{'fieldname': 'name'}, |
|
|
|
{'fieldname': 'creation'}, |
|
|
|
{'fieldname': 'idx'}, |
|
|
|
] |
|
|
|
|
|
|
|
// title field |
|
|
|
if(meta.title_field) { |
|
|
|
_options.push({'fieldname': meta.title_field}); |
|
|
|
if (meta.title_field) { |
|
|
|
_options.splice(1, 0, {'fieldname': meta.title_field}); |
|
|
|
} |
|
|
|
|
|
|
|
// sort field - set via DocType schema or Customize Form |
|
|
|
if (meta_sort_field) { |
|
|
|
_options.splice(1, 0, { 'fieldname': meta_sort_field }); |
|
|
|
} |
|
|
|
|
|
|
|
// bold or mandatory |
|
|
|
// bold, mandatory and fields that are available in list view |
|
|
|
meta.fields.forEach(function(df) { |
|
|
|
if(df.mandatory || df.bold) { |
|
|
|
if ( |
|
|
|
(df.mandatory || df.bold || df.in_list_view) |
|
|
|
&& frappe.model.is_value_type(df.fieldtype) |
|
|
|
&& frappe.perm.has_perm(me.doctype, df.permlevel, "read") |
|
|
|
) { |
|
|
|
_options.push({fieldname: df.fieldname, label: df.label}); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
// meta sort field |
|
|
|
if(meta_sort_field) _options.push({ 'fieldname': meta_sort_field }); |
|
|
|
|
|
|
|
// more default options |
|
|
|
_options.push( |
|
|
|
{'fieldname': 'name'}, |
|
|
|
{'fieldname': 'creation'}, |
|
|
|
{'fieldname': 'idx'} |
|
|
|
) |
|
|
|
// add missing labels |
|
|
|
_options.forEach(option => { |
|
|
|
if (!option.label) { |
|
|
|
option.label = me.get_label(option.fieldname); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
// de-duplicate |
|
|
|
this.args.options = _options.uniqBy(function(obj) { |
|
|
|
this.args.options = _options.uniqBy(obj => { |
|
|
|
return obj.fieldname; |
|
|
|
}); |
|
|
|
|
|
|
|
// add missing labels |
|
|
|
this.args.options.forEach(function(o) { |
|
|
|
if(!o.label) { |
|
|
|
o.label = me.get_label(o.fieldname); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
// set default |
|
|
|