Skip to content

Commit

Permalink
Merge pull request #149 from Yo1L/patch-2
Browse files Browse the repository at this point in the history
Auto Select values (Column with select fields)
  • Loading branch information
masiulis authored Nov 6, 2023
2 parents a192098 + 07c1558 commit 8eacb23
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/steps/MatchColumnsStep/utils/setColumn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,18 @@ export const setColumn = <T extends string>(
): Column<T> => {
switch (field?.fieldType.type) {
case "select":
const uniqueData = uniqueEntries(data || [], oldColumn.index)
const matchedOptions = uniqueData?.map(option => {

Check failure on line 13 in src/steps/MatchColumnsStep/utils/setColumn.ts

View workflow job for this annotation

GitHub Actions / unit-tests

Replace `option` with `(option)`
const value = field.fieldType.options.find(o => o.value == option.value || o.label == option.entry)?.value

Check failure on line 14 in src/steps/MatchColumnsStep/utils/setColumn.ts

View workflow job for this annotation

GitHub Actions / unit-tests

Replace `o` with `(o)`
return value ? {...option, value} as MatchedOptions<T> : option as MatchedOptions<T>

Check failure on line 15 in src/steps/MatchColumnsStep/utils/setColumn.ts

View workflow job for this annotation

GitHub Actions / unit-tests

Replace `{...option,·value}·as·MatchedOptions<T>··:·option·as·MatchedOptions<T>` with `({·...option,·value·}·as·MatchedOptions<T>)·:·(option·as·MatchedOptions<T>)`
})
const allMatched = matchedOptions.filter(o => o.value).length == uniqueData?.length

Check failure on line 17 in src/steps/MatchColumnsStep/utils/setColumn.ts

View workflow job for this annotation

GitHub Actions / unit-tests

Replace `o` with `(o)`

return {
...oldColumn,
type: ColumnType.matchedSelect,
type: allMatched ? ColumnType.matchedSelectOptions : ColumnType.matchedSelect,
value: field.key,
matchedOptions: uniqueEntries(data || [], oldColumn.index),
matchedOptions

Check failure on line 23 in src/steps/MatchColumnsStep/utils/setColumn.ts

View workflow job for this annotation

GitHub Actions / unit-tests

Insert `,`
}
case "checkbox":
return { index: oldColumn.index, type: ColumnType.matchedCheckbox, value: field.key, header: oldColumn.header }
Expand Down

0 comments on commit 8eacb23

Please sign in to comment.