diff --git a/frappe/public/js/frappe/list/bulk_operations.js b/frappe/public/js/frappe/list/bulk_operations.js index 53130afeb3..369c8e7a5a 100644 --- a/frappe/public/js/frappe/list/bulk_operations.js +++ b/frappe/public/js/frappe/list/bulk_operations.js @@ -222,4 +222,43 @@ export default class BulkOperations { dialog.refresh(); dialog.show(); } + + + add_tags(docnames, done) { + const dialog = new frappe.ui.Dialog({ + title: __('Add Tags'), + fields: [ + { + fieldtype: 'MultiSelectPills', + fieldname: 'tags', + label: __("Tags"), + reqd: true, + get_data: function(txt) { + return frappe.db.get_link_options("Tag", txt); + } + }, + ], + primary_action_label: __("Add"), + primary_action: () => { + let args = dialog.get_values(); + if (args && args.tags) { + dialog.set_message("Adding Tags..."); + + frappe.call({ + method: "frappe.desk.doctype.tag.tag.add_tags", + args: { + 'tags': args.tags, + 'dt': this.doctype, + 'docs': docnames, + }, + callback: () => { + dialog.hide(); + done(); + } + }); + } + }, + }); + dialog.show(); + } } diff --git a/frappe/public/js/frappe/list/list_view.js b/frappe/public/js/frappe/list/list_view.js index 44a70c1df5..1836a321f5 100644 --- a/frappe/public/js/frappe/list/list_view.js +++ b/frappe/public/js/frappe/list/list_view.js @@ -1587,6 +1587,18 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList { }; }; + const bulk_add_tags = () => { + return { + label: __("Add Tags"), + action: () => + bulk_operations.add_tags( + this.get_checked_items(true), + this.refresh + ), + standard: true, + }; + }; + const bulk_printing = () => { return { label: __("Print"), @@ -1690,6 +1702,8 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList { actions_menu_items.push(bulk_assignment_rule()); + actions_menu_items.push(bulk_add_tags()); + // bulk printing if (frappe.model.can_print(doctype)) { actions_menu_items.push(bulk_printing()); diff --git a/frappe/public/scss/tags.scss b/frappe/public/scss/tags.scss index 6498868c73..18b0720ebb 100644 --- a/frappe/public/scss/tags.scss +++ b/frappe/public/scss/tags.scss @@ -4,5 +4,7 @@ display: inline-block; padding: 3px 10px; color: var(--gray-700); + height: 24px; + width: 60px; vertical-align: middle; } \ No newline at end of file