Skip to content

Commit

Permalink
fix: Merge pull request #431 from CedricProfessionnel/KillClassDuplicate
Browse files Browse the repository at this point in the history
Class (Labels) duplicate impossible
  • Loading branch information
seveibar committed Jan 15, 2021
2 parents 5d22050 + 2e098db commit fc5ec54
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/components/ConfigureImageClassification/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ export default ({ iface, onChange }) => {
() => ({
multiple: iface.multiple ? iface.multiple : false,
labels:
(iface.labels || []).map((a) =>
typeof a === "string" ? { id: a, description: a } : a
) || [],
(iface.labels || []).map((a) => {
return typeof a === "string" ? { id: a, description: a } : a
}) || [],
}),
[iface.labels, iface.multiple]
)
Expand All @@ -43,7 +43,14 @@ export default ({ iface, onChange }) => {
noActions
variant="flat"
defaultAnswers={defaultAnswers}
onQuestionChange={(questionId, newValue, answers) => {
onQuestionChange={(questionId, newValue) => {
var arrayId = []
if (Array.isArray(newValue))
newValue = newValue.filter((json) => {
if (arrayId.includes(json.id)) return false
arrayId.push(json.id)
return true
})
onChange(setIn(iface, [questionId], newValue))
}}
form={form}
Expand Down

0 comments on commit fc5ec54

Please sign in to comment.