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

delete module OK

parent 26f873c0
Branches
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 ...@@ -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 come in chunk-wise and get placed
- programs are modules are heirarchical - 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 ## WRT Representations
OK OK
......
...@@ -39,6 +39,23 @@ function Output(type) { ...@@ -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) { output.emit = function(data) {
if (this.calls.length == 0) { if (this.calls.length == 0) {
console.log('no inputs bound to this output') console.log('no inputs bound to this output')
......
...@@ -85,6 +85,18 @@ function writeStateObject(mod, key) { ...@@ -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 EXTERNAL HOOKS
...@@ -201,5 +213,6 @@ module.exports = { ...@@ -201,5 +213,6 @@ module.exports = {
open: openProgram, open: openProgram,
save: saveProgram, save: saveProgram,
loadModuleFromSource: loadModuleFromSource, loadModuleFromSource: loadModuleFromSource,
removeModule: removeModuleFromProgram,
assignSocket: assignSocket assignSocket: assignSocket
} }
\ No newline at end of file
...@@ -229,6 +229,8 @@ function uiRequestNewModule(data) { ...@@ -229,6 +229,8 @@ function uiRequestNewModule(data) {
function uiRequestRemoveModule(data){ function uiRequestRemoveModule(data){
console.log('UI REQUEST TO REMOVE MODULE', data.id) console.log('UI REQUEST TO REMOVE MODULE', data.id)
Programs.removeModule(program, data.id)
socketSend('restart', '')
} }
function uiRequestStateChange(data) { function uiRequestStateChange(data) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment