Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
bsekachev committed Jul 13, 2023
1 parent 56a28ec commit 0aac1af
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
20 changes: 11 additions & 9 deletions cvat-ui/src/components/labels-editor/label-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,15 @@ export default class LabelForm extends React.Component<Props> {
attrValues = [attrValues];
}
}
if (attrValues.length) {
attrValues.push('');
}
attrValues = attrValues.map((value: string) => value.trim());

return {
...attribute,
values: attrValues,
default_value: attrValues[0],
input_type: attribute.type.toLowerCase(),
};
}),
Expand Down Expand Up @@ -140,7 +144,6 @@ export default class LabelForm extends React.Component<Props> {
<Form.Item
hasFeedback
name={[key, 'name']}
fieldKey={[fieldInstance.fieldKey, 'name']}
initialValue={value}
rules={[
{
Expand All @@ -165,7 +168,7 @@ export default class LabelForm extends React.Component<Props> {

return (
<CVATTooltip title='An HTML element representing the attribute'>
<Form.Item name={[key, 'type']} fieldKey={[fieldInstance.fieldKey, 'type']} initialValue={type}>
<Form.Item name={[key, 'type']} initialValue={type}>
<Select className='cvat-attribute-type-input' disabled={locked}>
<Select.Option value={AttributeType.SELECT} className='cvat-attribute-type-input-select'>
Select
Expand Down Expand Up @@ -213,7 +216,6 @@ export default class LabelForm extends React.Component<Props> {
<CVATTooltip title='Press enter to add a new value'>
<Form.Item
name={[key, 'values']}
fieldKey={[fieldInstance.fieldKey, 'values']}
initialValue={existingValues}
rules={[
{
Expand All @@ -236,8 +238,9 @@ export default class LabelForm extends React.Component<Props> {
);
}

private renderBooleanValueInput(fieldInstance: any): JSX.Element {
private renderBooleanValueInput(fieldInstance: any, attr: SerializedAttribute | null): JSX.Element {
const { key } = fieldInstance;
const existingValues = attr ? attr.values[0] : 'false';

return (
<CVATTooltip title='Specify a default value'>
Expand All @@ -248,7 +251,6 @@ export default class LabelForm extends React.Component<Props> {
message: 'Please, specify a default value',
}]}
name={[key, 'values']}
fieldKey={[fieldInstance.fieldKey, 'values']}
>
<Select className='cvat-attribute-values-input'>
<Select.Option value='false'>False</Select.Option>
Expand All @@ -265,6 +267,8 @@ export default class LabelForm extends React.Component<Props> {
const value = attr ? attr.values : '';

const validator = (_: any, strNumbers: string): Promise<void> => {
if (typeof strNumbers !== 'string') return Promise.resolve();

const numbers = strNumbers.split(';').map((number): number => Number.parseFloat(number));
if (numbers.length !== 3) {
return Promise.reject(new Error('Three numbers are expected'));
Expand Down Expand Up @@ -296,7 +300,6 @@ export default class LabelForm extends React.Component<Props> {
return (
<Form.Item
name={[key, 'values']}
fieldKey={[fieldInstance.fieldKey, 'values']}
initialValue={value}
rules={[
{
Expand All @@ -319,14 +322,14 @@ export default class LabelForm extends React.Component<Props> {

if (attr?.input_type.toUpperCase() === 'TEXT') {
return (
<Form.Item name={[key, 'values']} fieldKey={[fieldInstance.fieldKey, 'values']} initialValue={value}>
<Form.Item name={[key, 'values']} initialValue={value}>
<Input.TextArea className='cvat-attribute-values-input' placeholder='Default value' />
</Form.Item>
);
}

return (
<Form.Item name={[key, 'values']} fieldKey={[fieldInstance.fieldKey, 'values']} initialValue={value}>
<Form.Item name={[key, 'values']} initialValue={value}>
<Input className='cvat-attribute-values-input' placeholder='Default value' />
</Form.Item>
);
Expand All @@ -341,7 +344,6 @@ export default class LabelForm extends React.Component<Props> {
<CVATTooltip title='Can this attribute be changed frame to frame?'>
<Form.Item
name={[key, 'mutable']}
fieldKey={[fieldInstance.fieldKey, 'mutable']}
initialValue={value}
valuePropName='checked'
>
Expand Down
2 changes: 1 addition & 1 deletion cvat-ui/src/components/labels-editor/labels-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ export default class LabelsEditor extends React.PureComponent<LabelsEditorProps,
name: attr.name,
id: attr.id as number < 0 ? undefined : attr.id,
input_type: attr.input_type.toLowerCase() as SerializedAttribute['input_type'],
default_value: attr.default_value || attr.values[0],
default_value: attr.default_value,
mutable: attr.mutable,
values: [...attr.values],
})),
Expand Down

0 comments on commit 0aac1af

Please sign in to comment.