Skip to content

Commit

Permalink
Fix page range formatting issue
Browse files Browse the repository at this point in the history
  • Loading branch information
tp-shery committed Dec 13, 2023
1 parent c6e05a4 commit 61014fc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import userStore, { EzpUserService } from '../../services/user'
import { Printer, PrinterConfig, PrinterProperties } from '../../shared/types'
import { managePaperDimensions, poll, removeEmptyStrings } from '../../utils/utils'
import { BlobUploadCommonResponse } from '@azure/storage-blob'
import { PAPER_ID , validatePageRange } from '../../utils/utils'
import { PAPER_ID , validatePageRange , formatPageRange } from '../../utils/utils'

@Component({
tag: 'ezp-printer-selection',
Expand Down Expand Up @@ -217,8 +217,11 @@ 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
let cleanPrintProperties = removeEmptyStrings(this.selectedProperties)
let cleanPrintProperties: PrinterProperties = removeEmptyStrings(this.selectedProperties)
cleanPrintProperties = managePaperDimensions(cleanPrintProperties)
if (cleanPrintProperties.PageRanges)
cleanPrintProperties.PageRanges = formatPageRange(cleanPrintProperties.PageRanges)

// put it in store for further use
printStore.state.fileUrl = this.fileurl
printStore.state.fileID = this.fileid
Expand Down Expand Up @@ -381,6 +384,7 @@ export class EzpPrinterSelection {
case 'paper_ranges':
this.selectedProperties.PageRanges = eventDetails.value;
this.pageRangeInvalid = !validatePageRange(this.selectedProperties.PageRanges);

// console.log(this.selectedProperties.PageRanges)
break
case 'duplex':
Expand Down
4 changes: 4 additions & 0 deletions src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ export const managePaperDimensions = (properties :PrinterProperties)=>{
return properties
}

export const formatPageRange = (pageRange) => {
return pageRange.replace(/,/g, ';')
}

export const validatePageRange = (pageRange) => {
if (!pageRange) {
return true
Expand Down

0 comments on commit 61014fc

Please sign in to comment.