forked from ddrilling/asb_cloud_front
Подправлен code style
makeActionHandler экспортирован из components/Table
This commit is contained in:
parent
91a9bf9c9f
commit
741449fb99
@ -4,7 +4,7 @@ import { OptionsType } from 'rc-select/lib/interface'
|
|||||||
import { tryAddKeys } from './EditableTable'
|
import { tryAddKeys } from './EditableTable'
|
||||||
import { makeNumericSorter, makeStringSorter} from './sorters'
|
import { makeNumericSorter, makeStringSorter} from './sorters'
|
||||||
export { makeDateSorter, makeNumericSorter, makeStringSorter} from './sorters'
|
export { makeDateSorter, makeNumericSorter, makeStringSorter} from './sorters'
|
||||||
export { EditableTable } from './EditableTable'
|
export { EditableTable, makeActionHandler } from './EditableTable'
|
||||||
export { DatePickerWrapper } from './DatePickerWrapper'
|
export { DatePickerWrapper } from './DatePickerWrapper'
|
||||||
export { SelectFromDictionary } from './SelectFromDictionary'
|
export { SelectFromDictionary } from './SelectFromDictionary'
|
||||||
|
|
||||||
|
@ -1,33 +1,27 @@
|
|||||||
export const makeNumericSorter = (key: string) => (a: any, b: any) => a[key] - b[key];
|
export const makeNumericSorter = (key: string) => (a: any, b: any) => Number(a[key]) - Number(b[key])
|
||||||
|
|
||||||
export const makeStringSorter = (key: string) => (a: any, b: any) => {
|
export const makeStringSorter = (key: string) => (a: any, b: any) => {
|
||||||
if (a == null && b == null)
|
if (a == null) return 1
|
||||||
return 1;
|
if (b == null) return -1
|
||||||
|
|
||||||
if (a == null)
|
const aValue = a[key]
|
||||||
return 1;
|
const bValue = b[key]
|
||||||
|
|
||||||
if (b == null)
|
for (let i = 0; i < a.length; i++) {
|
||||||
return -1;
|
if (isNaN(aValue.charCodeAt(i)) || (aValue.charCodeAt(i) > bValue.charCodeAt(i)))
|
||||||
|
return 1
|
||||||
|
|
||||||
let aValue = a[key];
|
if (aValue.charCodeAt(i) > bValue.charCodeAt(i))
|
||||||
let bValue = b[key];
|
return -1
|
||||||
|
}
|
||||||
for (let i = 0; i < a.length; i++) {
|
return 0
|
||||||
if (isNaN(aValue.charCodeAt(i)) || (aValue.charCodeAt(i) > bValue.charCodeAt(i)))
|
}
|
||||||
return 1;
|
|
||||||
|
|
||||||
if (aValue.charCodeAt(i) > bValue.charCodeAt(i))
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const makeDateSorter = (key: string) => (a: any, b: any) => {
|
export const makeDateSorter = (key: string) => (a: any, b: any) => {
|
||||||
const date = new Date(a[key]);
|
const date = new Date(a[key])
|
||||||
|
|
||||||
if (Number.isNaN(date.getTime()))
|
if (Number.isNaN(date.getTime()))
|
||||||
throw new Error('Date column contains not date formatted string(s)');
|
throw new Error('Date column contains not date formatted string(s)')
|
||||||
|
|
||||||
return date.getTime() - new Date(b[key]).getTime();
|
return date.getTime() - new Date(b[key]).getTime()
|
||||||
};
|
}
|
||||||
|
@ -79,16 +79,16 @@ export const UserMenu: React.FC<UserMenuProps> = ({ isAdmin }) => {
|
|||||||
onOk={() => form.submit()}
|
onOk={() => form.submit()}
|
||||||
>
|
>
|
||||||
<LoaderPortal show={showLoader}>
|
<LoaderPortal show={showLoader}>
|
||||||
<Form
|
<Form
|
||||||
{...formLayout}
|
{...formLayout}
|
||||||
form={form}
|
form={form}
|
||||||
name={'change-password'}
|
name={'change-password'}
|
||||||
onFinish={changePassword}
|
onFinish={changePassword}
|
||||||
>
|
>
|
||||||
<Form.Item label={'Новый пароль'} name={'new-password'} rules={passwordRules}>
|
<Form.Item label={'Новый пароль'} name={'new-password'} rules={passwordRules}>
|
||||||
<Input.Password onChange={(e) => setPassword(e.target.value)} value={password} />
|
<Input.Password onChange={(e) => setPassword(e.target.value)} value={password} />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
</Form>
|
</Form>
|
||||||
</LoaderPortal>
|
</LoaderPortal>
|
||||||
</Modal>
|
</Modal>
|
||||||
</>
|
</>
|
||||||
|
Loading…
Reference in New Issue
Block a user