Skip to content

Commit

Permalink
Make it possible to hide from blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastienTainon committed Sep 6, 2024
1 parent 68b2301 commit 744e54c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion frontend/task/blocks/blocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ interface BlockInfo {
yieldsValue: string|boolean,
params: any[],
nbsArgs: any[],
hidden?: boolean,
}

export const CONSTRUCTOR_NAME = '__constructor';

export function generateBlockInfo(block: QuickalgoLibraryBlock, typeName: string): BlockInfo {
const blockInfo = {
const blockInfo: BlockInfo = {
nbArgs: 0, // handled below
type: typeName,
yieldsValue: block.yieldsValue,
Expand All @@ -47,6 +48,9 @@ export function generateBlockInfo(block: QuickalgoLibraryBlock, typeName: string
blockInfo.nbsArgs.push(variants[i].length);
}
}
if (block.hidden) {
blockInfo.hidden = true;
}

return blockInfo;
}
Expand All @@ -71,6 +75,7 @@ function getBlockFromBlockInfo(generatorName: string, blockName: string, blockIn
caption: code,
code,
returnType,
showInBlocks: !blockInfo?.hidden,
}
}

Expand Down
1 change: 1 addition & 0 deletions frontend/task/libs/quickalgo_library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export interface QuickalgoLibraryBlock {
blocklyJson?: any,
anyArgs?: boolean,
variants?: any,
hidden?: boolean,
}

export interface QuickAlgoCustomClass {
Expand Down

0 comments on commit 744e54c

Please sign in to comment.