Skip to content

Commit

Permalink
fix(UX): invalid filters, incorrect std fieldtypes (backport #19657) (#…
Browse files Browse the repository at this point in the history
…20118)

* fix: Correct standard docfield types

- `creation` and `modified` are timestamps not dates.
- `modified_by` is similar to `owner` so not sure why we can't have this render as link as well

* fix: correct invalid filters

- Datetime - equality doesn't make sense because of milliseconds. A separate operator for "date" part can be useful here maybe.
- Code - data like filter and remove comparison operators.
- Barcode - treat like data
- attach - treat like data
- attach image - treat like data
- rating - remove invalid operators
- password - LOL

---------

Co-authored-by: Ankush Menat <ankush@frappe.io>
  • Loading branch information
barredterra and ankush committed Feb 22, 2023
1 parent d7f9d91 commit a612baa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 3 additions & 3 deletions frappe/public/js/frappe/model/model.js
Expand Up @@ -21,9 +21,9 @@ $.extend(frappe.model, {
{fieldname:'name', fieldtype:'Link', label:__('ID')},
{fieldname:'owner', fieldtype:'Link', label:__('Created By'), options: 'User'},
{fieldname:'idx', fieldtype:'Int', label:__('Index')},
{fieldname:'creation', fieldtype:'Date', label:__('Created On')},
{fieldname:'modified', fieldtype:'Date', label:__('Last Updated On')},
{fieldname:'modified_by', fieldtype:'Data', label:__('Last Updated By')},
{fieldname:'creation', fieldtype:'Datetime', label:__('Created On')},
{fieldname:'modified', fieldtype:'Datetime', label:__('Last Updated On')},
{fieldname:'modified_by', fieldtype:'Link', label:__('Last Updated By'), options: "User"},
{fieldname:'_user_tags', fieldtype:'Data', label:__('Tags')},
{fieldname:'_liked_by', fieldtype:'Data', label:__('Liked By')},
{fieldname:'_comments', fieldtype:'Text', label:__('Comments')},
Expand Down
8 changes: 7 additions & 1 deletion frappe/public/js/frappe/ui/filters/filter.js
Expand Up @@ -39,13 +39,16 @@ frappe.ui.Filter = class {

this.invalid_condition_map = {
Date: ['like', 'not like'],
Datetime: ['like', 'not like'],
Datetime: ['like', 'not like', 'in', 'not in', '=', '!='],
Data: ['Between', 'Timespan'],
Select: ['like', 'not like', 'Between', 'Timespan'],
Link: ['Between', 'Timespan', '>', '<', '>=', '<='],
Currency: ['Between', 'Timespan'],
Color: ['Between', 'Timespan'],
Check: this.conditions.map((c) => c[0]).filter((c) => c !== '='),
Code: ['Between', 'Timespan', '>', '<', '>=', '<=', 'in', 'not in'],
Password: ['Between', 'Timespan', '>', '<', '>=', '<=', 'in', 'not in'],
Rating: ['like', 'not like', 'Between', 'in', 'not in', 'Timespan'],
};
}

Expand Down Expand Up @@ -491,10 +494,13 @@ frappe.ui.filter_utils = {
'Small Text',
'Text Editor',
'Code',
'Attach',
'Attach Image',
'Markdown Editor',
'HTML Editor',
'Tag',
'Comments',
'Barcode',
'Dynamic Link',
'Read Only',
'Assign',
Expand Down

0 comments on commit a612baa

Please sign in to comment.