Split Print into Save / Save & Print -- saving no longer requires also printing
deploy / deploy (push) Successful in 9s

Name is now required (it's the only thing identifying what got saved),
and printing is an explicit separate choice instead of an implicit
side-effect of naming something.
This commit is contained in:
randy committed 2026-09-13 11:37:24 +02:00
1 parent 148f7dc248
commit abb4eb0edb
3 files changed
+34 -18

No files matched your search

+26 -12
View File
@@ -219,15 +219,22 @@ end
post '/shipping/zpl' do
zpl = params[:zpl].to_s
name = params[:save_as].to_s
if zpl.strip.empty?
flash 'ZPL text is empty', 'warning'
elsif name.empty?
flash 'Name is required to save', 'warning'
else
LABEL_REPO.save(name: params[:save_as], type: 'zpl', content: zpl) unless params[:save_as].to_s.empty?
begin
print_to_datamax(zpl)
flash 'ZPL sent to printer', 'success'
rescue => e
flash "ZPL print failed (#{e.message})", 'danger'
LABEL_REPO.save(name: name, type: 'zpl', content: zpl)
if params[:commit] == 'save_and_print'
begin
print_to_datamax(zpl)
flash "Saved '#{name}' and sent to printer", 'success'
rescue => e
flash "Saved '#{name}', but print failed (#{e.message})", 'danger'
end
else
flash "Saved '#{name}'", 'success'
end
end
redirect '/upload'
@@ -296,15 +303,22 @@ end
post '/epson/raw' do
content = params[:content].to_s
name = params[:save_as].to_s
if content.strip.empty?
flash 'Receipt text is empty', 'warning'
elsif name.empty?
flash 'Name is required to save', 'warning'
else
LABEL_REPO.save(name: params[:save_as], type: 'escpos', content: content) unless params[:save_as].to_s.empty?
begin
print_raw_escpos(content)
flash 'Sent to Epson printer', 'success'
rescue => e
flash "Epson print failed (#{e.message})", 'danger'
LABEL_REPO.save(name: name, type: 'escpos', content: content)
if params[:commit] == 'save_and_print'
begin
print_raw_escpos(content)
flash "Saved '#{name}' and sent to printer", 'success'
rescue => e
flash "Saved '#{name}', but print failed (#{e.message})", 'danger'
end
else
flash "Saved '#{name}'", 'success'
end
end
redirect '/epson'