@@ -72,6 +72,7 @@ export class ExportCardsComponent implements OnInit {
7272 public maxTtsPixels : number = 4096 ;
7373 public scale : number = 0.1 ;
7474 public exportSelectionDialogVisible : boolean = false ;
75+ public excludeCardBacks : boolean = false ;
7576 public someCardsMissingTemplates : boolean = false ;
7677 renderCache : boolean = false ;
7778 zoomOptions : any [ ] = [
@@ -88,7 +89,7 @@ export class ExportCardsComponent implements OnInit {
8889 private confirmationService : ConfirmationService ) {
8990 cardsService . getAll ( ) . then ( cards => {
9091 // check cards for front/back templates being defined
91- const cardsWithTemplatesDefined = cards . filter ( card => card . backCardTemplateId && card . frontCardTemplateId ) ;
92+ const cardsWithTemplatesDefined = cards . filter ( card => card . frontCardTemplateId ) ;
9293 this . someCardsMissingTemplates = cards . length != cardsWithTemplatesDefined . length ;
9394 this . originalCards = cardsWithTemplatesDefined ;
9495 this . cards = cardsWithTemplatesDefined ;
@@ -184,7 +185,7 @@ export class ExportCardsComponent implements OnInit {
184185 this . cardsPerPage = 6 ;
185186 this . pixelRatio = 1 ;
186187 this . showFront = true ;
187- this . showBack = true ;
188+ this . showBack = ! this . excludeCardBacks ;
188189 this . updateSlices ( ) ;
189190 }
190191 // console.log('change paper type', this.selectedPaper.name, this.mirrorBacksX, this.mirrorBacksY);
@@ -235,7 +236,7 @@ export class ExportCardsComponent implements OnInit {
235236 const renderSlices = this . sliceIntoChunks ( this . cards , sliceSize ) ;
236237 const hardLimit = pLimit ( 1 ) ;
237238 this . showFront = true ;
238- this . showBack = true ;
239+ this . showBack = ! this . excludeCardBacks ;
239240 this . renderCache = true ;
240241 this . loadingPercent = 0 ;
241242 const preRenders$ = renderSlices . map ( ( slice , index ) => {
@@ -269,8 +270,10 @@ export class ExportCardsComponent implements OnInit {
269270 await this . prerenderCardImages ( ) ;
270271 this . loadingPercent = 0 ;
271272
273+ const exportSides = this . excludeCardBacks ? [ true ] : [ true , false ] ;
274+
272275 const promisedSheetImages$ = this . slicedCards . map ( ( sheet , sheetIndex ) => {
273- return Promise . all ( [ true , false ] . map ( async ( showFront ) => {
276+ return Promise . all ( exportSides . map ( async ( showFront ) => {
274277 return await hardLimit ( async ( ) => {
275278 this . sheet = sheet ;
276279 this . showFront = showFront ;
@@ -397,18 +400,23 @@ export class ExportCardsComponent implements OnInit {
397400 const imgName = 'front-' + imgIdentifier + '.png' ;
398401 return this . dataUrlToFile ( imgUri , imgName ) ;
399402 } ) ;
400- const backCards$ = this . backCards . map ( async cardPreview => {
401- await lastValueFrom ( cardPreview . isCacheLoaded ( ) ) . catch ( ( ) => {
402- return Promise . reject ( 'Failed to render card "' + cardPreview . card . name + '" with template "' + cardPreview . template . name + '".' ) ;
403+
404+ let backCards$ : Promise < File > [ ] = [ ] ;
405+ if ( ! this . excludeCardBacks ) {
406+ backCards$ = this . backCards . map ( async cardPreview => {
407+ await lastValueFrom ( cardPreview . isCacheLoaded ( ) ) . catch ( ( ) => {
408+ return Promise . reject ( 'Failed to render card "' + cardPreview . card . name + '" with template "' + cardPreview . template . name + '".' ) ;
409+ } ) ;
410+ const imgUri = await limit ( ( ) => this . imageRendererService . toPng ( ( < any > cardPreview ) . element . nativeElement ,
411+ { pixelRatio : this . individualExportPixelRatio } ) ) ;
412+ const imgIdentifier = this . individualExportUseCardName
413+ ? StringUtils . toKebabCase ( cardPreview . card ?. name )
414+ : cardPreview . card ?. id ;
415+ const imgName = 'back-' + imgIdentifier + '.png' ;
416+ return this . dataUrlToFile ( imgUri , imgName ) ;
403417 } ) ;
404- const imgUri = await limit ( ( ) => this . imageRendererService . toPng ( ( < any > cardPreview ) . element . nativeElement ,
405- { pixelRatio : this . individualExportPixelRatio } ) ) ;
406- const imgIdentifier = this . individualExportUseCardName
407- ? StringUtils . toKebabCase ( cardPreview . card ?. name )
408- : cardPreview . card ?. id ;
409- const imgName = 'back-' + imgIdentifier + '.png' ;
410- return this . dataUrlToFile ( imgUri , imgName ) ;
411- } ) ;
418+ }
419+
412420 const allCards$ = frontCards$ . concat ( backCards$ ) ;
413421 return Promise . all ( this . promisesProgress ( allCards$ , ( ) => this . loadingPercent += 100.0 / ( allCards$ . length + 1 ) ) )
414422 . then ( promisedImages => {
0 commit comments