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

Commit debc4a4

Browse files
McSamMcSam
authored andcommitted
add definition & meta to blocks
1 parent ee83684 commit debc4a4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+652
-148
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ Blockly.Blocks.lists_getIndex = {
3434

3535
this.updateAt(true);
3636
},
37+
meta(){
38+
return {
39+
'display_name': translate('List Get Index'),
40+
'description' : translate('List Get Index Description'),
41+
};
42+
},
3743
mutationToDom() {
3844
const container = document.createElement('mutation');
3945
const isStatement = !this.outputConnection;

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ Blockly.Blocks.lists_getSublist = {
2929
this.updateAt(1, true);
3030
this.updateAt(2, true);
3131
},
32+
meta() {
33+
return {
34+
'display_name': translate('List get sublit'),
35+
'description' : translate('List get sublist description'),
36+
};
37+
},
3238
mutationToDom() {
3339
const container = document.createElement('mutation');
3440
const isAt1 = this.getInput('AT1').type === Blockly.INPUT_VALUE;

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

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

33
Blockly.Blocks.lists_indexOf = {
44
init() {
5-
this.jsonInit({
5+
this.jsonInit(this.definition());
6+
},
7+
definition(){
8+
return {
69
message0: translate('in list %1 find %2 occurence of item %3'),
710
args0 : [
811
{
@@ -24,7 +27,15 @@ Blockly.Blocks.lists_indexOf = {
2427
colour : Blockly.Colours.Binary.colour,
2528
colourSecondary: Blockly.Colours.Binary.colourSecondary,
2629
colourTertiary : Blockly.Colours.Binary.colourTertiary,
27-
});
30+
tooltip : translate('Index of List Tooltip'),
31+
category : 'list',
32+
};
33+
},
34+
meta(){
35+
return {
36+
'display_name': translate('Index Of List'),
37+
'description' : translate('Index of List Description'),
38+
};
2839
},
2940
};
3041

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

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

33
Blockly.Blocks.lists_isEmpty = {
44
init() {
5-
this.jsonInit({
5+
this.jsonInit(this.definition());
6+
},
7+
definition(){
8+
return {
69
message0: translate('list %1 is empty'),
710
args0 : [
811
{
@@ -16,7 +19,15 @@ Blockly.Blocks.lists_isEmpty = {
1619
colour : Blockly.Colours.Binary.colour,
1720
colourSecondary: Blockly.Colours.Binary.colourSecondary,
1821
colourTertiary : Blockly.Colours.Binary.colourTertiary,
19-
});
22+
tooltip : translate('List is Empty Tooltip'),
23+
category : 'list',
24+
};
25+
},
26+
meta(){
27+
return {
28+
'display_name': translate('List is Empty'),
29+
'description' : translate('List is empty Description'),
30+
};
2031
},
2132
};
2233

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

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

33
Blockly.Blocks.lists_length = {
44
init() {
5-
this.jsonInit({
5+
this.jsonInit(this.definition());
6+
},
7+
definition(){
8+
return {
69
message0: translate('length of %1'),
710
args0 : [
811
{
@@ -15,7 +18,15 @@ Blockly.Blocks.lists_length = {
1518
colour : Blockly.Colours.Binary.colour,
1619
colourSecondary: Blockly.Colours.Binary.colourSecondary,
1720
colourTertiary : Blockly.Colours.Binary.colourTertiary,
18-
});
21+
tooltip : translate('List Length Tooltip'),
22+
category : 'list',
23+
};
24+
},
25+
meta(){
26+
return {
27+
'display_name': translate('List Length'),
28+
'description' : translate('List Length Description'),
29+
};
1930
},
2031
};
2132

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

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

33
Blockly.Blocks.lists_repeat = {
44
init() {
5-
this.jsonInit({
5+
this.jsonInit(this.definition());
6+
},
7+
definition(){
8+
return {
69
message0: translate('set %1 to item %2 repeated %3 times'),
710
args0 : [
811
{
@@ -24,7 +27,15 @@ Blockly.Blocks.lists_repeat = {
2427
colourTertiary : Blockly.Colours.Binary.colourTertiary,
2528
previousStatement: null,
2629
nextStatement : null,
27-
});
30+
tooltip : translate('List Repeat Tooltip'),
31+
category : 'list',
32+
};
33+
},
34+
meta(){
35+
return {
36+
'display_name': translate('List Repeat'),
37+
'description' : translate('List Repeat Description'),
38+
};
2839
},
2940
};
3041

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ Blockly.Blocks.lists_setIndex = {
2929

3030
this.updateAt(true);
3131
},
32+
meta(){
33+
return {
34+
'display_name': translate('List set Index'),
35+
'description' : translate('List set Index'),
36+
};
37+
},
3238
mutationToDom() {
3339
const container = document.createElement('mutation');
3440
const isAt = this.getInput('AT').type === Blockly.INPUT_VALUE;

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

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

33
Blockly.Blocks.lists_sort = {
44
init() {
5-
this.jsonInit({
5+
this.jsonInit(this.definition());
6+
},
7+
definition(){
8+
return {
69
message0: translate('sort %1 %2 %3'),
710
args0 : [
811
{
@@ -25,7 +28,15 @@ Blockly.Blocks.lists_sort = {
2528
colour : Blockly.Colours.Binary.colour,
2629
colourSecondary: Blockly.Colours.Binary.colourSecondary,
2730
colourTertiary : Blockly.Colours.Binary.colourTertiary,
28-
});
31+
tooltip : translate('List Sort Tooltip'),
32+
category : 'list',
33+
};
34+
},
35+
meta(){
36+
return {
37+
'display_name': translate('List Sort'),
38+
'description' : translate('List Sort Description'),
39+
};
2940
},
3041
};
3142

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ Blockly.Blocks.lists_split = {
2626
Blockly.Colours.Binary.colourTertiary
2727
);
2828
},
29+
meta(){
30+
return {
31+
'display_name': translate('List Split'),
32+
'description' : translate('List SPlit Description'),
33+
};
34+
},
2935
mutationToDom() {
3036
const container = document.createElement('mutation');
3137
container.setAttribute('mode', this.getFieldValue('MODE'));

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

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
import { minusIconDark } from '../../images';
2+
import { translate } from '../../../../utils/lang/i18n';
23

34
Blockly.Blocks.lists_statement = {
45
init() {
56
this.requiredParentId = '';
67

7-
this.jsonInit({
8+
this.jsonInit(this.definition());
9+
10+
// Render a ➖-icon for removing self
11+
const fieldImage = new Blockly.FieldImage(minusIconDark, 25, 25, '', () => this.onIconClick());
12+
this.appendDummyInput('REMOVE_ICON').appendField(fieldImage);
13+
},
14+
definition(){
15+
return {
816
message0: '%1',
917
args0 : [
1018
{
@@ -17,11 +25,15 @@ Blockly.Blocks.lists_statement = {
1725
colourTertiary : Blockly.Colours.BinaryLessGray.colourTertiary,
1826
previousStatement: null,
1927
nextStatement : null,
20-
});
21-
22-
// Render a ➖-icon for removing self
23-
const fieldImage = new Blockly.FieldImage(minusIconDark, 25, 25, '', () => this.onIconClick());
24-
this.appendDummyInput('REMOVE_ICON').appendField(fieldImage);
28+
tooltip : translate('List Statement Tooltip'),
29+
category : 'list',
30+
};
31+
},
32+
meta(){
33+
return {
34+
'display_name': translate('List Statement'),
35+
'description' : translate('List Statement Description'),
36+
};
2537
},
2638
onIconClick() {
2739
if (!this.workspace || this.isInFlyout) {

0 commit comments

Comments
 (0)