Skip to content

Commit 1113eab

Browse files
authored
Add no mechanism contents if mechanism is empty (#198)
1 parent ce167c1 commit 1113eab

File tree

5 files changed

+11
-1
lines changed

5 files changed

+11
-1
lines changed

src/blocks/tokens.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export function customTokens(t: (key: string) => string): typeof Blockly.Msg {
4949
ENABLED: t('BLOCKLY.ENABLED'),
5050
DISPLAY_NAME: t('BLOCKLY.DISPLAY_NAME'),
5151
DISPLAY_GROUP: t('BLOCKLY.DISPLAY_GROUP'),
52+
NO_MECHANISM_CONTENTS: t('BLOCKLY.NO_MECHANISM_CONTENTS'),
5253
OPMODE_TYPE_TOOLTIP: t('BLOCKLY.TOOLTIP.OPMODE_TYPE_TOOLTIP'),
5354
OPMODE_ENABLED_TOOLTIP: t('BLOCKLY.TOOLTIP.OPMODE_ENABLED_TOOLTIP'),
5455
OPMODE_NAME_TOOLTIP: t('BLOCKLY.TOOLTIP.OPMODE_NAME_TOOLTIP'),

src/i18n/locales/en/translation.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
"DISPLAY_NAME": "Display Name",
5555
"DISPLAY_GROUP": "Display Group",
5656
"PRINT": "print",
57+
"NO_MECHANISM_CONTENTS": "No Mechanism Contents",
5758
"TOOLTIP":{
5859
"EVALUATE_BUT_IGNORE_RESULT": "Executes the connected block and ignores the result. Allows you to call a function and ignore the return value.",
5960
"OPMODE_TYPE": "What sort of OpMode this is",

src/i18n/locales/es/translation.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@
5454
"ENABLED": "Habilitado",
5555
"DISPLAY_NAME": "Nombre a Mostrar",
5656
"DISPLAY_GROUP": "Grupo a Mostrar",
57+
"PRINT": "imprimir",
58+
"NO_MECHANISM_CONTENTS": "Sin Contenido de Mecanismo",
5759
"TOOLTIP": {
5860
"EVALUATE_BUT_IGNORE_RESULT": "Ejecuta el bloque conectado e ignora el resultado. Te permite llamar una función e ignorar el valor de retorno.",
5961
"OPMODE_TYPE": "Qué tipo de OpMode es este",

src/i18n/locales/he/translation.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
"DISPLAY_NAME": "שם תצוגה",
5555
"DISPLAY_GROUP": "קבוצת תצוגה",
5656
"PRINT": "הדפס",
57+
"NO_MECHANISM_CONTENTS": "אין תוכן מנגנון",
5758
"TOOLTIP":{
5859
"EVALUATE_BUT_IGNORE_RESULT": "מריץ את הבלוק המחובר ומתעלם מהתוצאה. מאפשר לך לקרוא לפונקציה ולהתעלם מערך ההחזרה.",
5960
"OPMODE_TYPE": "איזה סוג של מצב פעולה זה",

src/toolbox/hardware_category.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,19 @@ function getRobotMechanismsCategory(currentModule: storageModule.Module): toolbo
9292

9393
if (editor) {
9494
editor.getMechanismsFromRobot().forEach(mechanismInRobot => {
95-
const mechanismBlocks: toolboxItems.Block[] = [];
95+
const mechanismBlocks: toolboxItems.Item[] = [];
9696

9797
// Add the blocks for this mechanism's methods.
9898
const mechanism = editor.getMechanism(mechanismInRobot);
9999
if (mechanism) {
100100
const methodsFromMechanism = editor.getMethodsFromMechanism(mechanism);
101101
addInstanceMechanismBlocks(mechanismInRobot, methodsFromMechanism, mechanismBlocks);
102102

103+
if(mechanismBlocks.length === 0){
104+
const label : toolboxItems.Label = new toolboxItems.Label(Blockly.Msg['NO_MECHANISM_CONTENTS']);
105+
mechanismBlocks.push( label );
106+
}
107+
103108
contents.push({
104109
kind: 'category',
105110
name: mechanismInRobot.name,

0 commit comments

Comments
 (0)