-
-
Notifications
You must be signed in to change notification settings - Fork 206
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Edit criterion type functionality (#2516)
* refactor(#2405): Extract components for reuse * refactor(#2405): remove unneeded constructions * refactor: move TaskType to constants * refactor: criteria actions as text * refactor: rename prop * refactor: get rid of input type * feat: try to change select value * feat: changeTaskType * fix cancel * chore: comment * refactor: cleanup props * refactor: use map * refactor: debug * refactor: make it work * chore: remove todo * chore: remove unneeded * chore: format
- Loading branch information
Natalia Gulko
authored
Jul 24, 2024
1 parent
364c88f
commit c957ad5
Showing
13 changed files
with
232 additions
and
145 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { FC } from 'react'; | ||
import { CriteriaDto } from '../../api'; | ||
import { Popconfirm, Typography, Space } from 'antd'; | ||
|
||
interface CriteriaActionsProps { | ||
editing: boolean; | ||
record: CriteriaDto; | ||
editingKey: string; | ||
save: (key: string) => void; | ||
remove: (key: string) => void; | ||
cancel: () => void; | ||
edit: (record: CriteriaDto) => void; | ||
} | ||
|
||
export const CriteriaActions: FC<CriteriaActionsProps> = ({ | ||
editing, | ||
cancel, | ||
remove, | ||
edit, | ||
save, | ||
record, | ||
editingKey, | ||
}) => | ||
editing ? ( | ||
<Space direction="horizontal"> | ||
<Typography.Link onClick={() => save(record.key)}>Save</Typography.Link> | ||
<Typography.Link type="secondary" onClick={cancel}> | ||
Cancel | ||
</Typography.Link> | ||
</Space> | ||
) : ( | ||
<Space direction="horizontal"> | ||
<Typography.Link disabled={!!editingKey} onClick={() => edit(record)}> | ||
Edit | ||
</Typography.Link> | ||
<Popconfirm | ||
title="Are you sure to delete this criteria?" | ||
okText="Delete" | ||
okButtonProps={{ | ||
danger: true, | ||
}} | ||
onConfirm={() => remove(record.key)} | ||
> | ||
<Typography.Link disabled={!!editingKey} type="danger"> | ||
Delete | ||
</Typography.Link> | ||
</Popconfirm> | ||
</Space> | ||
); |
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,18 @@ | ||
import { Select } from 'antd'; | ||
import { FC } from 'react'; | ||
import { TaskType } from './constants'; | ||
import { SelectProps } from 'antd/lib'; | ||
|
||
const options = Object.entries(TaskType).map(([label, value]) => ({ label, value })); | ||
|
||
interface CriteriaTypeSelectProps extends SelectProps {} | ||
|
||
export const CriteriaTypeSelect: FC<CriteriaTypeSelectProps> = props => ( | ||
<Select placeholder="Select type" {...props}> | ||
{options.map(({ label, value }) => ( | ||
<Select.Option data-testid={label} value={value} key={label}> | ||
{label} | ||
</Select.Option> | ||
))} | ||
</Select> | ||
); |
40 changes: 11 additions & 29 deletions
40
client/src/modules/CrossCheck/EditableCellForCrossCheck.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
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,36 @@ | ||
import { Form, Input, InputNumber } from 'antd'; | ||
import { FC } from 'react'; | ||
import { CriteriaTypeSelect } from './CriteriaTypeSelect'; | ||
import { EditableTableColumnsDataIndex, TaskType } from './constants'; | ||
import { CriteriaDtoTypeEnum } from 'api'; | ||
|
||
interface EditableCriteriaInputProps { | ||
type?: CriteriaDtoTypeEnum; | ||
dataIndex: EditableTableColumnsDataIndex; | ||
onSelectChange: (value: string) => void; | ||
} | ||
|
||
export const EditableCriteriaInput: FC<EditableCriteriaInputProps> = ({ dataIndex, onSelectChange, type }) => { | ||
switch (dataIndex) { | ||
case EditableTableColumnsDataIndex.Max: | ||
return type !== TaskType.Title ? ( | ||
<Form.Item name={dataIndex} style={{ margin: 0 }}> | ||
<InputNumber style={{ width: 65 }} /> | ||
</Form.Item> | ||
) : null; | ||
case EditableTableColumnsDataIndex.Type: | ||
return ( | ||
<Form.Item name={dataIndex} style={{ margin: 0 }}> | ||
<CriteriaTypeSelect onChange={onSelectChange} /> | ||
</Form.Item> | ||
); | ||
case EditableTableColumnsDataIndex.Text: | ||
return ( | ||
<Form.Item name={dataIndex} style={{ margin: 0 }}> | ||
<Input.TextArea rows={3} /> | ||
</Form.Item> | ||
); | ||
default: | ||
return null; | ||
} | ||
}; |
Oops, something went wrong.