mirror of
https://github.com/google/blockly.git
synced 2026-01-08 17:40:09 +01:00
feat: procedure blocks update models (#6672)
* feat: procedure blocks have models * feat: add updating the name of the model * feat: add procedure defs updating the model enabled state * feat: add procedure blocks updating parameters in the model * fix: add disposing of the procedure model * chore: updates test to check for identity of parameters * chore: move statement handling into setStatement * fix: make parameter IDs consistent * chore: un-only tests * chore: fixup tests * chore: revert validator to use Procedures.rename * chore: cleanup typo
This commit is contained in:
@@ -5,11 +5,13 @@
|
||||
*/
|
||||
|
||||
import type {Block} from '../block.js';
|
||||
import {IProcedureModel} from './i_procedure_model.js';
|
||||
|
||||
|
||||
/** The interface for a block which models a procedure. */
|
||||
export interface IProcedureBlock {
|
||||
doProcedureUpdate(): void;
|
||||
getProcedureModel(): IProcedureModel;
|
||||
}
|
||||
|
||||
/** A type guard which checks if the given block is a procedure block. */
|
||||
|
||||
@@ -23,6 +23,7 @@ import type {Abstract} from './events/events_abstract.js';
|
||||
import type {BubbleOpen} from './events/events_bubble_open.js';
|
||||
import * as eventUtils from './events/utils.js';
|
||||
import {Field, UnattachedFieldError} from './field.js';
|
||||
import {isProcedureBlock} from './interfaces/i_procedure_block.js';
|
||||
import {Msg} from './msg.js';
|
||||
import {Names} from './names.js';
|
||||
import {ObservableProcedureMap} from './procedures/observable_procedure_map.js';
|
||||
@@ -192,6 +193,7 @@ export function rename(this: Field, name: string): string {
|
||||
name = name.trim();
|
||||
|
||||
const legalName = findLegalName(name, block);
|
||||
if (isProcedureBlock(block)) block.getProcedureModel().setName(legalName);
|
||||
const oldName = this.getValue();
|
||||
if (oldName !== name && oldName !== legalName) {
|
||||
// Rename any callers.
|
||||
|
||||
@@ -11,6 +11,8 @@ import type {IProcedureModel} from '../interfaces/i_procedure_model';
|
||||
import {triggerProceduresUpdate} from './update_procedures.js';
|
||||
import type {VariableModel} from '../variable_model.js';
|
||||
import type {Workspace} from '../workspace.js';
|
||||
import * as goog from '../../closure/goog/goog.js';
|
||||
goog.declareModuleId('Blockly.procedures.ObservableParameterModel');
|
||||
|
||||
|
||||
export class ObservableParameterModel implements IParameterModel {
|
||||
|
||||
@@ -11,6 +11,8 @@ import type {IProcedureModel} from '../interfaces/i_procedure_model.js';
|
||||
import {isObservable} from '../interfaces/i_observable.js';
|
||||
import {triggerProceduresUpdate} from './update_procedures.js';
|
||||
import type {Workspace} from '../workspace.js';
|
||||
import * as goog from '../../closure/goog/goog.js';
|
||||
goog.declareModuleId('Blockly.procedures.ObservableProcedureModel');
|
||||
|
||||
|
||||
export class ObservableProcedureModel implements IProcedureModel {
|
||||
|
||||
Reference in New Issue
Block a user