Skip to content

Commit

Permalink
Make Trays from Blob Capabilities available in Print Now/ezeep.js
Browse files Browse the repository at this point in the history
  • Loading branch information
tp-teman committed Dec 15, 2023
1 parent d58d2ea commit a860373
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 4 deletions.
35 changes: 33 additions & 2 deletions src/components/ezp-printer-selection/ezp-printer-selection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export class EzpPrinterSelection {
Resolutions: [],
DuplexSupported: false,
Color: false,
Trays: []
}

// needs to be initialised with empty strings
Expand All @@ -97,7 +98,9 @@ export class EzpPrinterSelection {
copies: '',
resolution: 0,
paperlength : 0,
paperwidth : 0
paperwidth : 0,
defaultSource: '',
trayname: ''
}

@State() paperid: number | string
Expand Down Expand Up @@ -215,6 +218,10 @@ export class EzpPrinterSelection {
this.printProcessing = true
// we have to initialse this obj with empty strings to display the select component
// but don't want to send any attributes with empty strings to the API
if (this.selectedPrinterConfig.Trays && this.selectedPrinterConfig.Trays.length >= 0 && this.selectedPrinterConfig.Trays[0] == null) {
delete this.selectedProperties.trayname
delete this.selectedProperties.defaultSource
}
let cleanPrintProperties = removeEmptyStrings(this.selectedProperties)
cleanPrintProperties = managePaperDimensions(cleanPrintProperties)
// put it in store for further use
Expand Down Expand Up @@ -310,7 +317,7 @@ export class EzpPrinterSelection {
} else {
this.selectedPrinter = { id: '', location: '', name: '', is_queue: false }
localStorage.removeItem('printer')
localStorage.removeItem('properties')
localStorage.removeItem('properties')
}
} else {
this.selectedPrinter = { id: '', location: '', name: '', is_queue: false }
Expand Down Expand Up @@ -376,6 +383,16 @@ export class EzpPrinterSelection {
this.selectedProperties.paperwidth = eventDetails.value
// console.log(this.selectedProperties)
break
case 'tray':
if(this.selectedPrinterConfig.Trays && this.selectedPrinterConfig.Trays.length >= 0 && this.selectedPrinterConfig.Trays[0] == null) {
delete this.selectedProperties.trayname
delete this.selectedProperties.defaultSource
}
if(this.selectedPrinterConfig.Trays && this.selectedPrinterConfig.Trays.length >= 1 && this.selectedPrinterConfig.Trays[0] != null) {
this.selectedProperties.trayname = eventDetails.title
this.selectedProperties.defaultSource = eventDetails.id
}
break
case 'duplex':
if (eventDetails.title === 'None') {
this.selectedProperties.duplex = false
Expand Down Expand Up @@ -781,6 +798,20 @@ export class EzpPrinterSelection {
preSelected={this.selectedPrinter.id ? this.selectedProperties.resolution : null}
disabled={!(this.selectedPrinterConfig.Resolutions.length > 0)}
/>
{this.selectedPrinterConfig.Trays.length >= 1 && this.selectedPrinterConfig.Trays[0] != null ? (
<ezp-select
label={i18next.t('printer_selection.trays')}
icon="size"
placeholder={i18next.t('printer_selection.select_trays')}
toggleFlow="horizontal"
optionFlow="horizontal"
options={this.selectedPrinterConfig.Trays.length >= 1 && this.selectedPrinterConfig.Trays.map((trays) => ({
title: trays.Name,
id: trays.Index,
meta: '',
type: 'tray',
}))}
/> ) : null}
</div>
<ezp-stepper label={i18next.t('printer_selection.copies')} max={10} icon="copies" />
</div>
Expand Down
5 changes: 4 additions & 1 deletion src/data/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@
"duplex_short": "auf der kurzen Seite umdrehen",
"pull_print_success": "Bereit zum Auslösen.",
"width":"Breite",
"length":"Länge"
"length":"Länge",
"trays": "Trays",
"select_trays": "Wähle Trays",
"page_ranges": "Page Ranges"
},
"button_actions": {
"login": "Anmelden",
Expand Down
5 changes: 4 additions & 1 deletion src/data/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@
"no_printers": "No printers found.",
"copies": "Copies",
"width":"Width",
"length":"Length"
"length":"Length",
"trays": "Trays",
"select_trays": "Select Trays",
"page_ranges": "Page Ranges"
},
"button_actions": {
"login": "Sign In",
Expand Down
10 changes: 10 additions & 0 deletions src/shared/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ export interface PrinterProperties {
resolution?: string | number
paperlength? : string | number
paperwidth? : string | number
defaultSource?: number | string
trayname?: string
}

export interface Printer {
Expand All @@ -79,6 +81,13 @@ export interface PaperFormat {
XRes: number
YRes: number
}

export interface Trays {
Default : boolean
Index: number
Name: string
}

export interface PrinterConfig {
Collate?: boolean
Color?: boolean
Expand All @@ -95,6 +104,7 @@ export interface PrinterConfig {
PaperFormats?: Array<PaperFormat>
Resolutions?: Array<string>
TPUID?: number
Trays?: Array<Trays>
}

export interface User {
Expand Down

0 comments on commit a860373

Please sign in to comment.