From 91bd5ed2e2a8413574ac26e0620157d59022cc73 Mon Sep 17 00:00:00 2001 From: saxenabhishek Date: Thu, 16 Dec 2021 22:37:03 +0530 Subject: [PATCH 1/3] fix: misc setup_wizard region slide placeholder on all fields autocomplete on country input default selected values on inputs --- frappe/desk/page/setup_wizard/setup_wizard.js | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/frappe/desk/page/setup_wizard/setup_wizard.js b/frappe/desk/page/setup_wizard/setup_wizard.js index 7e90bc01ad..5ef5bda8a8 100644 --- a/frappe/desk/page/setup_wizard/setup_wizard.js +++ b/frappe/desk/page/setup_wizard/setup_wizard.js @@ -392,12 +392,14 @@ frappe.setup.slides_settings = [ fields: [ { fieldname: "country", label: __("Your Country"), reqd: 1, - fieldtype: "Select" + fieldtype: "Autocomplete", + placeholder: __('Select Country') }, { fieldtype: "Section Break" }, { fieldname: "timezone", label: __("Time Zone"), reqd: 1, - fieldtype: "Select" + fieldtype: "Select", + }, { fieldtype: "Column Break" }, { @@ -529,16 +531,19 @@ frappe.setup.utils = { var country_field = slide.get_field('country'); - slide.get_input("country").empty() - .add_options([""].concat(Object.keys(data.country_info).sort())); - slide.get_input("currency").empty() - .add_options(frappe.utils.unique([""].concat( - $.map(data.country_info, opts => opts.currency) - )).sort()); + country_field.set_data(Object.keys(data.country_info).sort()); + + slide.get_input("currency") + .empty() + .add_options( + frappe.utils.unique( + ["Select Currency"].concat($.map(data.country_info, opts => opts.currency).sort()) + ) + ); slide.get_input("timezone").empty() - .add_options([""].concat(data.all_timezones)); + .add_options(["Select Timezone"].concat(data.all_timezones)); // set values if present if (frappe.wizard.values.country) { @@ -590,7 +595,7 @@ frappe.setup.utils = { $timezone.empty(); // add country specific timezones first - if (country) { + if (country !== "Select Country" ) { var timezone_list = data.country_info[country].timezones || []; $timezone.add_options(timezone_list.sort()); slide.get_field("currency").set_input(data.country_info[country].currency); @@ -598,7 +603,7 @@ frappe.setup.utils = { } // add all timezones at the end, so that user has the option to change it to any timezone - $timezone.add_options([""].concat(data.all_timezones)); + $timezone.add_options(["Select Timezone"].concat(data.all_timezones)); slide.get_field("timezone").set_input($timezone.val()); @@ -609,7 +614,7 @@ frappe.setup.utils = { slide.get_input("currency").on("change", function () { var currency = slide.get_input("currency").val(); - if (!currency) return; + if (currency === "Select Currency") return; frappe.model.with_doc("Currency", currency, function () { frappe.provide("locals.:Currency." + currency); var currency_doc = frappe.model.get_doc("Currency", currency); From 1dd870ce73457b1505e74c706be14ea8a7a33867 Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Tue, 21 Dec 2021 08:54:31 +0530 Subject: [PATCH 2/3] refactor: Use placeholder instead of additional option in select - Additional options were still selectable which could have got through - Minor formatting changes --- frappe/desk/page/setup_wizard/setup_wizard.js | 43 +++++++++---------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/frappe/desk/page/setup_wizard/setup_wizard.js b/frappe/desk/page/setup_wizard/setup_wizard.js index 5ef5bda8a8..565c311af7 100644 --- a/frappe/desk/page/setup_wizard/setup_wizard.js +++ b/frappe/desk/page/setup_wizard/setup_wizard.js @@ -397,14 +397,19 @@ frappe.setup.slides_settings = [ }, { fieldtype: "Section Break" }, { - fieldname: "timezone", label: __("Time Zone"), reqd: 1, + fieldname: "timezone", + label: __("Time Zone"), + placeholder: __('Select Time Zone'), + reqd: 1, fieldtype: "Select", - }, { fieldtype: "Column Break" }, { - fieldname: "currency", label: __("Currency"), reqd: 1, - fieldtype: "Select" + fieldname: "currency", + label: __("Currency"), + placeholder: __('Select Currency'), + reqd: 1, + fieldtype: "Select", } ], @@ -514,7 +519,7 @@ frappe.setup.utils = { frappe.setup.data.email = r.message.email; callback(slide); } - }) + }); }, setup_language_field: function (slide) { @@ -538,12 +543,12 @@ frappe.setup.utils = { .empty() .add_options( frappe.utils.unique( - ["Select Currency"].concat($.map(data.country_info, opts => opts.currency).sort()) + $.map(data.country_info, opts => opts.currency).sort() ) ); slide.get_input("timezone").empty() - .add_options(["Select Timezone"].concat(data.all_timezones)); + .add_options(data.all_timezones); // set values if present if (frappe.wizard.values.country) { @@ -552,13 +557,9 @@ frappe.setup.utils = { country_field.set_input(data.default_country); } - if (frappe.wizard.values.currency) { - slide.get_field("currency").set_input(frappe.wizard.values.currency); - } + slide.get_field("currency").set_input(frappe.wizard.values.currency); - if (frappe.wizard.values.timezone) { - slide.get_field("timezone").set_input(frappe.wizard.values.timezone); - } + slide.get_field("timezone").set_input(frappe.wizard.values.timezone); }, @@ -595,16 +596,13 @@ frappe.setup.utils = { $timezone.empty(); // add country specific timezones first - if (country !== "Select Country" ) { - var timezone_list = data.country_info[country].timezones || []; - $timezone.add_options(timezone_list.sort()); - slide.get_field("currency").set_input(data.country_info[country].currency); - slide.get_field("currency").$input.trigger("change"); - } + const timezone_list = data.country_info[country].timezones || []; + $timezone.add_options(timezone_list.sort()); + slide.get_field("currency").set_input(data.country_info[country].currency); + slide.get_field("currency").$input.trigger("change"); // add all timezones at the end, so that user has the option to change it to any timezone - $timezone.add_options(["Select Timezone"].concat(data.all_timezones)); - + $timezone.add_options(data.all_timezones); slide.get_field("timezone").set_input($timezone.val()); // temporarily set date format @@ -614,7 +612,6 @@ frappe.setup.utils = { slide.get_input("currency").on("change", function () { var currency = slide.get_input("currency").val(); - if (currency === "Select Currency") return; frappe.model.with_doc("Currency", currency, function () { frappe.provide("locals.:Currency." + currency); var currency_doc = frappe.model.get_doc("Currency", currency); @@ -622,7 +619,7 @@ frappe.setup.utils = { if (number_format === "#.###") { number_format = "#.###,##"; } else if (number_format === "#,###") { - number_format = "#,###.##" + number_format = "#,###.##"; } frappe.boot.sysdefaults.number_format = number_format; From b530beb503c0f70422daafb98817741c24ffd21e Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Tue, 21 Dec 2021 09:36:09 +0530 Subject: [PATCH 3/3] revert: Empty value checks --- frappe/desk/page/setup_wizard/setup_wizard.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/frappe/desk/page/setup_wizard/setup_wizard.js b/frappe/desk/page/setup_wizard/setup_wizard.js index 565c311af7..32d5bf235b 100644 --- a/frappe/desk/page/setup_wizard/setup_wizard.js +++ b/frappe/desk/page/setup_wizard/setup_wizard.js @@ -595,6 +595,7 @@ frappe.setup.utils = { $timezone.empty(); + if (!country) return; // add country specific timezones first const timezone_list = data.country_info[country].timezones || []; $timezone.add_options(timezone_list.sort()); @@ -612,6 +613,7 @@ frappe.setup.utils = { slide.get_input("currency").on("change", function () { var currency = slide.get_input("currency").val(); + if (!currency) return; frappe.model.with_doc("Currency", currency, function () { frappe.provide("locals.:Currency." + currency); var currency_doc = frappe.model.get_doc("Currency", currency);