Repository navigation
feat(csm-timecards): searchable filters, minutes not hours, tighter approver gating #1055
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
Merged
rksk
merged 3 commits into
wso2-open-operations:dev-app-csm-portal
from
Hesara2003:feature/timecards-filter-dropdowns
Jul 6, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
89 changes: 89 additions & 0 deletions
89
apps/csm-portal/webapp/src/components/MultiSelectField.tsx
This file contains hidden or 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,89 @@ | ||
| // Copyright (c) 2026 WSO2 LLC. (https://www.wso2.com). | ||
| // | ||
| // WSO2 LLC. licenses this file to you under the Apache License, | ||
| // Version 2.0 (the "License"); you may not use this file except | ||
| // in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
|
|
||
| import { Autocomplete, Checkbox, Chip, ListItemText, TextField } from "@wso2/oxygen-ui"; | ||
| import type * as React from "react"; | ||
| import type { JSX } from "react"; | ||
|
|
||
| export interface MultiSelectFieldProps<T extends string> { | ||
| id: string; | ||
| label: string; | ||
| values: T[]; | ||
| options: { value: T; label: string }[]; | ||
| onChange: (next: T[]) => void; | ||
| disabled?: boolean; | ||
| } | ||
|
|
||
| /** | ||
| * Autocomplete-based multi-select for a fixed, small set of options (e.g. an | ||
| * enum) — selected values render as chips, options are type-to-search + | ||
| * checkboxes. Pairs with {@link SearchableMultiSelect} for larger/dynamic | ||
| * option lists. Extracted from `CasesFilterBar.tsx` so other feature filter | ||
| * bars (e.g. time cards) can reuse the same look and behavior. | ||
| */ | ||
| export default function MultiSelectField<T extends string>({ | ||
| id, | ||
| label, | ||
| values, | ||
| options, | ||
| onChange, | ||
| disabled, | ||
| }: MultiSelectFieldProps<T>): JSX.Element { | ||
| const selected = options.filter((o) => values.includes(o.value)); | ||
| return ( | ||
| <Autocomplete<{ value: T; label: string }, true> | ||
| multiple | ||
| size="small" | ||
| id={id} | ||
| disabled={disabled} | ||
| options={options} | ||
| value={selected} | ||
| disableCloseOnSelect | ||
| getOptionLabel={(o) => o.label} | ||
| isOptionEqualToValue={(o, v) => o.value === v.value} | ||
| onChange={(_event, next) => onChange(next.map((o) => o.value))} | ||
| renderTags={(value, getTagProps) => | ||
| value.map((option, index) => { | ||
| const { key, ...tagProps } = getTagProps({ index }); | ||
| return ( | ||
| <Chip key={key} size="small" label={option.label} {...tagProps} /> | ||
| ); | ||
| }) | ||
| } | ||
| renderOption={(props, option, { selected: isSelected }) => { | ||
| const { key, ...liProps } = props as React.HTMLAttributes<HTMLLIElement> & { | ||
| key: string; | ||
| }; | ||
| return ( | ||
| <li key={key} {...liProps} style={{ paddingTop: 2, paddingBottom: 2 }}> | ||
| <Checkbox size="small" checked={isSelected} sx={{ mr: 1, p: 0.25 }} /> | ||
| <ListItemText | ||
| primary={option.label} | ||
| slotProps={{ primary: { style: { fontSize: 13 } } }} | ||
| /> | ||
| </li> | ||
| ); | ||
| }} | ||
| renderInput={(params) => ( | ||
| <TextField | ||
| {...params} | ||
| label={label} | ||
| placeholder={values.length ? undefined : "Select…"} | ||
| /> | ||
| )} | ||
| /> | ||
| ); | ||
| } |
131 changes: 131 additions & 0 deletions
131
apps/csm-portal/webapp/src/components/SearchableMultiSelect.tsx
This file contains hidden or 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,131 @@ | ||
| // Copyright (c) 2026 WSO2 LLC. (https://www.wso2.com). | ||
| // | ||
| // WSO2 LLC. licenses this file to you under the Apache License, | ||
| // Version 2.0 (the "License"); you may not use this file except | ||
| // in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
|
|
||
| import { Autocomplete, Checkbox, Chip, ListItemText, TextField } from "@wso2/oxygen-ui"; | ||
| import type * as React from "react"; | ||
| import type { JSX } from "react"; | ||
|
|
||
| export interface SearchableMultiSelectProps { | ||
| id: string; | ||
| label: string; | ||
| placeholder?: string; | ||
| values: string[]; | ||
| options: string[]; | ||
| /** Optional renderer for option labels (e.g. an `@me` sentinel → "Me"). */ | ||
| formatOption?: (value: string) => string; | ||
| /** Optional secondary line shown beneath each option (e.g. email). */ | ||
| getOptionSecondary?: (value: string) => string | undefined; | ||
| /** Optional filter against synthetic text (e.g. include email in the query). */ | ||
| getOptionSearchText?: (value: string) => string; | ||
| onChange: (next: string[]) => void; | ||
| disabled?: boolean; | ||
| } | ||
|
|
||
| /** | ||
| * Multi-select autocomplete. Users type to filter the option list and | ||
| * select multiple. Picked values render as removable chips inside the field. | ||
| * Internally a thin wrapper over MUI Autocomplete so we keep oxygen-ui | ||
| * theming via the re-exported components. Extracted from `CasesFilterBar.tsx` | ||
| * so other feature filter bars (e.g. time cards) can reuse the same look and | ||
| * behavior instead of a plain free-text field. | ||
| */ | ||
| export default function SearchableMultiSelect({ | ||
| id, | ||
| label, | ||
| placeholder, | ||
| values, | ||
| options, | ||
| formatOption, | ||
| getOptionSecondary, | ||
| getOptionSearchText, | ||
| onChange, | ||
| disabled, | ||
| }: SearchableMultiSelectProps): JSX.Element { | ||
| const format = formatOption ?? ((v: string) => v); | ||
| const searchText = getOptionSearchText ?? format; | ||
| return ( | ||
| <Autocomplete | ||
| multiple | ||
| size="small" | ||
| disabled={disabled} | ||
| id={id} | ||
| options={options} | ||
| value={values} | ||
| onChange={(_event, next) => onChange(next as string[])} | ||
| disableCloseOnSelect | ||
| // MUI's own available-space heuristic sometimes flips the list above | ||
| // the field even when there's clearly room below (e.g. sitting above a | ||
| // data table) — pin it open downward instead of guessing. | ||
| slotProps={{ | ||
| popper: { | ||
| placement: "bottom-start", | ||
| modifiers: [{ name: "flip", enabled: false }], | ||
| }, | ||
| }} | ||
| getOptionLabel={(opt) => format(opt as string)} | ||
| isOptionEqualToValue={(opt, val) => opt === val} | ||
| filterOptions={(opts, state) => { | ||
| const q = state.inputValue.trim().toLowerCase(); | ||
| if (!q) return opts; | ||
| return opts.filter((o) => searchText(o as string).toLowerCase().includes(q)); | ||
| }} | ||
| renderTags={(value, getTagProps) => | ||
| value.map((option, index) => { | ||
| const { key, ...tagProps } = getTagProps({ index }); | ||
| return ( | ||
| <Chip | ||
| key={key} | ||
| size="small" | ||
| label={format(option as string)} | ||
| {...tagProps} | ||
| /> | ||
| ); | ||
| }) | ||
| } | ||
| renderOption={(props, option, { selected }) => { | ||
| const { key, ...liProps } = props as React.HTMLAttributes<HTMLLIElement> & { | ||
| key: string; | ||
| }; | ||
| const primary = format(option as string); | ||
| const secondary = getOptionSecondary?.(option as string); | ||
| return ( | ||
| <li key={key} {...liProps} style={{ paddingTop: 2, paddingBottom: 2 }}> | ||
| <Checkbox | ||
| size="small" | ||
| checked={selected} | ||
| sx={{ mr: 1, p: 0.25 }} | ||
| /> | ||
| <ListItemText | ||
| primary={primary} | ||
| secondary={secondary} | ||
| slotProps={{ | ||
| primary: { style: { fontSize: 13 } }, | ||
| secondary: { style: { fontSize: 11 } }, | ||
| }} | ||
| /> | ||
| </li> | ||
| ); | ||
| }} | ||
| renderInput={(params) => ( | ||
| <TextField | ||
| {...params} | ||
| label={label} | ||
| placeholder={values.length ? undefined : placeholder ?? "Type to search…"} | ||
| /> | ||
| )} | ||
| /> | ||
| ); | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.