Merge pull request #1167 from quantified-uncertainty/remove-sources
Add removeSource to project
This commit is contained in:
commit
9caee0fecd
|
@ -112,6 +112,25 @@ describe("project2", () => {
|
|||
})
|
||||
})
|
||||
|
||||
describe("removing sources", () => {
|
||||
let project = Project.createProject()
|
||||
Project.setContinues(project, "main", ["second"])
|
||||
Project.setContinues(project, "second", ["first"])
|
||||
Project.setSource(project, "first", "x=1")
|
||||
Project.setSource(project, "second", "y=2")
|
||||
Project.setSource(project, "main", "y")
|
||||
|
||||
Project.removeSource(project, "main")
|
||||
|
||||
test("project doesn't have source", () => {
|
||||
expect(Project.getSource(project, "main")) == None
|
||||
})
|
||||
|
||||
test("dependents get updated", () => {
|
||||
expect(Project.getDependents(project, "second")) == []
|
||||
})
|
||||
})
|
||||
|
||||
describe("project with include", () => {
|
||||
let project = Project.createProject()
|
||||
Project.setContinues(project, "main", ["second"])
|
||||
|
|
|
@ -22,6 +22,10 @@ export class SqProject {
|
|||
return RSProject.setSource(this._value, sourceId, value);
|
||||
}
|
||||
|
||||
removeSource(sourceId: string) {
|
||||
RSProject.removeSource(this._value, sourceId);
|
||||
}
|
||||
|
||||
getSource(sourceId: string) {
|
||||
return RSProject.getSource(this._value, sourceId);
|
||||
}
|
||||
|
|
|
@ -50,6 +50,13 @@ Sets the source for a given source Id.
|
|||
let setSource = (project: reducerProject, sourceId: string, value: string): unit =>
|
||||
project->Private.setSource(sourceId, value)
|
||||
|
||||
/*
|
||||
Removes the source for a given source Id.
|
||||
*/
|
||||
@genType
|
||||
let removeSource = (project: reducerProject, sourceId: string): unit =>
|
||||
project->Private.removeSource(sourceId)
|
||||
|
||||
/*
|
||||
Gets the source for a given source id.
|
||||
*/
|
||||
|
|
|
@ -61,6 +61,10 @@ let setSource = (project: t, sourceId: string, value: string): unit => {
|
|||
touchDependents(project, sourceId)
|
||||
}
|
||||
|
||||
let removeSource = (project: t, sourceId: string): unit => {
|
||||
Belt.MutableMap.String.remove(project.items, sourceId)
|
||||
}
|
||||
|
||||
let clean = (project: t, sourceId: string): unit => {
|
||||
let newItem = project->getItem(sourceId)->ProjectItem.clean
|
||||
project->setItem(sourceId, newItem)
|
||||
|
|
Loading…
Reference in New Issue
Block a user