-
Notifications
You must be signed in to change notification settings - Fork 21
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 #455 from commons-stack/enh/user_event_logs
User Event Logs - filter, search and sorting
- Loading branch information
Showing
15 changed files
with
525 additions
and
104 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
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
94 changes: 94 additions & 0 deletions
94
packages/frontend/src/components/form/MultiselectInput.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,94 @@ | ||
import { faChevronDown } from '@fortawesome/free-solid-svg-icons'; | ||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; | ||
import { Listbox, Transition } from '@headlessui/react'; | ||
import { Fragment } from 'react'; | ||
|
||
interface ISelectedItem { | ||
key: string; | ||
label: string; | ||
} | ||
|
||
interface MultiselectInputProps { | ||
selected: ISelectedItem[]; | ||
handleChange: (element) => void; | ||
options: ISelectedItem[]; | ||
noSelectedMessage: string; | ||
} | ||
|
||
const MultiselectInput = ({ | ||
handleChange, | ||
selected, | ||
options, | ||
noSelectedMessage, | ||
}: MultiselectInputProps): JSX.Element => { | ||
return ( | ||
<div className="relative w-60 border border-gray-400 h-[42px]"> | ||
<Listbox value={selected} onChange={handleChange} multiple> | ||
<Listbox.Button className=" pl-2 pr-8 text-left h-[42px] w-full bg-transparent border-none outline-none focus:ring-0 "> | ||
{(): JSX.Element => ( | ||
<> | ||
<span className="block truncate"> | ||
{selected.length === 0 && noSelectedMessage} | ||
{selected.length > 3 | ||
? `${selected.length} items.` | ||
: selected | ||
.map((filter) => | ||
filter && filter.label ? filter.label : '' | ||
) | ||
.join(', ')} | ||
</span> | ||
|
||
<div className="absolute inset-y-0 right-0 flex items-center pr-3"> | ||
<span className="text-gray-800"> | ||
<FontAwesomeIcon icon={faChevronDown} className="mt-[-1]" /> | ||
</span> | ||
</div> | ||
</> | ||
)} | ||
</Listbox.Button> | ||
<Transition | ||
as={Fragment} | ||
leave="transition ease-in duration-100" | ||
leaveFrom="opacity-100" | ||
leaveTo="opacity-0" | ||
> | ||
<Listbox.Options className="absolute w-full py-1 mt-1 overflow-auto bg-white border border-gray-400 max-h-60"> | ||
{options.map((filter, filterIdx) => ( | ||
<Listbox.Option | ||
key={filterIdx} | ||
className={({ active }): string => | ||
`relative cursor-default select-none py-2 pl-10 pr-4 ${ | ||
active ? 'bg-gray-100 text-gray-900' : 'text-gray-600' | ||
}` | ||
} | ||
value={filter} | ||
> | ||
{({ selected }): JSX.Element => ( | ||
<> | ||
<span | ||
className={`block truncate ${ | ||
selected ? 'font-medium' : 'font-normal' | ||
}`} | ||
> | ||
{filter.label} | ||
</span> | ||
<span className="absolute inset-y-0 left-0 flex items-center pl-3 text-gray-600"> | ||
<input | ||
type="checkbox" | ||
className="w-4 h-4 mr-4 text-black focus:ring-0" | ||
checked={selected} | ||
onChange={(): void => {}} | ||
/> | ||
</span> | ||
</> | ||
)} | ||
</Listbox.Option> | ||
))} | ||
</Listbox.Options> | ||
</Transition> | ||
</Listbox> | ||
</div> | ||
); | ||
}; | ||
|
||
export default MultiselectInput; |
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,38 @@ | ||
import { faMagnifyingGlass } from '@fortawesome/free-solid-svg-icons'; | ||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; | ||
|
||
interface SearchInputProps { | ||
handleChange: (element) => void; | ||
value: string; | ||
} | ||
|
||
const SearchInput = ({ | ||
handleChange, | ||
value, | ||
}: SearchInputProps): JSX.Element => { | ||
return ( | ||
<div className="relative flex items-center border border-gray-400 h-[42px]"> | ||
<div className="absolute inset-y-0 left-0 flex items-center pl-3"> | ||
<span className="text-gray-800"> | ||
<FontAwesomeIcon | ||
icon={faMagnifyingGlass} | ||
size="1x" | ||
className="absolute transform -translate-y-1/2 top-1/2 left-3" | ||
/> | ||
</span> | ||
</div> | ||
<input | ||
className="h-[42px] block pl-8 bg-transparent border-none outline-none focus:ring-0" | ||
name="search" | ||
type="text" | ||
placeholder="Search" | ||
value={value} | ||
onChange={(e: React.ChangeEvent<HTMLInputElement>): void => | ||
handleChange(e.target.value) | ||
} | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
export default SearchInput; |
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,71 @@ | ||
import { IconProp } from '@fortawesome/fontawesome-svg-core'; | ||
import { faChevronDown } from '@fortawesome/free-solid-svg-icons'; | ||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; | ||
import { Listbox, Transition } from '@headlessui/react'; | ||
import { Fragment } from 'react'; | ||
|
||
interface ISelectedItem { | ||
value: string; | ||
label: string; | ||
} | ||
|
||
interface SelectInputProps { | ||
selected: ISelectedItem; | ||
handleChange: (element) => void; | ||
options: ISelectedItem[]; | ||
icon?: IconProp; | ||
} | ||
|
||
const SelectInput = ({ | ||
selected, | ||
handleChange, | ||
options, | ||
icon, | ||
}: SelectInputProps): JSX.Element => { | ||
return ( | ||
<div className="relative w-40 h-[42px]"> | ||
<Listbox value={selected} onChange={handleChange}> | ||
<Listbox.Button className="h-[42px] border border-gray-400 w-full py-1.5 pl-3 pr-10 text-left bg-transparent "> | ||
<span className="block truncate">{selected.label}</span> | ||
<div className="absolute inset-y-0 right-0 flex items-center pr-3"> | ||
<span className="text-gray-800 "> | ||
<FontAwesomeIcon icon={icon || faChevronDown} /> | ||
</span> | ||
</div> | ||
</Listbox.Button> | ||
<Transition | ||
as={Fragment} | ||
leave="transition ease-in duration-100" | ||
leaveFrom="opacity-100" | ||
leaveTo="opacity-0" | ||
> | ||
<Listbox.Options className="absolute w-full py-1 mt-1 overflow-auto bg-white border border-gray-400 max-h-60"> | ||
{options.map((s, sIdx) => ( | ||
<Listbox.Option | ||
key={sIdx} | ||
className={({ active }): string => | ||
`relative cursor-default select-none py-2 pl-4 pr-4 ${ | ||
active ? 'bg-gray-100 text-gray-900' : 'text-gray-600' | ||
}` | ||
} | ||
value={s} | ||
> | ||
{({ selected }): JSX.Element => ( | ||
<span | ||
className={`block truncate ${ | ||
selected ? 'font-medium' : 'font-normal' | ||
}`} | ||
> | ||
{s.label} | ||
</span> | ||
)} | ||
</Listbox.Option> | ||
))} | ||
</Listbox.Options> | ||
</Transition> | ||
</Listbox> | ||
</div> | ||
); | ||
}; | ||
|
||
export default SelectInput; |
Oops, something went wrong.