Fix project preselection when project identifier is not defined (#9)

This commit is contained in:
Manuel Bouza
2019-04-01 17:41:54 +02:00
committed by Tobias Miesel
parent 1533c2261f
commit 1d2e336e3d
3 changed files with 14 additions and 7 deletions

View File

@@ -69,8 +69,9 @@ class App extends Component {
head(projects)
const task =
findTask(this.changeset.task_id || service?.taskId || lastTaskId)(project) ||
head(project?.tasks)
findTask(this.changeset.task_id || service?.taskId || lastTaskId)(
project
) || head(project?.tasks)
const defaults = {
remote_service: service?.name,
@@ -111,7 +112,7 @@ class App extends Component {
if (name === "assignment_id") {
const project = findProjectByValue(value)(projects)
this.changeset.task_id = head(project?.tasks)?.value
this.changeset.task_id = head(project?.tasks)?.value
}
};

View File

@@ -21,11 +21,17 @@ export const ERROR_UNKNOWN = "unknown"
export const noop = () => null
export const findProjectBy = prop => val =>
compose(
export const findProjectBy = prop => val => projects => {
if (!val) {
return undefined
}
return compose(
find(pathEq(prop, val)),
flatMap(get("options"))
)
)(projects)
}
export const findProjectByIdentifier = findProjectBy("identifier")
export const findProjectByValue = findProjectBy("value")