2020-10-27 01:01:34 +01:00
import TagRenderingConfig from "./JSON/TagRenderingConfig" ;
2020-11-21 16:44:48 +01:00
import * as questions from "../assets/tagRenderings/questions.json" ;
import * as icons from "../assets/tagRenderings/icons.json" ;
2021-07-04 20:36:19 +02:00
import { Utils } from "../Utils" ;
2020-10-27 01:01:34 +01:00
export default class SharedTagRenderings {
2021-04-21 01:26:36 +02:00
public static SharedTagRendering : Map < string , TagRenderingConfig > = SharedTagRenderings . generatedSharedFields ( ) ;
public static SharedIcons : Map < string , TagRenderingConfig > = SharedTagRenderings . generatedSharedFields ( true ) ;
2020-10-27 01:01:34 +01:00
2021-04-21 01:26:36 +02:00
private static generatedSharedFields ( iconsOnly = false ) : Map < string , TagRenderingConfig > {
const dict = new Map < string , TagRenderingConfig > ( ) ;
2020-12-06 00:20:27 +01:00
function add ( key , store ) {
2020-10-27 01:01:34 +01:00
try {
2021-06-27 20:35:38 +02:00
dict . set ( key , new TagRenderingConfig ( store [ key ] , undefined , ` SharedTagRenderings. ${ key } ` ) )
2020-10-27 01:01:34 +01:00
} catch ( e ) {
2021-07-04 20:36:19 +02:00
if ( ! Utils . runningFromConsole ) {
console . error ( "BUG: could not parse" , key , " from questions.json or icons.json - this error happened during the build step of the SharedTagRenderings" , e )
}
2020-10-27 01:01:34 +01:00
}
}
2020-12-06 00:20:27 +01:00
if ( ! iconsOnly ) {
for ( const key in questions ) {
add ( key , questions ) ;
}
2020-11-21 16:44:48 +01:00
}
for ( const key in icons ) {
add ( key , icons ) ;
}
2020-12-06 00:20:27 +01:00
2020-10-27 01:01:34 +01:00
return dict ;
}
}