-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NEOS-1628: Optimizes Bulk Set and Apply Default (#2968)
- Loading branch information
Showing
7 changed files
with
142 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
.../web/app/(mgmt)/[account]/jobs/[id]/source/components/useOnTransformerBulkUpdateClick.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { | ||
JobMappingFormValues, | ||
JobMappingTransformerForm, | ||
} from '@/yup-validations/jobs'; | ||
|
||
interface Props { | ||
getMappings(): JobMappingFormValues[]; | ||
setMappings(mappings: JobMappingFormValues[]): void; | ||
triggerUpdate(): void; | ||
} | ||
|
||
interface UseOnTransformerBulkUpdateClickResponse { | ||
onClick(indices: number[], transformer: JobMappingTransformerForm): void; | ||
} | ||
|
||
// Hook that provides an onClick handler that will handle setting specified job mappings to a the provided transformer | ||
export function useOnTransformerBulkUpdateClick( | ||
props: Props | ||
): UseOnTransformerBulkUpdateClickResponse { | ||
const { getMappings, triggerUpdate, setMappings } = props; | ||
|
||
return { | ||
onClick(indices, transformer) { | ||
if (indices.length === 0) { | ||
return; | ||
} | ||
|
||
const formMappings = getMappings(); | ||
|
||
indices.forEach((idx) => { | ||
if (formMappings[idx]) { | ||
formMappings[idx].transformer = transformer; | ||
} | ||
}); | ||
|
||
setMappings(formMappings); | ||
setTimeout(() => { | ||
triggerUpdate(); | ||
}, 0); | ||
}, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters