2020-10-27 00:01:34 +00:00
import TagRenderingConfig from "./JSON/TagRenderingConfig" ;
2020-11-21 15:44:48 +00:00
import * as questions from "../assets/tagRenderings/questions.json" ;
import * as icons from "../assets/tagRenderings/icons.json" ;
2020-10-27 00:01:34 +00:00
export default class SharedTagRenderings {
public static SharedTagRendering = SharedTagRenderings . generatedSharedFields ( ) ;
2020-12-05 23:20:27 +00:00
public static SharedIcons = SharedTagRenderings . generatedSharedFields ( true ) ;
2020-10-27 00:01:34 +00:00
2020-12-05 23:20:27 +00:00
private static generatedSharedFields ( iconsOnly = false ) {
2020-10-27 00:01:34 +00:00
const dict = { }
2020-12-05 23:20:27 +00:00
function add ( key , store ) {
2020-10-27 00:01:34 +00:00
try {
2020-12-08 22:44:34 +00:00
dict [ key ] = new TagRenderingConfig ( store [ key ] , key )
2020-10-27 00:01:34 +00:00
} catch ( e ) {
2020-12-08 22:44:34 +00:00
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 00:01:34 +00:00
}
}
2020-12-05 23:20:27 +00:00
if ( ! iconsOnly ) {
for ( const key in questions ) {
add ( key , questions ) ;
}
2020-11-21 15:44:48 +00:00
}
for ( const key in icons ) {
add ( key , icons ) ;
}
2020-12-05 23:20:27 +00:00
2020-10-27 00:01:34 +00:00
return dict ;
}
}