diff --git a/jey_wizard/__init__.py b/jey_wizard/__init__.py index f4bd716..6852ddf 100644 --- a/jey_wizard/__init__.py +++ b/jey_wizard/__init__.py @@ -1 +1 @@ -__version__ = "0.1.21" +__version__ = "0.1.22" diff --git a/jey_wizard/public/js/jey_setup.js b/jey_wizard/public/js/jey_setup.js index 2597670..623c377 100644 --- a/jey_wizard/public/js/jey_setup.js +++ b/jey_wizard/public/js/jey_setup.js @@ -10,7 +10,7 @@ frappe.provide("jey_wizard"); // Bump this string in every commit that changes wizard code. Displayed in the badge so // we can tell at a glance which version is actually running on a given machine. Kept in // sync with __version__ in jey_wizard/__init__.py. -const JEY_WIZARD_VERSION = "0.1.21"; +const JEY_WIZARD_VERSION = "0.1.22"; // Wipe Frappe + ERPNext default slides so their `before_load`/`after_load` listeners // don't try to mutate a wizard that isn't slide-based anymore. @@ -71,6 +71,12 @@ frappe.setup.SetupWizard = class JeySetupWizard { amas_selected_employees: [], amas_create_designation: 1, amas_organization_name: "", + // Survives show_current_step() re-renders so the user sees what + // failed when an error path resets amas_state to "intro" — the + // .jey-status helper is cleared by every render and would erase + // the message before they could read it. + amas_last_error: "", + asan_last_error: "", }; // Sub-state machines per step. `input` / `intro` is the always-safe fallback @@ -314,8 +320,14 @@ frappe.setup.SetupWizard = class JeySetupWizard { render_employees($body) { if (this.amas_state === "intro") { const alreadyLoaded = (this.data.amas_selected_employees || []).length; + const lastError = this.data.amas_last_error || ""; $body.html(`
${__("ƏMAS (e-social.gov.az) stores employment contracts. If your company has employees registered there, we can import them now.")}
${__("All employees will be imported into ƏMAS Employees and the standard Employee doctype after the wizard finishes.")}
+${__("Cached on the server. Actual import into Employee / ƏMAS Employees runs as a background job right after you click Finish — you can keep working in /app while it runs.")}
+${__("Click Next to continue, or Back to re-select.")}
`); // No extra buttons here — Back/Next in nav cover everything. } @@ -1157,6 +1170,7 @@ frappe.setup.SetupWizard = class JeySetupWizard { return; } this.data.amas_skipped = false; + this.data.amas_last_error = ""; this.amas_verification_code = ""; this.amas_state = "auth"; this.show_current_step(); @@ -1170,7 +1184,7 @@ frappe.setup.SetupWizard = class JeySetupWizard { if (this.amas_state !== "auth") return; const m = r.message || {}; if (!m.success) { - this.$wrap.find(".jey-status").text(m.message || __("MyGovID authentication failed.")); + this.data.amas_last_error = m.message || __("MyGovID authentication failed."); this.amas_state = "intro"; this.show_current_step(); return; @@ -1179,7 +1193,7 @@ frappe.setup.SetupWizard = class JeySetupWizard { }, error: () => { if (this.amas_state !== "auth") return; - this.$wrap.find(".jey-status").text(__("MyGovID request timed out.")); + this.data.amas_last_error = __("MyGovID request timed out."); this.amas_state = "intro"; this.show_current_step(); }, @@ -1213,7 +1227,7 @@ frappe.setup.SetupWizard = class JeySetupWizard { callback: (r) => { const m = r.message || {}; if (!m.success) { - this.$wrap.find(".jey-status").text(m.message || __("Failed to connect to ƏMAS.")); + this.data.amas_last_error = m.message || __("Failed to connect to ƏMAS."); this.amas_state = "intro"; this.show_current_step(); return; @@ -1233,7 +1247,7 @@ frappe.setup.SetupWizard = class JeySetupWizard { } else if (this.amas_accounts.length === 1) { this.amas_pick_account(0); } else if (this.amas_accounts.length === 0) { - this.$wrap.find(".jey-status").text(__("No organizations found in ƏMAS for this account.")); + this.data.amas_last_error = __("No organizations found in ƏMAS for this account."); this.amas_state = "intro"; this.show_current_step(); } else { @@ -1241,6 +1255,11 @@ frappe.setup.SetupWizard = class JeySetupWizard { this.show_current_step(); } }, + error: () => { + this.data.amas_last_error = __("Network error while connecting to ƏMAS."); + this.amas_state = "intro"; + this.show_current_step(); + }, }); } @@ -1267,7 +1286,7 @@ frappe.setup.SetupWizard = class JeySetupWizard { callback: (r) => { const m = r.message || {}; if (!m.success) { - this.$wrap.find(".jey-status").text(m.message || __("Failed to select organization.")); + this.data.amas_last_error = m.message || __("Failed to select organization."); this.amas_state = "intro"; this.show_current_step(); return; @@ -1275,6 +1294,11 @@ frappe.setup.SetupWizard = class JeySetupWizard { this.data.amas_organization_name = name; this.amas_load_employees(); }, + error: () => { + this.data.amas_last_error = __("Network error while selecting organization."); + this.amas_state = "intro"; + this.show_current_step(); + }, }); } @@ -1292,14 +1316,14 @@ frappe.setup.SetupWizard = class JeySetupWizard { callback: (r) => { const m = r.message || {}; if (!m.success) { - this.$wrap.find(".jey-status").text(m.message || __("Failed to fetch employees.")); + this.data.amas_last_error = m.message || __("Failed to fetch employees."); this.amas_state = "intro"; this.show_current_step(); return; } const employees = m.employees || []; if (employees.length === 0) { - this.$wrap.find(".jey-status").text(__("No employees found in ƏMAS for this organization.")); + this.data.amas_last_error = __("No employees found in ƏMAS for this organization."); this.amas_state = "intro"; this.show_current_step(); return; @@ -1315,6 +1339,7 @@ frappe.setup.SetupWizard = class JeySetupWizard { amas_commit_selection() { const all = this.amas_employees || []; if (all.length === 0) { + this.data.amas_last_error = __("Got empty employee list from ƏMAS."); this.amas_state = "intro"; this.show_current_step(); return; @@ -1331,7 +1356,7 @@ frappe.setup.SetupWizard = class JeySetupWizard { callback: (r) => { const m = r.message || {}; if (!m.ok) { - this.$wrap.find(".jey-status").text(__("Failed to cache selection.")); + this.data.amas_last_error = __("Failed to cache employee selection on the server."); this.amas_state = "intro"; this.show_current_step(); return; @@ -1341,6 +1366,11 @@ frappe.setup.SetupWizard = class JeySetupWizard { this.amas_state = "done"; this.show_current_step(); }, + error: () => { + this.data.amas_last_error = __("Network error while caching the employee selection."); + this.amas_state = "intro"; + this.show_current_step(); + }, }); }