let thisBlock = (this as unknown) as Blockly.BlockSvg;
let thisField = thisBlock.getField('model_alias') as Blockly.FieldVariable;
if (!!thisField)
{
const MODEL_ALIAS_MENU_GENERATOR = (): string[][] =>
{
// Gather all valid model aliases to be shown
let options = Blockly.FieldVariable.dropdownCreate.call(thisField);
let selectedVar = thisField.getValue();
if (BlocklyHelper.isSystemVariable(selectedVar))
{
// If dropdown has a system variable as it's selected one, remove variable management options e.g 'Rename Variable', 'Delete Variable'
if (Blockly.mainWorkspace.getVariableById(selectedVar))
{
options.splice(
options.findIndex((opt) => opt[1] === Blockly.RENAME_VARIABLE_ID),
1
);
options.splice(
options.findIndex((opt) => opt[1] === Blockly.DELETE_VARIABLE_ID),
1
);
}
}
return options;
};
thisField.menuGenerator_ = MODEL_ALIAS_MENU_GENERATOR;
}