Skip to content

Commit

Permalink
refactor(Holiday List): use autocomplete fieldtype
Browse files Browse the repository at this point in the history
  • Loading branch information
barredterra committed Jul 14, 2023
1 parent 8aff5a1 commit dab9688
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
12 changes: 5 additions & 7 deletions erpnext/setup/doctype/holiday_list/holiday_list.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ frappe.ui.form.on("Holiday List", {

frm.call("get_supported_countries").then(r => {
frm.subdivisions_by_country = r.message.subdivisions_by_country;
const countries = r.message.countries.sort((a, b) => a.label.localeCompare(b.label));
countries.unshift({ value: "", label: __("Select Country ...") });

frm.set_df_property("country", "options", countries);
frm.fields_dict.country.set_data(
r.message.countries.sort((a, b) => a.label.localeCompare(b.label))
);

if (frm.doc.country) {
frm.trigger("set_subdivisions");
Expand All @@ -35,11 +34,10 @@ frappe.ui.form.on("Holiday List", {
set_subdivisions: function(frm) {
const subdivisions = [...frm.subdivisions_by_country[frm.doc.country]];
if (subdivisions && subdivisions.length > 0) {
subdivisions.unshift({ value: "", label: __("Select Subdivision ...") });
frm.set_df_property("subdivision", "options", subdivisions);
frm.fields_dict.subdivision.set_data(subdivisions);
frm.set_df_property("subdivision", "hidden", 0);
} else {
frm.set_df_property("subdivision", "options", "");
frm.fields_dict.subdivision.set_data([]);
frm.set_df_property("subdivision", "hidden", 1);
}
},
Expand Down
6 changes: 3 additions & 3 deletions erpnext/setup/doctype/holiday_list/holiday_list.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,13 @@
},
{
"fieldname": "country",
"fieldtype": "Select",
"fieldtype": "Autocomplete",
"label": "Country"
},
{
"depends_on": "country",
"fieldname": "subdivision",
"fieldtype": "Select",
"fieldtype": "Autocomplete",
"label": "Subdivision"
},
{
Expand All @@ -141,7 +141,7 @@
"icon": "fa fa-calendar",
"idx": 1,
"links": [],
"modified": "2023-07-14 11:29:12.537263",
"modified": "2023-07-14 13:28:53.156421",
"modified_by": "Administrator",
"module": "Setup",
"name": "Holiday List",
Expand Down
2 changes: 0 additions & 2 deletions erpnext/translations/de.csv
Original file line number Diff line number Diff line change
Expand Up @@ -4004,8 +4004,6 @@ Search for a payment,Suche nach einer Zahlung,
Search for anything ...,Nach etwas suchen ...,
Search results for,Suchergebnisse für,
Select All,Alles auswählen,
Select Country ...,Land auswählen ...,
Select Subdivision ...,Teilgebiet auswählen ...,
Select Difference Account,Wählen Sie Differenzkonto,
Select a Default Priority.,Wählen Sie eine Standardpriorität.,
Select a company,Wählen Sie eine Firma aus,
Expand Down

0 comments on commit dab9688

Please sign in to comment.