feat: bulk add tags in list view

This commit is contained in:
prssanna 2020-07-20 19:14:53 +05:30
parent 7cb9909bab
commit 25ac9aa871
3 changed files with 55 additions and 0 deletions

View file

@ -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();
}
}

View file

@ -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());

View file

@ -4,5 +4,7 @@
display: inline-block;
padding: 3px 10px;
color: var(--gray-700);
height: 24px;
width: 60px;
vertical-align: middle;
}