Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto Select values (Column with select fields) #149

Merged
merged 2 commits into from
Nov 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
): 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
Loading