-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from openimis/feature/ONI-255
ONI-255: Basic allowed task source picker and filtering.
- Loading branch information
Showing
8 changed files
with
79 additions
and
7 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
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,35 @@ | ||
import React from 'react'; | ||
import { Autocomplete, useTranslations, useModulesManager } from '@openimis/fe-core'; | ||
import { TASK_CONTRIBUTION_KEY } from '../constants'; | ||
|
||
function TaskSourceAllowedPicker({ | ||
onChange, readOnly, required, withLabel, value, | ||
}) { | ||
const modulesManager = useModulesManager(); | ||
const { formatMessage } = useTranslations('tasksManagement'); | ||
const contributions = modulesManager.getContribs(TASK_CONTRIBUTION_KEY); | ||
const allowedSources = contributions.flatMap((contribution) => { | ||
const source = contribution.taskSource; | ||
return source ? source.map((item) => ({ id: item, name: item })) : []; | ||
}); | ||
|
||
return ( | ||
<Autocomplete | ||
multiple | ||
required={required} | ||
label={formatMessage('TaskSourceAllowedPicker.label')} | ||
placeholder={formatMessage('TaskSourceAllowedPicker.placeholder')} | ||
readOnly={readOnly} | ||
withLabel={withLabel} | ||
withPlaceholder={!value?.length} | ||
options={allowedSources} | ||
value={value} | ||
getOptionLabel={(source) => `${source.name}`} | ||
onChange={onChange} | ||
filterSelectedOptions | ||
onInputChange={() => {}} | ||
/> | ||
); | ||
} | ||
|
||
export default TaskSourceAllowedPicker; |
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