@@ -7,43 +7,42 @@ import { BlocklyError } from '../../../../../common/error';
7
7
export default ( ) => {
8
8
const symbolNames = bot . symbol . activeSymbols . getSymbolNames ( ) ;
9
9
for ( const symbol of Object . keys ( symbolNames ) ) {
10
- Blockly . Blocks [ symbol . toLowerCase ( ) ] = {
11
- init : function init ( ) {
12
- this . appendDummyInput ( )
13
- . appendField ( symbolNames [ symbol ] ) ;
14
- this . appendDummyInput ( )
15
- . appendField ( `${ translator . translateText ( 'Accepts' ) } : (${
16
- bot . symbol . getAllowedCategoryNames ( symbol ) } )`) ;
17
- this . appendStatementInput ( 'CONDITION' )
18
- . setCheck ( 'Condition' ) ;
19
- this . setInputsInline ( false ) ;
20
- this . setPreviousStatement ( true , null ) ;
21
- this . setColour ( '#f2f2f2' ) ;
22
- this . setTooltip ( `${ translator . translateText ( 'Chooses the symbol:' ) } ${ symbolNames [ symbol ] } ` ) ; // eslint-disable-line max-len
23
- this . setHelpUrl ( 'https://github.com/binary-com/binary-bot/wiki' ) ;
24
- } ,
25
- onchange : function onchange ( ev ) {
26
- submarket ( this , ev ) ;
27
- } ,
28
- } ;
29
- }
30
-
31
- for ( const symbol of Object . keys ( symbolNames ) ) {
32
- Blockly . JavaScript [ symbol . toLowerCase ( ) ] = function market ( block ) {
33
- const condition = Blockly . JavaScript . statementToCode ( block , 'CONDITION' ) ;
34
- if ( ! condition ) {
35
- return new BlocklyError (
36
- translator . translateText ( 'A trade type has to be defined for the symbol' ) ) . emit ( ) ;
37
- }
38
- const code = `
10
+ const allowedCategories = bot . symbol . getAllowedCategoryNames ( symbol ) ;
11
+ if ( allowedCategories . length ) {
12
+ Blockly . Blocks [ symbol . toLowerCase ( ) ] = {
13
+ init : function init ( ) {
14
+ this . appendDummyInput ( )
15
+ . appendField ( symbolNames [ symbol ] ) ;
16
+ this . appendDummyInput ( )
17
+ . appendField ( `${ translator . translateText ( 'Accepts' ) } : (${ allowedCategories } )` ) ;
18
+ this . appendStatementInput ( 'CONDITION' )
19
+ . setCheck ( 'Condition' ) ;
20
+ this . setInputsInline ( false ) ;
21
+ this . setPreviousStatement ( true , null ) ;
22
+ this . setColour ( '#f2f2f2' ) ;
23
+ this . setTooltip ( `${ translator . translateText ( 'Chooses the symbol:' ) } ${ symbolNames [ symbol ] } ` ) ; // eslint-disable-line max-len
24
+ this . setHelpUrl ( 'https://github.com/binary-com/binary-bot/wiki' ) ;
25
+ } ,
26
+ onchange : function onchange ( ev ) {
27
+ submarket ( this , ev ) ;
28
+ } ,
29
+ } ;
30
+ Blockly . JavaScript [ symbol . toLowerCase ( ) ] = function market ( block ) {
31
+ const condition = Blockly . JavaScript . statementToCode ( block , 'CONDITION' ) ;
32
+ if ( ! condition ) {
33
+ return new BlocklyError (
34
+ translator . translateText ( 'A trade type has to be defined for the symbol' ) ) . emit ( ) ;
35
+ }
36
+ const code = `
39
37
getTradeOptions = function getTradeOptions() {
40
38
var tradeOptions = {};
41
39
tradeOptions = ${ condition . trim ( ) } ;
42
40
tradeOptions.symbol = '${ symbol } '
43
41
return tradeOptions;
44
42
};
45
43
` ;
46
- return code ;
47
- } ;
44
+ return code ;
45
+ } ;
46
+ }
48
47
}
49
48
} ;
0 commit comments