Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle Actions button for smaller screens #2806

Merged
merged 7 commits into from
Dec 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading