Skip to content

Commit

Permalink
Merge pull request #791 from CSCfi/fix-workflow-editor2
Browse files Browse the repository at this point in the history
fix: workflow editor
  • Loading branch information
Macroz committed Dec 13, 2018
2 parents 2045114 + cdfa67a commit 490a5be
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
9 changes: 5 additions & 4 deletions src/cljs/rems/administration/workflow.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,18 @@
:rounds (every? valid-round? (:rounds request))
nil false)))

(defn- build-request-round [round]
(select-keys round [:type :actors]))
(defn- build-request-round [{:keys [type actors]}]
{:type type
:actors (map :userid actors)})

(defn build-request [form]
(let [request {:organization (:organization form)
:title (:title form)
:type (:type form)}
request (case (:type form)
:auto-approve request
:dynamic (assoc request :handlers (:handlers form))
:rounds (assoc request :rounds (map build-request-round (:rounds form))))]
:dynamic (assoc request :handlers (map :userid (:handlers form)))
:rounds (assoc request :rounds (map build-request-round (vals (:rounds form)))))]
(when (valid-request? request)
request)))

Expand Down
10 changes: 5 additions & 5 deletions test/cljs/rems/test/administration/workflow.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
(let [form {:organization "abc"
:title "workflow title"
:type :dynamic
:handlers ["bob" "carl"]}]
:handlers [{:userid "bob"} {:userid "carl"}]}]
(testing "valid form"
(is (= {:organization "abc"
:title "workflow title"
Expand All @@ -47,10 +47,10 @@
(let [form {:organization "abc"
:title "workflow title"
:type :rounds
:rounds [{:type :review
:actors ["alice" "bob"]}
{:type :approval
:actors ["carl"]}]}]
:rounds {0 {:type :review
:actors [{:userid "alice"} {:userid "bob"}]}
1 {:type :approval
:actors [{:userid "carl"}]}}}]
(testing "valid form"
(is (= {:organization "abc"
:title "workflow title"
Expand Down

0 comments on commit 490a5be

Please sign in to comment.