Fix Queue settings save broken by nested industry reinstall form.
Deploy Ladill Queue / deploy (push) Successful in 2m5s
Deploy Ladill Queue / deploy (push) Successful in 2m5s
Browsers abort the outer Save settings form when a Reinstall package form is nested inside it. Move reinstall outside the main form and harden update validation so package failures cannot block saving. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -64,9 +64,9 @@ class SettingsController extends Controller
|
||||
|
||||
$validated = $request->validate([
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'timezone' => ['required', 'timezone'],
|
||||
'timezone' => ['required', 'string', 'timezone:all'],
|
||||
'appointment_mode' => ['required', 'string', 'in:'.implode(',', array_keys(config('qms.appointment_modes')))],
|
||||
'industry' => ['nullable', 'string', 'in:'.implode(',', array_keys(config('industry_packages.packages', [])))],
|
||||
'industry' => ['nullable', 'string', 'max:64'],
|
||||
'notifications_enabled' => ['boolean'],
|
||||
'care_integration_enabled' => ['nullable', 'boolean'],
|
||||
'frontdesk_integration_enabled' => ['nullable', 'boolean'],
|
||||
@@ -74,10 +74,17 @@ class SettingsController extends Controller
|
||||
'remove_logo' => ['nullable', 'boolean'],
|
||||
]);
|
||||
|
||||
$registry = app(IndustryPackageRegistry::class);
|
||||
$settings = $organization->settings ?? [];
|
||||
$industry = isset($validated['industry']) && $validated['industry'] !== ''
|
||||
? $registry->resolveKey($validated['industry'])
|
||||
: ($settings['industry'] ?? null);
|
||||
|
||||
$settings['appointment_mode'] = $validated['appointment_mode'];
|
||||
$previousIndustry = $settings['industry'] ?? null;
|
||||
$settings['industry'] = $validated['industry'] ?? $settings['industry'] ?? null;
|
||||
if ($industry !== null) {
|
||||
$settings['industry'] = $industry;
|
||||
}
|
||||
$settings['notifications_enabled'] = $request->boolean('notifications_enabled', true);
|
||||
$integrations = $settings['integrations'] ?? [];
|
||||
if ($request->has('care_integration_enabled')) {
|
||||
@@ -108,7 +115,8 @@ class SettingsController extends Controller
|
||||
|
||||
AuditLogger::record($owner, 'organization.updated', $organization->id, $owner, \App\Models\Organization::class, $organization->id);
|
||||
|
||||
$industryChanged = $settings['industry'] && $settings['industry'] !== $previousIndustry;
|
||||
$industryChanged = ($settings['industry'] ?? null) && ($settings['industry'] ?? null) !== $previousIndustry;
|
||||
$packageNote = '';
|
||||
if ($industryChanged) {
|
||||
$branch = Branch::query()
|
||||
->where('organization_id', $organization->id)
|
||||
@@ -116,15 +124,19 @@ class SettingsController extends Controller
|
||||
->orderBy('id')
|
||||
->first();
|
||||
if ($branch) {
|
||||
app(IndustryPackageInstaller::class)->install($organization->fresh(), $branch, $settings['industry'], [
|
||||
'actor_ref' => $owner,
|
||||
]);
|
||||
try {
|
||||
app(IndustryPackageInstaller::class)->install($organization->fresh(), $branch, $settings['industry'], [
|
||||
'actor_ref' => $owner,
|
||||
]);
|
||||
$packageNote = ' Industry package re-provisioned.';
|
||||
} catch (\Throwable $e) {
|
||||
report($e);
|
||||
$packageNote = ' Settings saved, but industry package re-provision failed — try Reinstall package.';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return back()->with('success', $industryChanged
|
||||
? 'Settings saved. Industry package re-provisioned.'
|
||||
: 'Settings saved.');
|
||||
return back()->with('success', 'Settings saved.'.$packageNote);
|
||||
}
|
||||
|
||||
public function reinstallPackage(Request $request, IndustryPackageInstaller $installer): RedirectResponse
|
||||
|
||||
Reference in New Issue
Block a user