Skip to content
Snippets Groups Projects
Commit 8ee96cc8 authored by Jake Read's avatar Jake Read
Browse files

delete module OK

parent 26f873c0
No related branches found
No related tags found
No related merge requests found
......@@ -50,6 +50,11 @@ This project serves the developement environment / api we use to write and repre
- programs come in chunk-wise and get placed
- programs are modules are heirarchical
## Questionable Moves
- module deletion seems unclean
- input / output objects should be able to unhook themselves:
- keep references of what-is-attached ?
## WRT Representations
OK
......
......@@ -39,6 +39,23 @@ function Output(type) {
}
}
output.removeAllLinks = function() {
this.calls = []
}
output.checkLinks = function(id){
console.log('checking links', this)
for(index in this.calls){
if(this.calls[index].parentId == id){
console.log('popping null entry from', this.calls)
this.calls.splice(index, 1)
console.log('new record', this.calls)
} else {
// all good
}
}
}
output.emit = function(data) {
if (this.calls.length == 0) {
console.log('no inputs bound to this output')
......
......@@ -85,6 +85,18 @@ function writeStateObject(mod, key) {
})
}
function removeModuleFromProgram(program, id){
// this simple?
delete program.modules[id]
for(key in program.modules){
var mdl = program.modules[key]
for(otKey in mdl.outputs){
mdl.outputs[otKey].checkLinks(id)
}
}
}
/*
EXTERNAL HOOKS
......@@ -201,5 +213,6 @@ module.exports = {
open: openProgram,
save: saveProgram,
loadModuleFromSource: loadModuleFromSource,
removeModule: removeModuleFromProgram,
assignSocket: assignSocket
}
\ No newline at end of file
......@@ -229,6 +229,8 @@ function uiRequestNewModule(data) {
function uiRequestRemoveModule(data){
console.log('UI REQUEST TO REMOVE MODULE', data.id)
Programs.removeModule(program, data.id)
socketSend('restart', '')
}
function uiRequestStateChange(data) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment