feat: v4.4.0 - export filename: <slug_nazvu>-<YYYYMMDD-HHMM>.{json,pdf}
Some checks failed
Build & Push Docker / build (push) Has been cancelled

This commit is contained in:
2026-02-20 18:38:34 +01:00
parent 751ffe6f82
commit f7f2987f86
4 changed files with 24 additions and 4 deletions

View File

@@ -1,5 +1,5 @@
"""Application configuration.""" """Application configuration."""
VERSION = "4.3.0" VERSION = "4.4.0"
MAX_FILE_SIZE_MB = 10 MAX_FILE_SIZE_MB = 10
DEFAULT_COLOR = "#ffffff" DEFAULT_COLOR = "#ffffff"

View File

@@ -13,7 +13,7 @@
<header class="header"> <header class="header">
<div class="header-left"> <div class="header-left">
<h1 class="header-title">Scénář Creator</h1> <h1 class="header-title">Scénář Creator</h1>
<span class="header-version">v4.3</span> <span class="header-version">v4.4</span>
</div> </div>
<div class="header-actions"> <div class="header-actions">
<label class="btn btn-secondary btn-sm" id="importJsonBtn"> <label class="btn btn-secondary btn-sm" id="importJsonBtn">

View File

@@ -21,6 +21,26 @@ const App = {
return 'b_' + Math.random().toString(36).slice(2, 10); return 'b_' + Math.random().toString(36).slice(2, 10);
}, },
// Build download filename: "<slug_nazvu>-<YYYYMMDD-HHMM>.<ext>"
buildFilename(ext) {
const title = (this.state.event.title || 'scenar').trim();
// Remove diacritics, lowercase, replace non-alphanum with dash, collapse dashes
const slug = title
.normalize('NFD')
.replace(/[\u0300-\u036f]/g, '')
.toLowerCase()
.replace(/[^a-z0-9]+/g, '-')
.replace(/^-+|-+$/g, '') || 'scenar';
const now = new Date();
const ts = now.getFullYear().toString()
+ String(now.getMonth() + 1).padStart(2, '0')
+ String(now.getDate()).padStart(2, '0')
+ '-'
+ String(now.getHours()).padStart(2, '0')
+ String(now.getMinutes()).padStart(2, '0');
return `${slug}-${ts}.${ext}`;
},
parseTimeToMin(str) { parseTimeToMin(str) {
if (!str) return 0; if (!str) return 0;
const [h, m] = str.split(':').map(Number); const [h, m] = str.split(':').map(Number);
@@ -440,7 +460,7 @@ const App = {
try { try {
this.toast('Generuji PDF…', 'success'); this.toast('Generuji PDF…', 'success');
const blob = await API.postBlob('/api/generate-pdf', doc); const blob = await API.postBlob('/api/generate-pdf', doc);
API.downloadBlob(blob, 'scenar.pdf'); API.downloadBlob(blob, App.buildFilename('pdf'));
this.toast('PDF staženo', 'success'); this.toast('PDF staženo', 'success');
} catch (err) { } catch (err) {
this.toast('Chyba PDF: ' + err.message, 'error'); this.toast('Chyba PDF: ' + err.message, 'error');

View File

@@ -10,7 +10,7 @@ function exportJson() {
} }
const json = JSON.stringify(doc, null, 2); const json = JSON.stringify(doc, null, 2);
const blob = new Blob([json], { type: 'application/json' }); const blob = new Blob([json], { type: 'application/json' });
API.downloadBlob(blob, 'scenar_export.json'); API.downloadBlob(blob, App.buildFilename('json'));
App.toast('JSON exportován', 'success'); App.toast('JSON exportován', 'success');
} }