Skip to content

Commit

Permalink
Merge pull request #60 from ezeep/feature/printer-trays
Browse files Browse the repository at this point in the history
Make Trays from Blob Capabilities available in Print Now/ezeep.js
  • Loading branch information
tp-shery authored Dec 15, 2023
2 parents 4ba1af0 + c041cc9 commit 846bcac
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/components/ezp-icon/assets/glyph-paper_range.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/components/ezp-icon/assets/glyph-trays.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 @@ -85,6 +85,7 @@ export class EzpPrinterSelection {
Resolutions: [],
DuplexSupported: false,
Color: false,
Trays: []
}

// needs to be initialised with empty strings
Expand All @@ -99,6 +100,8 @@ export class EzpPrinterSelection {
resolution: 0,
paperlength : 0,
paperwidth : 0,
defaultSource: '',
trayname: '',
PageRanges : '',
}

Expand Down Expand Up @@ -217,6 +220,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: PrinterProperties = removeEmptyStrings(this.selectedProperties)
cleanPrintProperties = managePaperDimensions(cleanPrintProperties)
if (cleanPrintProperties.PageRanges)
Expand Down Expand Up @@ -315,7 +322,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 @@ -381,6 +388,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 'paper_ranges':
this.selectedProperties.PageRanges = eventDetails.value;
this.pageRangeInvalid = !validatePageRange(this.selectedProperties.PageRanges);
Expand Down Expand Up @@ -792,8 +809,22 @@ 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="trays"
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}
<ezp-input
icon="width"
icon="paper_range"
suffix=""
placeholder="1-2,4-5,8"
value={this.selectedProperties.PageRanges}
Expand Down
3 changes: 3 additions & 0 deletions src/data/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
"pull_print_success": "Bereit zum Auslösen.",
"width":"Breite",
"length":"Länge",
"trays": "Trays",
"select_trays": "Wähle Trays",
"page_ranges": "Page Ranges",
"paper_ranges": "Papier-Ranges"
},
"button_actions": {
Expand Down
3 changes: 3 additions & 0 deletions src/data/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
"copies": "Copies",
"width":"Width",
"length":"Length",
"trays": "Trays",
"select_trays": "Select Trays",
"page_ranges": "Page Ranges",
"paper_ranges": "Paper Ranges"
},
"button_actions": {
Expand Down
12 changes: 12 additions & 0 deletions src/shared/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ export type IconNameTypes =
| 'size'
| 'system'
| 'width'
| 'paper_range'
| 'trays'
export type IconSizeTypes = 'normal' | 'large' | 'huge'
export type PrintOrganizationType = { id: number; name: string; printers: PrintPrinterType[] }
export type PrintPrinterType = { id: number; name: string; location: string }
Expand Down Expand Up @@ -64,6 +66,8 @@ export interface PrinterProperties {
resolution?: string | number
paperlength? : string | number
paperwidth? : string | number
defaultSource?: number | string
trayname?: string
PageRanges? : string
}

Expand All @@ -80,6 +84,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 @@ -96,6 +107,7 @@ export interface PrinterConfig {
PaperFormats?: Array<PaperFormat>
Resolutions?: Array<string>
TPUID?: number
Trays?: Array<Trays>
}

export interface User {
Expand Down

0 comments on commit 846bcac

Please sign in to comment.