feat: add "Zaktualizuj dane" button to re-run all enrichment steps
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions

Two buttons side by side: "Uzbrój firmę" runs only missing steps,
"Zaktualizuj dane" forces re-run of all steps regardless of status.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Maciej Pienczyn 2026-02-20 15:16:29 +01:00
parent fb29b41720
commit a0cc22a29d

View File

@ -212,6 +212,9 @@
/* Workflow section */
.master-btn-wrap {
margin-bottom: var(--spacing-lg);
display: flex;
gap: var(--spacing-md);
flex-wrap: wrap;
}
.btn-master {
@ -230,6 +233,11 @@
box-shadow: var(--shadow-md);
}
.btn-master.btn-refresh {
background: linear-gradient(135deg, var(--warning, #f59e0b), #fbbf24);
font-size: var(--font-size-base);
}
.btn-master:hover { opacity: 0.9; box-shadow: var(--shadow-lg); }
.btn-master:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-master svg { width: 22px; height: 22px; }
@ -661,10 +669,14 @@
<h2>Workflow uzbrajania firmy</h2>
<div class="master-btn-wrap">
<button id="btn-arm" class="btn-master" onclick="armCompany()">
<button id="btn-arm" class="btn-master" onclick="armCompany(false)">
<svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path d="M13 10V3L4 14h7v7l9-11h-7z"/></svg>
Uzbrój firmę
</button>
<button id="btn-refresh" class="btn-master btn-refresh" onclick="armCompany(true)">
<svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"/></svg>
Zaktualizuj dane
</button>
</div>
<div class="actions-grid">
@ -1018,18 +1030,21 @@
});
}
function armCompany() {
function armCompany(forceAll) {
_skipReload = true;
var masterBtn = document.getElementById('btn-arm');
var isRefresh = !!forceAll;
var masterBtn = document.getElementById(isRefresh ? 'btn-refresh' : 'btn-arm');
var otherBtn = document.getElementById(isRefresh ? 'btn-arm' : 'btn-refresh');
masterBtn.disabled = true;
masterBtn.innerHTML = '<span class="spinner"></span> Uzbrajam firmę...';
otherBtn.disabled = true;
masterBtn.innerHTML = '<span class="spinner"></span> ' + (isRefresh ? 'Aktualizuję...' : 'Uzbrajam firmę...');
var steps = [
{id: 'btn-registry', fn: fetchRegistry, skip: {{ 'true' if enrichment.registry.done else 'false' }}, requires: {{ 'true' if company.nip else 'false' }} },
{id: 'btn-seo', fn: runSeoAudit, skip: {{ 'true' if enrichment.seo.done else 'false' }}, requires: {{ 'true' if company.website else 'false' }} },
{id: 'btn-social', fn: runSocialAudit, skip: {{ 'true' if enrichment.social.done else 'false' }}, requires: true },
{id: 'btn-gbp', fn: runGbpAudit, skip: {{ 'true' if enrichment.gbp.done else 'false' }}, requires: true },
{id: 'btn-logo', fn: fetchLogoAuto, skip: {{ 'true' if enrichment.logo.done else 'false' }}, requires: {{ 'true' if company.website else 'false' }} }
{id: 'btn-registry', fn: fetchRegistry, skip: forceAll ? false : {{ 'true' if enrichment.registry.done else 'false' }}, requires: {{ 'true' if company.nip else 'false' }} },
{id: 'btn-seo', fn: runSeoAudit, skip: forceAll ? false : {{ 'true' if enrichment.seo.done else 'false' }}, requires: {{ 'true' if company.website else 'false' }} },
{id: 'btn-social', fn: runSocialAudit, skip: forceAll ? false : {{ 'true' if enrichment.social.done else 'false' }}, requires: true },
{id: 'btn-gbp', fn: runGbpAudit, skip: forceAll ? false : {{ 'true' if enrichment.gbp.done else 'false' }}, requires: true },
{id: 'btn-logo', fn: fetchLogoAuto, skip: forceAll ? false : {{ 'true' if enrichment.logo.done else 'false' }}, requires: {{ 'true' if company.website else 'false' }} }
];
var pending = steps.filter(function(s) { return !s.skip && s.requires; });
@ -1037,15 +1052,19 @@
if (pending.length === 0) {
showToast('Wszystkie kroki zostały już wykonane!', 'success');
masterBtn.disabled = false;
masterBtn.innerHTML = '<svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24" style="width:22px;height:22px"><path d="M13 10V3L4 14h7v7l9-11h-7z"/></svg> Uzbrój firmę';
otherBtn.disabled = false;
masterBtn.innerHTML = isRefresh
? '<svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24" style="width:22px;height:22px"><path d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"/></svg> Zaktualizuj dane'
: '<svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24" style="width:22px;height:22px"><path d="M13 10V3L4 14h7v7l9-11h-7z"/></svg> Uzbrój firmę';
_skipReload = false;
return;
}
var idx = 0;
var label = isRefresh ? 'Aktualizuję' : 'Uzbrajam';
function runNext() {
if (idx >= pending.length) {
showToast('Uzbrajanie zakończone! Odświeżam stronę...', 'success');
showToast(label + ' zakończone! Odświeżam stronę...', 'success');
setTimeout(function() { location.reload(); }, 2000);
return;
}