fix: make notification settings searchable
This commit is contained in:
parent
d3c73e3a89
commit
ab8d00a5b7
3 changed files with 31 additions and 19 deletions
|
|
@ -72,15 +72,14 @@
|
|||
"fieldname": "user",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 1,
|
||||
"in_list_view": 1,
|
||||
"label": "User",
|
||||
"options": "User",
|
||||
"read_only": 1
|
||||
}
|
||||
],
|
||||
"in_create": 1,
|
||||
"modified": "2019-10-23 12:42:56.175928",
|
||||
"modified_by": "Administrator",
|
||||
"modified": "2019-11-08 14:11:35.619306",
|
||||
"modified_by": "frappetestuser2@gmail.com",
|
||||
"module": "Desk",
|
||||
"name": "Notification Settings",
|
||||
"owner": "Administrator",
|
||||
|
|
@ -97,7 +96,6 @@
|
|||
"write": 1
|
||||
}
|
||||
],
|
||||
"read_only": 1,
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC",
|
||||
"track_changes": 1
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
frappe.provide('frappe.search');
|
||||
|
||||
frappe.ui.Notifications = class Notifications {
|
||||
constructor() {
|
||||
frappe.model
|
||||
|
|
@ -29,10 +31,30 @@ frappe.ui.Notifications = class Notifications {
|
|||
);
|
||||
|
||||
frappe.utils.bind_actions_with_object(this.$dropdown_list, this);
|
||||
let me = this;
|
||||
frappe.search.utils.make_function_searchable(
|
||||
me.route_to_settings,
|
||||
__('Notification Settings'),
|
||||
[this.notifications_settings],
|
||||
)
|
||||
|
||||
this.setup_notifications();
|
||||
this.bind_events();
|
||||
}
|
||||
|
||||
route_to_settings(settings_doc) {
|
||||
let method =
|
||||
'frappe.desk.doctype.notification_settings.notification_settings.create_notification_settings';
|
||||
|
||||
return Promise.resolve()
|
||||
.then(() => {
|
||||
if (!settings_doc) return frappe.call(method);
|
||||
})
|
||||
.then(() => {
|
||||
frappe.set_route(`#Form/Notification Settings/${frappe.session.user}`);
|
||||
});
|
||||
}
|
||||
|
||||
setup_notifications() {
|
||||
this.get_notifications_list(this.max_length).then(list => {
|
||||
this.dropdown_items = list;
|
||||
|
|
@ -249,7 +271,7 @@ frappe.ui.Notifications = class Notifications {
|
|||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
mark_all_as_seen() {
|
||||
this.$dropdown_list.find('.unseen').removeClass('unseen');
|
||||
let unseen_docnames = this.dropdown_items
|
||||
|
|
@ -368,7 +390,7 @@ frappe.ui.Notifications = class Notifications {
|
|||
let mark_all_read_html =
|
||||
category.value === 'Notifications'
|
||||
? `<span class="mark-all-read pull-right" data-action="mark_all_as_read">
|
||||
${__('Mark All as Read')}
|
||||
${__('Mark all as Read')}
|
||||
</span>`
|
||||
: '';
|
||||
let html = `<li class="notifications-category">
|
||||
|
|
@ -407,16 +429,7 @@ frappe.ui.Notifications = class Notifications {
|
|||
e.stopImmediatePropagation();
|
||||
this.$dropdown.removeClass('open');
|
||||
this.$dropdown.trigger('hide.bs.dropdown');
|
||||
let method =
|
||||
'frappe.desk.doctype.notification_settings.notification_settings.create_notification_settings';
|
||||
|
||||
return Promise.resolve()
|
||||
.then(() => {
|
||||
if (!this.notifications_settings) return frappe.call(method);
|
||||
})
|
||||
.then(() => {
|
||||
frappe.set_route(`#Form/Notification Settings/${frappe.session.user}`);
|
||||
});
|
||||
this.route_to_settings(this.notifications_settings);
|
||||
}
|
||||
|
||||
bind_events() {
|
||||
|
|
|
|||
|
|
@ -622,20 +622,21 @@ frappe.search.utils = {
|
|||
value: this.bolden_match_part(__(item.label), txt),
|
||||
index: this.fuzzy_search(txt, target),
|
||||
match: item.label,
|
||||
onclick: item.action,
|
||||
onclick: () => item.action.apply(this, item.args)
|
||||
});
|
||||
}
|
||||
});
|
||||
return results;
|
||||
},
|
||||
make_function_searchable(_function, label=null) {
|
||||
make_function_searchable(_function, label=null, args=null) {
|
||||
if (typeof _function !== 'function') {
|
||||
throw new Error('First argument should be a function');
|
||||
}
|
||||
|
||||
this.searchable_functions.push({
|
||||
'label': label || _function.name,
|
||||
'action': _function
|
||||
'action': _function,
|
||||
'args': args,
|
||||
});
|
||||
},
|
||||
searchable_functions: [],
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue