mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-20 21:49:18 +00:00
fix: Update split issue & help article
This commit is contained in:
@@ -154,52 +154,71 @@ frappe.ui.form.on("Issue", {
|
|||||||
|
|
||||||
|
|
||||||
timeline_refresh: function(frm) {
|
timeline_refresh: function(frm) {
|
||||||
// create button for "Help Article"
|
|
||||||
if (frappe.model.can_create("Help Article")) {
|
|
||||||
// Removing Help Article button if exists to avoid multiple occurance
|
|
||||||
frm.timeline.wrapper.find('.comment-header .asset-details .btn-add-to-kb').remove();
|
|
||||||
$('<button class="btn btn-xs btn-link btn-add-to-kb text-muted hidden-xs pull-right">'+
|
|
||||||
__('Help Article') + '</button>')
|
|
||||||
.appendTo(frm.timeline.wrapper.find('.comment-header .asset-details:not([data-communication-type="Comment"])'))
|
|
||||||
.on("click", function() {
|
|
||||||
var content = $(this).parents(".timeline-item:first").find(".timeline-item-content").html();
|
|
||||||
var doc = frappe.model.get_new_doc("Help Article");
|
|
||||||
doc.title = frm.doc.subject;
|
|
||||||
doc.content = content;
|
|
||||||
frappe.set_route("Form", "Help Article", doc.name);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!frm.timeline.wrapper.find(".btn-split-issue").length) {
|
if (!frm.timeline.wrapper.find(".btn-split-issue").length) {
|
||||||
let split_issue = __("Split Issue")
|
let split_issue_btn = $(`
|
||||||
$(`<button class="btn btn-xs btn-link btn-add-to-kb text-muted hidden-xs btn-split-issue pull-right" style="display:inline-block; margin-right: 15px">
|
<a class="action-btn btn-split-issue" title="${__("Split Issue")}">
|
||||||
${split_issue}
|
${frappe.utils.icon('branch', 'sm')}
|
||||||
</button>`)
|
</a>
|
||||||
.appendTo(frm.timeline.wrapper.find('.comment-header .asset-details:not([data-communication-type="Comment"])'))
|
`);
|
||||||
|
|
||||||
|
let communication_box = frm.timeline.wrapper.find('.timeline-item[data-doctype="Communication"]');
|
||||||
|
communication_box.find('.actions').prepend(split_issue_btn);
|
||||||
|
|
||||||
if (!frm.timeline.wrapper.data("split-issue-event-attached")) {
|
if (!frm.timeline.wrapper.data("split-issue-event-attached")) {
|
||||||
frm.timeline.wrapper.on('click', '.btn-split-issue', (e) => {
|
frm.timeline.wrapper.on('click', '.btn-split-issue', (e) => {
|
||||||
var dialog = new frappe.ui.Dialog({
|
var dialog = new frappe.ui.Dialog({
|
||||||
title: __("Split Issue"),
|
title: __("Split Issue"),
|
||||||
fields: [
|
fields: [
|
||||||
{fieldname: "subject", fieldtype: "Data", reqd: 1, label: __("Subject"), description: __("All communications including and above this shall be moved into the new Issue")}
|
{
|
||||||
|
fieldname: "subject",
|
||||||
|
fieldtype: "Data",
|
||||||
|
reqd: 1,
|
||||||
|
label: __("Subject"),
|
||||||
|
description: __("All communications including and above this shall be moved into the new Issue")
|
||||||
|
}
|
||||||
],
|
],
|
||||||
primary_action_label: __("Split"),
|
primary_action_label: __("Split"),
|
||||||
primary_action: function() {
|
primary_action: () => {
|
||||||
frm.call("split_issue", {
|
frm.call("split_issue", {
|
||||||
subject: dialog.fields_dict.subject.value,
|
subject: dialog.fields_dict.subject.value,
|
||||||
communication_id: e.currentTarget.closest(".timeline-item").getAttribute("data-name")
|
communication_id: e.currentTarget.closest(".timeline-item").getAttribute("data-name")
|
||||||
}, (r) => {
|
}, (r) => {
|
||||||
frappe.msgprint(`New issue created: <a href="/app/issue/${r.message}">${r.message}</a>`)
|
frappe.msgprint(`New issue created: <a href="/app/issue/${r.message}">${r.message}</a>`);
|
||||||
frm.reload_doc();
|
frm.reload_doc();
|
||||||
dialog.hide();
|
dialog.hide();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
dialog.show()
|
dialog.show();
|
||||||
})
|
});
|
||||||
frm.timeline.wrapper.data("split-issue-event-attached", true)
|
frm.timeline.wrapper.data("split-issue-event-attached", true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// create button for "Help Article"
|
||||||
|
if (frappe.model.can_create("Help Article")) {
|
||||||
|
// Removing Help Article button if exists to avoid multiple occurrence
|
||||||
|
frm.timeline.wrapper.find('.action-btn .btn-add-to-kb').remove();
|
||||||
|
|
||||||
|
let help_article = $(`
|
||||||
|
<a class="action-btn btn-add-to-kb" title="${__('Help Article')}">
|
||||||
|
${frappe.utils.icon('solid-info', 'sm')}
|
||||||
|
</a>
|
||||||
|
`);
|
||||||
|
|
||||||
|
let communication_box = frm.timeline.wrapper.find('.timeline-item[data-doctype="Communication"]');
|
||||||
|
communication_box.find('.actions').prepend(help_article);
|
||||||
|
if (!frm.timeline.wrapper.data("help-article-event-attached")) {
|
||||||
|
frm.timeline.wrapper.on('click', '.btn-add-to-kb', function () {
|
||||||
|
const content = $(this).parents('.timeline-item[data-doctype="Communication"]:first').find(".content").html();
|
||||||
|
const doc = frappe.model.get_new_doc("Help Article");
|
||||||
|
doc.title = frm.doc.subject;
|
||||||
|
doc.content = content;
|
||||||
|
frappe.set_route("Form", "Help Article", doc.name);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
frm.timeline.wrapper.data("help-article-event-attached", true);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user