-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CM-722: allow to add task source to task group (#35)
- Loading branch information
1 parent
25bdb11
commit cb3066b
Showing
5 changed files
with
61 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import React from 'react'; | ||
import { | ||
Autocomplete, useTranslations, useModulesManager, | ||
} from '@openimis/fe-core'; | ||
import { TASK_CONTRIBUTION_KEY } from '../constants'; | ||
|
||
function TaskSourcePicker({ | ||
onChange, | ||
readOnly, | ||
required, | ||
withLabel, | ||
value, | ||
}) { | ||
const modulesManager = useModulesManager(); | ||
const { formatMessage } = useTranslations('tasksManagement'); | ||
const contributions = modulesManager.getContribs(TASK_CONTRIBUTION_KEY); | ||
const sources = contributions.flatMap((contribution) => { | ||
const source = contribution.taskSource; | ||
return source ? [{ id: source, name: source }] : []; | ||
}); | ||
|
||
return ( | ||
<Autocomplete | ||
multiple | ||
required={required} | ||
label={formatMessage('TaskSourcePicker.label')} | ||
placeholder={formatMessage('TaskSourcePicker.placeholder')} | ||
readOnly={readOnly} | ||
withLabel={withLabel} | ||
withPlaceholder={!value?.length} | ||
options={sources} | ||
value={value} | ||
getOptionLabel={(source) => `${source.name}`} | ||
onChange={onChange} | ||
filterSelectedOptions | ||
onInputChange={() => {}} | ||
/> | ||
); | ||
} | ||
|
||
export default TaskSourcePicker; |
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