Skip to content
This repository was archived by the owner on Jul 24, 2019. It is now read-only.

Commit 4c26ad6

Browse files
McSamMcSam
authored andcommitted
improved
1 parent 42366b6 commit 4c26ad6

File tree

14 files changed

+235
-114
lines changed

14 files changed

+235
-114
lines changed

src/assets/sass/scratch/_toolbox.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
@import '../base/mixins';
22

33
$category-colours: (
4+
search : #afffda,
45
trade-definition: #303f9f,
56
before-purchase : #00897b,
67
during-purchase : #78909c,
@@ -114,4 +115,11 @@ $category-colours: (
114115
}
115116
}
116117
}
118+
119+
#search_input {
120+
padding: 10px;
121+
border-radius: 5px;
122+
border: solid $grey 1px;
123+
margin: 3px;
124+
}
117125
}

src/scratch/blocks/Advanced/Functions/procedures_callreturn.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1+
import { translate } from '../../../../utils/lang/i18n';
2+
13
Blockly.Blocks.procedures_callreturn = {
24
init() {
35
this.arguments = [];
46
this.previousDisabledState = false;
57

6-
this.jsonInit({
8+
this.jsonInit(this.definition());
9+
},
10+
definition(){
11+
return {
712
message0: '%1 %2',
813
args0 : [
914
{
@@ -20,7 +25,15 @@ Blockly.Blocks.procedures_callreturn = {
2025
colour : Blockly.Colours.BinaryProcedures.colour,
2126
colourSecondary: Blockly.Colours.BinaryProcedures.colourSecondary,
2227
colourTertiary : Blockly.Colours.BinaryProcedures.colourTertiary,
23-
});
28+
tooltip : translate('Function with return value'),
29+
category : translate('functions'),
30+
};
31+
},
32+
meta(){
33+
return {
34+
'display_name': translate('Function with return value'),
35+
'description' : translate('Function with return value Description'),
36+
};
2437
},
2538
onchange : Blockly.Blocks.procedures_callnoreturn.onchange,
2639
getProcedureDefinition: Blockly.Blocks.procedures_callnoreturn.getProcedureDefinition,

src/scratch/blocks/Advanced/Functions/procedures_defreturn.js

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,21 @@ Blockly.Blocks.procedures_defreturn = {
66
this.arguments = [];
77
this.argumentVarModels = [];
88

9-
this.jsonInit({
9+
this.jsonInit(this.definition());
10+
11+
// Enforce unique procedure names
12+
const nameField = this.getField('NAME');
13+
nameField.setValidator(Blockly.Procedures.rename);
14+
15+
// Render a ➕-icon for adding parameters
16+
const fieldImage = new Blockly.FieldImage(plusIconDark, 24, 24, '+', () => this.onAddClick());
17+
this.appendDummyInput('ADD_ICON').appendField(fieldImage);
18+
this.moveInputBefore('ADD_ICON', 'RETURN');
19+
20+
this.setStatements(true);
21+
},
22+
definition(){
23+
return {
1024
message0: translate('function %1 %2 %3'),
1125
message1: 'return %1',
1226
args0 : [
@@ -35,18 +49,15 @@ Blockly.Blocks.procedures_defreturn = {
3549
colour : Blockly.Colours.BinaryProcedures.colour,
3650
colourSecondary: Blockly.Colours.BinaryProcedures.colourSecondary,
3751
colourTertiary : Blockly.Colours.BinaryProcedures.colourTertiary,
38-
});
39-
40-
// Enforce unique procedure names
41-
const nameField = this.getField('NAME');
42-
nameField.setValidator(Blockly.Procedures.rename);
43-
44-
// Render a ➕-icon for adding parameters
45-
const fieldImage = new Blockly.FieldImage(plusIconDark, 24, 24, '+', () => this.onAddClick());
46-
this.appendDummyInput('ADD_ICON').appendField(fieldImage);
47-
this.moveInputBefore('ADD_ICON', 'RETURN');
48-
49-
this.setStatements(true);
52+
tooltip : translate('Function def with return value'),
53+
category : translate('functions'),
54+
};
55+
},
56+
meta(){
57+
return {
58+
'display_name': translate('Function def with return value'),
59+
'description' : translate('Function def with return value Description'),
60+
};
5061
},
5162
onAddClick : Blockly.Blocks.procedures_defnoreturn.onAddClick,
5263
onchange : Blockly.Blocks.procedures_defnoreturn.onchange,

src/scratch/blocks/Advanced/Functions/procedures_ifreturn.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ Blockly.Blocks.procedures_ifreturn = {
99
init() {
1010
this.hasReturnValue = true;
1111

12-
this.jsonInit({
12+
this.jsonInit(this.definition());
13+
},
14+
definition(){
15+
return {
1316
message0: translate('if %1 return %2'),
1417
args0 : [
1518
{
@@ -26,7 +29,15 @@ Blockly.Blocks.procedures_ifreturn = {
2629
colourTertiary : Blockly.Colours.BinaryProcedures.colourTertiary,
2730
previousStatement: null,
2831
nextStatement : null,
29-
});
32+
tooltip : translate('Function If Else'),
33+
category : translate('functions'),
34+
};
35+
},
36+
meta(){
37+
return {
38+
'display_name': translate('Function If else'),
39+
'description' : translate('Function If else Description'),
40+
};
3041
},
3142
/**
3243
* Create XML to represent whether this block has a return value.

src/scratch/blocks/Advanced/List/lists_create_with.js

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,15 @@ import { translate } from '../../../../utils/lang/i18n';
33

44
Blockly.Blocks.lists_create_with = {
55
init() {
6-
this.jsonInit({
6+
this.jsonInit(this.definition());
7+
8+
// Render a ➕-icon for adding additional `lists_statement` blocks
9+
const fieldImage = new Blockly.FieldImage(plusIconDark, 25, 25, '', () => this.onIconClick());
10+
this.appendDummyInput('ADD_ICON').appendField(fieldImage);
11+
this.moveInputBefore('ADD_ICON', 'STACK');
12+
},
13+
definition(){
14+
return {
715
message0: translate('set %1 to create list with'),
816
message1: '%1',
917
args0 : [
@@ -24,12 +32,15 @@ Blockly.Blocks.lists_create_with = {
2432
colourTertiary : Blockly.Colours.Binary.colourTertiary,
2533
previousStatement: null,
2634
nextStatement : null,
27-
});
28-
29-
// Render a ➕-icon for adding additional `lists_statement` blocks
30-
const fieldImage = new Blockly.FieldImage(plusIconDark, 25, 25, '', () => this.onIconClick());
31-
this.appendDummyInput('ADD_ICON').appendField(fieldImage);
32-
this.moveInputBefore('ADD_ICON', 'STACK');
35+
tooltip : translate('Create List with'),
36+
category : translate('list'),
37+
};
38+
},
39+
meta(){
40+
return {
41+
'display_name': translate('Create list with'),
42+
'description' : translate('Create list with description'),
43+
};
3344
},
3445
onIconClick() {
3546
if (!this.workspace || this.isInFlyout) {

src/scratch/blocks/Binary/After Purchase/check_result.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ import { translate } from '../../../../utils/lang/i18n';
33

44
Blockly.Blocks.contract_check_result = {
55
init() {
6-
this.jsonInit({
6+
this.jsonInit(this.definition());
7+
},
8+
definition(){
9+
return {
710
message0: translate('Result is %1'),
811
args0 : [
912
{
@@ -18,7 +21,14 @@ Blockly.Blocks.contract_check_result = {
1821
colourSecondary: Blockly.Colours.Binary.colourSecondary,
1922
colourTertiary : Blockly.Colours.Binary.colourTertiary,
2023
tooltip : translate('True if the result matches the selection'),
21-
});
24+
category : translate('after-purchase'),
25+
};
26+
},
27+
meta(){
28+
return {
29+
'display_name': translate('Check Result'),
30+
'description' : translate('Check Result Description'),
31+
};
2232
},
2333
onchange(event) {
2434
if (!this.workspace || this.isInFlyout || this.workspace.isDragging()) {

src/scratch/blocks/Binary/After Purchase/read_details.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ import { translate } from '../../../../utils/lang/i18n';
33

44
Blockly.Blocks.read_details = {
55
init() {
6-
this.jsonInit({
6+
this.jsonInit(this.definition());
7+
},
8+
definition(){
9+
return {
710
message0: translate('Contract Detail: %1'),
811
args0 : [
912
{
@@ -17,7 +20,15 @@ Blockly.Blocks.read_details = {
1720
colourSecondary: Blockly.Colours.Binary.colourSecondary,
1821
colourTertiary : Blockly.Colours.Binary.colourTertiary,
1922
tooltip : translate('Reads a selected option from contract details list'),
20-
});
23+
category : translate('after-purchase'),
24+
};
25+
},
26+
meta(){
27+
return {
28+
'display_name': translate('Read Detail Block'),
29+
'description' : translate('Read Detail Description'),
30+
31+
};
2132
},
2233
onchange(event) {
2334
if (!this.workspace || this.isInFlyout || this.workspace.isDragging()) {

src/scratch/blocks/Binary/After Purchase/trade_again.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,27 @@ import { translate } from '../../../../utils/lang/i18n';
22

33
Blockly.Blocks.trade_again = {
44
init() {
5-
this.jsonInit({
5+
this.jsonInit(this.definition());
6+
7+
// Ensure one of this type per statement-stack
8+
this.setNextStatement(false);
9+
},
10+
definition(){
11+
return {
612
message0 : translate('Trade Again'),
713
colour : Blockly.Colours.Binary.colour,
814
colourSecondary : Blockly.Colours.Binary.colourSecondary,
915
colourTertiary : Blockly.Colours.Binary.colourTertiary,
1016
previousStatement: null,
1117
tooltip : translate('Runs the trade block again'),
12-
});
13-
14-
// Ensure one of this type per statement-stack
15-
this.setNextStatement(false);
18+
category : translate('after-purchase'),
19+
};
20+
},
21+
meta(){
22+
return {
23+
'display_name': translate('Trade Again'),
24+
'description' : translate('Trade Again Description'),
25+
};
1626
},
1727
onchange(event) {
1828
if (!this.workspace || this.isInFlyout || this.workspace.isDragging()) {

src/scratch/blocks/Binary/Before Purchase/ask_price.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ import { translate } from '../../../../utils/lang/i18n';
33

44
Blockly.Blocks.ask_price = {
55
init() {
6-
this.jsonInit({
6+
this.jsonInit(this.definition());
7+
},
8+
definition(){
9+
return {
710
message0: translate('Ask Price %1'),
811
args0 : [
912
{
@@ -18,7 +21,14 @@ Blockly.Blocks.ask_price = {
1821
colourSecondary: Blockly.Colours.Binary.colourSecondary,
1922
colourTertiary : Blockly.Colours.Binary.colourTertiary,
2023
tooltip : translate('Ask Price for selected proposal'),
21-
});
24+
category : translate('before-purchase'),
25+
};
26+
},
27+
meta(){
28+
return {
29+
'display_name': translate('Ask Price'),
30+
'description' : translate('Ask Price Description'),
31+
};
2232
},
2333
onchange(event) {
2434
if (!this.workspace || this.isInFlyout || this.workspace.isDragging()) {

src/scratch/blocks/Binary/Before Purchase/payout.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ import { translate } from '../../../../utils/lang/i18n';
33

44
Blockly.Blocks.payout = {
55
init() {
6-
this.jsonInit({
6+
this.jsonInit(this.definition());
7+
},
8+
definition(){
9+
return {
710
message0: translate('Payout %1'),
811
args0 : [
912
{
@@ -18,7 +21,14 @@ Blockly.Blocks.payout = {
1821
colourSecondary: Blockly.Colours.Binary.colourSecondary,
1922
colourTertiary : Blockly.Colours.Binary.colourTertiary,
2023
tooltip : translate('Payout for selected proposal'),
21-
});
24+
category : translate('before-purchase'),
25+
};
26+
},
27+
meta(){
28+
return {
29+
'display_name': translate('Payout'),
30+
'description' : translate('Payout Description'),
31+
};
2232
},
2333
onchange(event) {
2434
if (!this.workspace || this.isInFlyout || this.workspace.isDragging()) {

0 commit comments

Comments
 (0)