Skip to content

Commit

Permalink
Merge pull request #2824 from resilient-tech/mergify/bp/version-15-ho…
Browse files Browse the repository at this point in the history
…tfix/pr-2806

fix: handle `Actions` button for smaller screens (backport #2806)
  • Loading branch information
vorasmit authored Dec 5, 2024
2 parents fef597f + bf2b241 commit 6265581
Showing 1 changed file with 27 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ const ALERT_HTML = `
<div>
You have missing GSTR-2B downloads
</div>
${api_enabled
? `<a id="download-gstr2b-button" href="#" class="alert-link">
${
api_enabled
? `<a id="download-gstr2b-button" href="#" class="alert-link">
Download 2B
</a>`
: ""
}
: ""
}
</div>
`;

Expand Down Expand Up @@ -98,28 +99,30 @@ frappe.ui.form.on("Purchase Reconciliation Tool", {
frm.save();
});

const action_group = __("Actions");

// add custom buttons
api_enabled
? frm.add_custom_button(__("Download 2A/2B"), () => new ImportDialog(frm))
: frm.add_custom_button(
__("Upload 2A/2B"),
() => new ImportDialog(frm, false)
);
__("Upload 2A/2B"),
() => new ImportDialog(frm, false)
);

if (!frm.purchase_reconciliation_tool?.data?.length) return;
if (frm.get_active_tab()?.df.fieldname == "invoice_tab") {
frm.add_custom_button(
__("Unlink"),
() => unlink_documents(frm),
__("Actions")
action_group
);
frm.add_custom_button(__("dropdown-divider"), () => { }, __("Actions"));
frm.add_custom_button(__("dropdown-divider"), () => {}, action_group);
}
["Accept", "Pending", "Ignore"].forEach(action =>
frm.add_custom_button(
__(action),
() => apply_action(frm, action),
__("Actions")
action_group
)
);
frm.$wrapper
Expand All @@ -132,10 +135,16 @@ frappe.ui.form.on("Purchase Reconciliation Tool", {
);

// move actions button next to filters
for (let button of $(".custom-actions .inner-group-button")) {
if (button.innerText?.trim() != "Actions") continue;
for (const group_div of $(".custom-actions .inner-group-button")) {
const btn_label = group_div.querySelector("button").innerText?.trim();
if (btn_label != action_group) continue;

$(".custom-button-group .inner-group-button").remove();
$(button).appendTo($(".custom-button-group"));

// to hide `Actions` button group on smaller screens
$(group_div).addClass("hidden-md");

$(group_div).appendTo($(".custom-button-group"));
}
},

Expand Down Expand Up @@ -192,8 +201,8 @@ frappe.ui.form.on("Purchase Reconciliation Tool", {
method == "update_api_progress"
? __("Fetching data from GSTN")
: __("Updating Inward Supply for Return Period {0}", [
data.return_period,
]);
data.return_period,
]);

frm.dashboard.show_progress(
"Import GSTR Progress",
Expand Down Expand Up @@ -921,8 +930,9 @@ class DetailViewDialog {
? ["GST Inward Supply"]
: ["Purchase Invoice", "Bill of Entry"],

read_only_depends_on: `eval: ${this.missing_doctype == "GST Inward Supply"
}`,
read_only_depends_on: `eval: ${
this.missing_doctype == "GST Inward Supply"
}`,

onchange: () => {
const doctype = this.dialog.get_value("doctype");
Expand Down

0 comments on commit 6265581

Please sign in to comment.