fix: Update split issue & help article
This commit is contained in:
parent
cde1566606
commit
e560d7428e
@ -154,52 +154,71 @@ frappe.ui.form.on("Issue", {
|
||||
|
||||
|
||||
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) {
|
||||
let split_issue = __("Split Issue")
|
||||
$(`<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">
|
||||
${split_issue}
|
||||
</button>`)
|
||||
.appendTo(frm.timeline.wrapper.find('.comment-header .asset-details:not([data-communication-type="Comment"])'))
|
||||
let split_issue_btn = $(`
|
||||
<a class="action-btn btn-split-issue" title="${__("Split Issue")}">
|
||||
${frappe.utils.icon('branch', 'sm')}
|
||||
</a>
|
||||
`);
|
||||
|
||||
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")) {
|
||||
frm.timeline.wrapper.on('click', '.btn-split-issue', (e) => {
|
||||
var dialog = new frappe.ui.Dialog({
|
||||
title: __("Split Issue"),
|
||||
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: function() {
|
||||
primary_action: () => {
|
||||
frm.call("split_issue", {
|
||||
subject: dialog.fields_dict.subject.value,
|
||||
communication_id: e.currentTarget.closest(".timeline-item").getAttribute("data-name")
|
||||
}, (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();
|
||||
dialog.hide();
|
||||
});
|
||||
}
|
||||
});
|
||||
dialog.show()
|
||||
})
|
||||
frm.timeline.wrapper.data("split-issue-event-attached", true)
|
||||
dialog.show();
|
||||
});
|
||||
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);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user