mirror of
https://github.com/google/blockly.git
synced 2026-01-08 01:20:12 +01:00
Remove some functions from utilsService and consolidate code in workspace-tree.component.js.
This commit is contained in:
@@ -362,7 +362,7 @@ blocklyApp.TreeService = ng.core.Class({
|
||||
var blockRootSuffix = this.getBlockRootSuffix_();
|
||||
var blockId = blockRootNode.id.substring(
|
||||
0, blockRootNode.id.length - blockRootSuffix.length);
|
||||
return this.utilsService.getBlockById(blockId);
|
||||
return blocklyApp.workspace.getBlockById(blockId);
|
||||
},
|
||||
onKeypress: function(e, tree) {
|
||||
// TODO(sll): Instead of this, have a common ActiveContextService which
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
var blocklyApp = {};
|
||||
|
||||
blocklyApp.UtilsService = ng.core.Class({
|
||||
constructor: function() {},
|
||||
constructor: [function() {}],
|
||||
generateUniqueId: function() {
|
||||
return 'blockly-' + Blockly.utils.genUid();
|
||||
},
|
||||
@@ -42,22 +42,6 @@ blocklyApp.UtilsService = ng.core.Class({
|
||||
generateAriaLabelledByAttr: function(mainLabel, secondLabel) {
|
||||
return mainLabel + (secondLabel ? ' ' + secondLabel : '');
|
||||
},
|
||||
getInputTypeLabel: function(connection) {
|
||||
// Returns the input type name, or 'any' if any official input type
|
||||
// qualifies.
|
||||
if (connection.check_) {
|
||||
return connection.check_.join(', ');
|
||||
} else {
|
||||
return Blockly.Msg.ANY;
|
||||
}
|
||||
},
|
||||
getBlockTypeLabel: function(inputBlock) {
|
||||
if (inputBlock.type == Blockly.NEXT_STATEMENT) {
|
||||
return Blockly.Msg.BLOCK;
|
||||
} else {
|
||||
return Blockly.Msg.VALUE;
|
||||
}
|
||||
},
|
||||
getBlockDescription: function(block) {
|
||||
// We use 'BLANK' instead of the default '?' so that the string is read
|
||||
// out. (By default, screen readers tend to ignore punctuation.)
|
||||
@@ -65,8 +49,5 @@ blocklyApp.UtilsService = ng.core.Class({
|
||||
},
|
||||
isWorkspaceEmpty: function() {
|
||||
return !blocklyApp.workspace.topBlocks_.length;
|
||||
},
|
||||
getBlockById: function(blockId) {
|
||||
return blocklyApp.workspace.getBlockById(blockId);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -53,7 +53,7 @@ blocklyApp.WorkspaceTreeComponent = ng.core.Component({
|
||||
[attr.aria-labelledBy]="generateAriaLabelledByAttr(idMap['inputMenuLabel' + i], 'blockly-submenu-indicator')"
|
||||
[attr.aria-level]="level + 1">
|
||||
<label [id]="idMap['inputMenuLabel' + i]">
|
||||
{{utilsService.getInputTypeLabel(blockInput.connection)}} {{utilsService.getBlockTypeLabel(blockInput)}} needed:
|
||||
{{getBlockNeededLabel(blockInput)}}
|
||||
</label>
|
||||
<button [id]="idMap[fieldButtonsInfo[0].baseIdKey + 'Button' + i]"
|
||||
(click)="fieldButtonsInfo[0].action(blockInput.connection)"
|
||||
@@ -200,5 +200,15 @@ blocklyApp.WorkspaceTreeComponent = ng.core.Component({
|
||||
generateAriaLabelledByAttr: function(mainLabel, secondLabel) {
|
||||
return this.utilsService.generateAriaLabelledByAttr(
|
||||
mainLabel, secondLabel);
|
||||
},
|
||||
getBlockNeededLabel: function(blockInput) {
|
||||
// The input type name, or 'any' if any official input type qualifies.
|
||||
var inputTypeLabel = (
|
||||
blockInput.connection.check_ ?
|
||||
blockInput.connection.check_.join(', ') : Blockly.Msg.ANY);
|
||||
var blockTypeLabel = (
|
||||
blockInput.type == Blockly.NEXT_STATEMENT ?
|
||||
Blockly.Msg.BLOCK : Blockly.Msg.VALUE);
|
||||
return inputTypeLabel + ' ' + blockTypeLabel + ' needed:';
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user