mirror of
https://github.com/haiwen/seahub.git
synced 2025-08-28 19:51:34 +00:00
[fix] rename metdata column name (#6511)
This commit is contained in:
parent
e5d92ccb9e
commit
b5e28df790
@ -3,11 +3,3 @@
|
|||||||
min-width: 350px;
|
min-width: 350px;
|
||||||
width: 350px;
|
width: 350px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sf-metadata-rename-column-popover .popover-body {
|
|
||||||
padding: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.sf-metadata-rename-column-popover .form-group {
|
|
||||||
margin-bottom: 0;
|
|
||||||
}
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { Form, FormGroup, Input, PopoverBody } from 'reactstrap';
|
import { Input, PopoverBody } from 'reactstrap';
|
||||||
import { CustomizePopover } from '@seafile/sf-metadata-ui-component';
|
import { CustomizePopover } from '@seafile/sf-metadata-ui-component';
|
||||||
import { KeyCodes } from '../../../../../constants';
|
import { KeyCodes } from '../../../../../constants';
|
||||||
import { ValidateColumnFormFields } from '../column-popover/utils';
|
import { ValidateColumnFormFields } from '../column-popover/utils';
|
||||||
@ -23,13 +23,17 @@ const RenamePopover = ({ value: oldValue, target, onToggle, onSubmit }) => {
|
|||||||
}, [value]);
|
}, [value]);
|
||||||
|
|
||||||
const handleSubmit = useCallback(() => {
|
const handleSubmit = useCallback(() => {
|
||||||
|
if (value === oldValue) {
|
||||||
|
onToggle();
|
||||||
|
return;
|
||||||
|
}
|
||||||
const valueError = ValidateColumnFormFields[COMMON_FORM_FIELD_TYPE.COLUMN_NAME]({ columnName: value, metadata, gettext });
|
const valueError = ValidateColumnFormFields[COMMON_FORM_FIELD_TYPE.COLUMN_NAME]({ columnName: value, metadata, gettext });
|
||||||
if (valueError) {
|
if (valueError) {
|
||||||
toaster.danger(valueError.tips);
|
toaster.danger(valueError.tips);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
onSubmit(value);
|
onSubmit(value);
|
||||||
}, [value, metadata, onSubmit]);
|
}, [value, oldValue, metadata, onSubmit, onToggle]);
|
||||||
|
|
||||||
const onHotKey = useCallback((event) => {
|
const onHotKey = useCallback((event) => {
|
||||||
if (event.keyCode === KeyCodes.Enter) {
|
if (event.keyCode === KeyCodes.Enter) {
|
||||||
@ -52,12 +56,8 @@ const RenamePopover = ({ value: oldValue, target, onToggle, onSubmit }) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<CustomizePopover target={target} className="sf-metadata-rename-column-popover" hide={handleSubmit} hideWithEsc={onToggle}>
|
<CustomizePopover target={target} className="sf-metadata-rename-column-popover" hide={handleSubmit} hideWithEsc={onToggle}>
|
||||||
<PopoverBody>
|
<PopoverBody className='p-4'>
|
||||||
<Form>
|
|
||||||
<FormGroup>
|
|
||||||
<Input value={value} innerRef={inputRef} onClick={onClick} onChange={onChange} />
|
<Input value={value} innerRef={inputRef} onClick={onClick} onChange={onChange} />
|
||||||
</FormGroup>
|
|
||||||
</Form>
|
|
||||||
</PopoverBody>
|
</PopoverBody>
|
||||||
</CustomizePopover>
|
</CustomizePopover>
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user