File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed
app/assets/javascripts/resources Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -613,8 +613,47 @@ QueryBuilder = {
613613 configured : {
614614 check_validity_of_file_content : function ( file_data ) {
615615 var result = { valid : true , description : "" } ;
616+ var blocks = QueryBuilder . convert . configured . get_string_blocks ( file_data ) ;
617+ var block_types = [ "variable_dictionary" , "header" , "body" , "footer" ] ;
618+ for ( i = 0 ; i < block_types . length ; i ++ ) {
619+ result . valid = QueryBuilder . convert . configured . check_file_body_item ( blocks , block_types [ i ] ) ;
620+ if ( result . valid == false ) {
621+ result . description = "These seems to be some problem with the <strong>" + block_types [ i ] + "</strong> section of your template. Please correct it and upload again." ;
622+ break ;
623+ }
624+ }
616625 return result ;
617626 } ,
627+ check_file_body_item : function ( blocks , block_type ) {
628+ var result = false ;
629+
630+ var inside = false ;
631+ var break_loop = false ;
632+ for ( i = 0 ; i < blocks . length ; i ++ ) {
633+ if ( blocks [ i ] . charAt ( 0 ) == '{' && blocks [ i ] . charAt ( 1 ) == '{' && blocks [ i ] . charAt ( blocks [ i ] . length - 1 ) == '}' && blocks [ i ] . charAt ( blocks [ i ] . length - 2 ) == '}' )
634+ {
635+ if ( blocks [ i ] . indexOf ( "start" ) > - 1 && inside == false ) {
636+ if ( blocks [ i ] . indexOf ( block_type ) > - 1 ) {
637+ inside = true ;
638+ }
639+ }
640+ else if ( blocks [ i ] . indexOf ( "start" ) > - 1 && inside == true ) {
641+ //nested block.
642+ //will throw an errow.
643+ break_loop = true ;
644+ result = false ;
645+ }
646+ else if ( inside == true && blocks [ i ] . indexOf ( "end" ) ) {
647+ result = true ;
648+ break_loop = true ;
649+ }
650+ }
651+ if ( break_loop == true )
652+ break ;
653+ }
654+ return result ;
655+ }
656+ ,
618657 handle_error_output : function ( valid , error_description ) {
619658 if ( valid == true ) {
620659 $ ( ".configured-download-file-ok" ) . show ( "fast" ) ;
You can’t perform that action at this time.
0 commit comments