-
-
Notifications
You must be signed in to change notification settings - Fork 68
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
Implement deleteObjs
method in Circuit
#1228
Conversation
actually delete from the circuit as opposed to deleting from the given array
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good!
Please make sure to update your branch though, there are some merge conflicts
protected get selections(): SelectionsManager { | ||
return this.state.selections; | ||
} | ||
|
||
public get kind(): string { | ||
throw new Error("Unimplemented"); | ||
const tmp = this.circuit.getObjByID(this.objID); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: called this obj
throw new Error("Unimplemented"); | ||
const tmp = this.circuit.getObjByID(this.objID); | ||
if(!tmp) | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: don't need brackets
public getProp(key: string): Prop { | ||
throw new Error("Unimplemented"); | ||
const tmp = this.circuit.getObjByID(this.objID); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: call this obj
throw new Error("Unimplemented"); | ||
const tmp = this.circuit.getObjByID(this.objID); | ||
if(!tmp) | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: don't need brackets
public getProps(): Record<string, Prop> { | ||
throw new Error("Unimplemented"); | ||
const tmp = this.circuit.getObjByID(this.objID); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: call this obj
src/app/tests/BaseObject.test.ts
Outdated
const circuit = CreateCircuit(); | ||
|
||
const a = circuit.placeComponentAt(V(0, 0), "ANDGate"); | ||
expect(a.getProp('x')).toEqual(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: use "
not '
src/app/tests/BaseObject.test.ts
Outdated
let cArray: Component[] = [a]; | ||
circuit.deleteObjs(cArray); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just do circuit.deleteObjs([a])
src/app/tests/DeleteObjects.test.ts
Outdated
let cArray: Component[] = [c]; | ||
circuit.deleteObjs(cArray); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just do circuit.deleteObjs([c])
expect(s1.exists()).toEqual(false); | ||
expect(s2.exists()).toEqual(false); | ||
expect(l1.exists()).toEqual(false); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also add some tests for when there are connections between components, and things like deleting a component that has connections and making sure the wires were deleted
Also please update the title and description to provide some more useful information about the PR |
…rcuits/OpenCircuits into model_refactor_api_friedj
deleteObjs
method in Circuit
@@ -1,5 +1,6 @@ | |||
import {BaseObject} from "./BaseObject"; | |||
import {Component} from "./Component"; | |||
import {Wire} from "./Wire"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: spacing
*/ | ||
public deleteObjs(objs: Obj[]): void { | ||
this.circuit.beginTransaction(); | ||
for(const obj of objs) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: spacing
this.circuit.beginTransaction(); | ||
for(const obj of objs) | ||
{ | ||
if(obj.baseKind == "Port") { continue; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please fix
this.circuit.beginTransaction(); | ||
for(const obj of objs) { | ||
if(obj.baseKind == "Port") { continue; } | ||
if(obj.baseKind == "Component") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: spacing
nit: use ===
if(obj.baseKind == "Port") { continue; } | ||
if(obj.baseKind == "Component") | ||
{ | ||
this.circuit.setPortConfig(obj.id, {}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please fix
const circuit = CreateCircuit(); | ||
|
||
const c = circuit.placeComponentAt(V(0, 0), "ANDGate"); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expect a.exists() to be true before deleting it
const s1 = circuit.placeComponentAt(V(-5, 5), "Switch"); | ||
const s2 = circuit.placeComponentAt(V(-5, -5), "Switch"); | ||
const l1 = circuit.placeComponentAt(V(5, 0), "LED"); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expect them to exist before deleting it as well
|
||
const w1 = s1.ports["outputs"][0].connectTo(g.ports["inputs"][0]), | ||
w2 = s2.ports["outputs"][0].connectTo(g.ports["inputs"][1]), | ||
w3 = g.ports["outputs"][0].connectTo(l.ports["inputs"][0]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't comma separate, just declare const
for each of them
//TODO test for wires existing | ||
//TODO ensure deletion working properly for full circuit | ||
//none of my test cases are working properly right now unfortunately |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do the TODOs or remove them
//TODO test for wires existing | ||
//TODO ensure deletion working properly for full circuit | ||
//none of my test cases are working properly right now unfortunately | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a test case for deleting just a wire, make sure the components and ports still exist
Add one for deleting just the ANDGate from the above circuit, and expect that the Switches and LED still exist while all the wires and the ANDGate were deleted
No description provided.