feat: v4.4.0 - export filename: <slug_nazvu>-<YYYYMMDD-HHMM>.{json,pdf}
Some checks failed
Build & Push Docker / build (push) Has been cancelled
Some checks failed
Build & Push Docker / build (push) Has been cancelled
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
"""Application configuration."""
|
||||
|
||||
VERSION = "4.3.0"
|
||||
VERSION = "4.4.0"
|
||||
MAX_FILE_SIZE_MB = 10
|
||||
DEFAULT_COLOR = "#ffffff"
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<header class="header">
|
||||
<div class="header-left">
|
||||
<h1 class="header-title">Scénář Creator</h1>
|
||||
<span class="header-version">v4.3</span>
|
||||
<span class="header-version">v4.4</span>
|
||||
</div>
|
||||
<div class="header-actions">
|
||||
<label class="btn btn-secondary btn-sm" id="importJsonBtn">
|
||||
|
||||
@@ -21,6 +21,26 @@ const App = {
|
||||
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) {
|
||||
if (!str) return 0;
|
||||
const [h, m] = str.split(':').map(Number);
|
||||
@@ -440,7 +460,7 @@ const App = {
|
||||
try {
|
||||
this.toast('Generuji PDF…', 'success');
|
||||
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');
|
||||
} catch (err) {
|
||||
this.toast('Chyba PDF: ' + err.message, 'error');
|
||||
|
||||
@@ -10,7 +10,7 @@ function exportJson() {
|
||||
}
|
||||
const json = JSON.stringify(doc, null, 2);
|
||||
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');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user