From 337ce75ab72a74b6c9c2551f92442cbf848a5e90 Mon Sep 17 00:00:00 2001 From: Maribeth Bottorff Date: Fri, 10 May 2024 11:21:07 -0700 Subject: [PATCH] fix: remove angle fields from block-test (#2346) * fix: remove angle fields from block-test * fix: remove colour label --- plugins/block-test/src/fields/angles.js | 160 -------------------- plugins/block-test/src/fields/defaults.js | 20 --- plugins/block-test/src/fields/index.js | 3 - plugins/block-test/src/fields/validators.js | 98 ------------ 4 files changed, 281 deletions(-) delete mode 100644 plugins/block-test/src/fields/angles.js diff --git a/plugins/block-test/src/fields/angles.js b/plugins/block-test/src/fields/angles.js deleted file mode 100644 index a12b37865f..0000000000 --- a/plugins/block-test/src/fields/angles.js +++ /dev/null @@ -1,160 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC - * SPDX-License-Identifier: Apache-2.0 - */ -'use strict'; - -/** - * @fileoverview Angle fields test blocks. - * @author samelh@google.com (Sam El-Husseini) - */ - -import * as Blockly from 'blockly/core'; - -Blockly.defineBlocksWithJsonArray([ - { - type: 'test_angles_protractor', - message0: 'protractor %1', - args0: [ - { - type: 'field_angle', - name: 'FIELDNAME', - angle: 0, - mode: 'protractor', - }, - ], - style: 'math_blocks', - tooltip: 'test tooltip', - }, - { - type: 'test_angles_compass', - message0: 'compass %1', - args0: [ - { - type: 'field_angle', - name: 'FIELDNAME', - angle: 0, - mode: 'compass', - }, - ], - style: 'math_blocks', - tooltip: 'test tooltip', - }, - { - type: 'test_angles_clockwise', - message0: 'clockwise %1', - args0: [ - { - type: 'field_angle', - name: 'FIELDNAME', - angle: 0, - clockwise: true, - }, - ], - style: 'math_blocks', - tooltip: 'test tooltip', - }, - { - type: 'test_angles_offset', - message0: 'offset 90 %1', - args0: [ - { - type: 'field_angle', - name: 'FIELDNAME', - angle: 0, - offset: 90, - }, - ], - style: 'math_blocks', - tooltip: 'test tooltip', - }, - { - type: 'test_angles_wrap', - message0: 'wrap %1', - args0: [ - { - type: 'field_angle', - name: 'FIELDNAME', - angle: 0, - wrap: 180, - }, - ], - style: 'math_blocks', - tooltip: 'test tooltip', - }, - { - type: 'test_angles_round_30', - message0: 'round 30 %1', - args0: [ - { - type: 'field_angle', - name: 'FIELDNAME', - angle: 0, - round: 30, - }, - ], - style: 'math_blocks', - tooltip: 'test tooltip', - }, - { - type: 'test_angles_round_0', - message0: 'no round %1', - args0: [ - { - type: 'field_angle', - name: 'FIELDNAME', - angle: 0, - round: 0, - }, - ], - style: 'math_blocks', - tooltip: 'test tooltip', - }, -]); - -/** - * The Angle field category. - */ -export const category = { - kind: 'CATEGORY', - name: 'Angles', - contents: [ - { - kind: 'BLOCK', - type: 'test_angles_clockwise', - }, - { - kind: 'BLOCK', - type: 'test_angles_offset', - }, - { - kind: 'BLOCK', - type: 'test_angles_wrap', - }, - { - kind: 'BLOCK', - type: 'test_angles_round_30', - }, - { - kind: 'BLOCK', - type: 'test_angles_round_0', - }, - { - kind: 'BLOCK', - type: 'test_angles_protractor', - }, - { - kind: 'BLOCK', - type: 'test_angles_compass', - }, - ], -}; - -/** - * Initialize this toolbox category. - * @param {!Blockly.WorkspaceSvg} workspace The Blockly workspace. - */ -export function onInit(workspace) { - // NOP -} diff --git a/plugins/block-test/src/fields/defaults.js b/plugins/block-test/src/fields/defaults.js index bbd99da01f..98daa55b4b 100644 --- a/plugins/block-test/src/fields/defaults.js +++ b/plugins/block-test/src/fields/defaults.js @@ -13,22 +13,6 @@ import * as Blockly from 'blockly/core'; Blockly.defineBlocksWithJsonArray([ - { - type: 'test_fields_angle', - message0: 'angle: %1', - args0: [ - { - type: 'field_angle', - name: 'FIELDNAME', - angle: '90', - alt: { - type: 'field_label', - text: 'NO ANGLE FIELD', - }, - }, - ], - style: 'math_blocks', - }, { type: 'test_fields_text_input', message0: 'text input %1', @@ -165,10 +149,6 @@ export const category = { text: 'toggle collapsed', callbackkey: 'toggleCollapsed', }, - { - kind: 'BLOCK', - type: 'test_fields_angle', - }, { kind: 'BLOCK', type: 'test_fields_checkbox', diff --git a/plugins/block-test/src/fields/index.js b/plugins/block-test/src/fields/index.js index 79e01ea23f..259058e35f 100644 --- a/plugins/block-test/src/fields/index.js +++ b/plugins/block-test/src/fields/index.js @@ -12,7 +12,6 @@ import {category as fieldDefaults, onInit as initDefaults} from './defaults'; import {category as fieldNumbers, onInit as initNumbers} from './numbers'; -import {category as fieldAngles, onInit as initAngles} from './angles'; import {category as fieldDropdowns, onInit as initDropdowns} from './dropdowns'; import {category as fieldImages, onInit as initImages} from './images'; import {category as fieldEmoji, onInit as initEmoji} from './emojis'; @@ -31,7 +30,6 @@ export const category = { contents: [ fieldDefaults, fieldNumbers, - fieldAngles, fieldDropdowns, fieldImages, fieldEmoji, @@ -46,7 +44,6 @@ export const category = { export function onInit(workspace) { initDefaults(workspace); initNumbers(workspace); - initAngles(workspace); initDropdowns(workspace); initImages(workspace); initEmoji(workspace); diff --git a/plugins/block-test/src/fields/validators.js b/plugins/block-test/src/fields/validators.js index 9eb70cb254..dbeb8f6ec3 100644 --- a/plugins/block-test/src/fields/validators.js +++ b/plugins/block-test/src/fields/validators.js @@ -98,68 +98,6 @@ Blockly.Blocks['test_validators_text_B'] = { }, }; -Blockly.Blocks['test_validators_angle_null'] = { - init: function () { - this.appendDummyInput() - .appendField('always null') - .appendField(new Blockly.FieldAngle(90, this.validate), 'INPUT'); - this.setColour(230); - this.setCommentText( - 'All input validates to null (invalid). The field' + - ' will display the input while the field is being edited (this' + - ' includes the text and the graphic), but the value should be the' + - ' default value. The input should be red after the first' + - ' keystroke.', - ); - }, - - validate: function (newValue) { - return null; - }, -}; -Blockly.Blocks['test_validators_angle_mult30_force'] = { - init: function () { - this.appendDummyInput() - .appendField('force mult of 30') - .appendField(new Blockly.FieldAngle(90, this.validate), 'INPUT'); - this.setColour(230); - this.setCommentText( - 'The input value will be rounded to the nearest' + - ' multiple of 30. The field will display the input while the field is' + - ' being edited (this includes the text and the graphic), but the' + - ' value will be the validated (rounded) value. Note: If you want to' + - ' do rounding this is not the proper way, use the ROUND property of' + - ' the field angle instead.', - ); - }, - - validate: function (newValue) { - return Math.round(newValue / 30) * 30; - }, -}; -Blockly.Blocks['test_validators_angle_mult30_null'] = { - init: function () { - this.appendDummyInput() - .appendField('not mult of 30 -> null') - .appendField(new Blockly.FieldAngle(90, this.validate), 'INPUT'); - this.setColour(230); - this.setCommentText( - 'If the input value is not a multiple of 30, the' + - ' input will validated to null (invalid). The field will display the' + - ' input while the field is being edited (this includes the text and' + - ' the graphic), but if the input value is invalid the value should be' + - ' the default value.', - ); - }, - - validate: function (newValue) { - if (newValue % 30 != 0) { - return null; - } - return newValue; - }, -}; - Blockly.Blocks['test_validators_checkbox_null'] = { init: function () { this.appendDummyInput() @@ -458,34 +396,6 @@ export const category = { kind: 'BLOCK', type: 'test_validators_dispose_block', }, - { - kind: 'LABEL', - text: 'Angles', - }, - { - kind: 'SEP', - gap: '12', - }, - { - kind: 'BLOCK', - type: 'test_validators_angle_null', - }, - { - kind: 'SEP', - gap: '12', - }, - { - kind: 'BLOCK', - type: 'test_validators_angle_mult30_force', - }, - { - kind: 'SEP', - gap: '12', - }, - { - kind: 'BLOCK', - type: 'test_validators_angle_mult30_null', - }, { kind: 'LABEL', text: 'Checkboxes', @@ -514,14 +424,6 @@ export const category = { kind: 'BLOCK', type: 'test_validators_checkbox_not_match_null', }, - { - kind: 'LABEL', - text: 'Colours', - }, - { - kind: 'SEP', - gap: '12', - }, { kind: 'LABEL', text: 'Dropdowns',