File tree Expand file tree Collapse file tree 2 files changed +27
-9
lines changed
Expand file tree Collapse file tree 2 files changed +27
-9
lines changed Original file line number Diff line number Diff line change @@ -78,20 +78,20 @@ describe('DisplayFile tests', () => {
7878 {
7979 name : "COLOR" ,
8080 value : "BLU" ,
81- conditions : [ ]
81+ conditional : new Conditional ( )
8282 } ,
8383 {
8484 name : "DSPATR" ,
8585 value : "PR" ,
86- conditions : [ ]
86+ conditional : new Conditional ( ` 31` )
8787 }
8888 ) ;
8989
9090 lines = DisplayFile . getLinesForField ( field ) ;
9191 expect ( lines . length ) . toBe ( 3 ) ;
9292 expect ( lines [ 0 ] ) . toBe ( ` A 4 10'Some text'` ) ;
9393 expect ( lines [ 1 ] ) . toBe ( ` A COLOR(BLU)` ) ;
94- expect ( lines [ 2 ] ) . toBe ( ` A DSPATR(PR)` ) ;
94+ expect ( lines [ 2 ] ) . toBe ( ` A 31 DSPATR(PR)` ) ;
9595
9696 } ) ;
9797
Original file line number Diff line number Diff line change @@ -346,10 +346,7 @@ export class DisplayFile {
346346 }
347347
348348 for ( const keyword of field . keywords ) {
349- // TODO: support conditions
350- newLines . push (
351- ` A ${ keyword . name } ${ keyword . value ? `(${ keyword . value } )` : `` } ` ,
352- ) ;
349+ newLines . push ( ...keyword . conditional . getLinesWithCondition ( ` A ${ keyword . name } ${ keyword . value ? `(${ keyword . value } )` : `` } ` ) ) ;
353350 }
354351
355352 return newLines ;
@@ -614,8 +611,29 @@ export class Conditional {
614611 return this . conditions ;
615612 }
616613
617- getLines ( line : string ) : string [ ] {
618- return [ ] ;
614+ getLinesWithCondition ( line : string ) : string [ ] {
615+ if ( this . conditions . length == 1 && this . conditions [ 0 ] . indicators . length == 0 ) {
616+ return [ line ] ;
617+ }
618+ let lines : string [ ] = [ ] ;
619+ this . conditions . forEach ( ( condition , cIdx ) => {
620+ let i = 0 ;
621+ let line = `` ;
622+ condition . indicators . forEach ( ind => {
623+ if ( i >= 3 ) {
624+ lines . push ( line . padEnd ( 16 ) ) ;
625+ i = 0 ;
626+ }
627+ if ( i == 0 ) {
628+ line = ` A${ cIdx > 0 ? "O" : " " } ` ;
629+ }
630+ i ++ ;
631+ line += `${ ind . negate ? `N` : ` ` } ${ String ( ind . indicator ) . padStart ( 2 , '0' ) } ` ;
632+ } ) ;
633+ lines . push ( line . padEnd ( 16 ) ) ;
634+ } ) ;
635+ lines [ lines . length - 1 ] = lines [ lines . length - 1 ] . substring ( 0 , 16 ) + line . substring ( 16 ) ;
636+ return lines ;
619637 }
620638
621639}
You can’t perform that action at this time.
0 commit comments