Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When the label changes on Map Layer node types, update the respective Layer #213

Merged
merged 1 commit into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { dataSocket } from "../socket_types"
import { BooleanTileGrid, CategoricalTileGrid, NumericTileGrid } from "../tile_grid"
import { BaseComponent } from "./base_component"

export type SaveMapLayer = (id: number, tileGrid: BooleanTileGrid | NumericTileGrid | CategoricalTileGrid) => void
export type SaveMapLayer = (id: number, name: string | undefined, tileGrid: BooleanTileGrid | NumericTileGrid | CategoricalTileGrid) => void

export class MapLayerComponent extends BaseComponent {
callback: SaveMapLayer
Expand All @@ -30,7 +30,7 @@ export class MapLayerComponent extends BaseComponent {
else {
delete editorNode.meta.errorMessage

if (inputs["in"][0]) this.callback(node.id, inputs["in"][0] as BooleanTileGrid | NumericTileGrid | CategoricalTileGrid)
if (inputs["in"][0]) this.callback(node.id, editorNode.data.name as string, inputs["in"][0] as BooleanTileGrid | NumericTileGrid | CategoricalTileGrid)
else editorNode.meta.errorMessage = 'No input'

}
Expand Down
3 changes: 2 additions & 1 deletion app/javascript/projects/project_editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,11 @@ export function ProjectEditor({ projectId, projectSource, backButtonPath, dbMode
deleteOutputLayer={(nodeId: number) =>
dispatch({ type: "DeleteModelOutputLayer", nodeId })
}
saveMapLayer={(id, tileGrid) => {
saveMapLayer={(id, name, tileGrid) => {
const cache = modelOutputCache
cache[id] = tileGrid
setModelOutputCache(cache)
if(name) dispatch({ type: "MutateLayer", id, data: { name }})
}}
setProcessing={setProcessing}
autoProcessing={state.autoProcessing}
Expand Down