mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-20 06:40:31 +00:00
fix: remove parent category.
This commit is contained in:
@@ -30,34 +30,6 @@ export default function ItemCategoryForm({
|
|||||||
}) {
|
}) {
|
||||||
const categoryNameFieldRef = useAutofocus();
|
const categoryNameFieldRef = useAutofocus();
|
||||||
|
|
||||||
// Filters Item Categories list.
|
|
||||||
const filterItemCategories = useCallback(
|
|
||||||
(query, category, _index, exactMatch) => {
|
|
||||||
const normalizedTitle = category.name.toLowerCase();
|
|
||||||
const normalizedQuery = query.toLowerCase();
|
|
||||||
|
|
||||||
if (exactMatch) {
|
|
||||||
return normalizedTitle === normalizedQuery;
|
|
||||||
} else {
|
|
||||||
return normalizedTitle.indexOf(normalizedQuery) >= 0;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
[],
|
|
||||||
);
|
|
||||||
|
|
||||||
const parentCategoryItem = useCallback(
|
|
||||||
(category, { handleClick, modifiers, query }) => {
|
|
||||||
return (
|
|
||||||
<MenuItem
|
|
||||||
text={category.name}
|
|
||||||
key={category.id}
|
|
||||||
onClick={handleClick}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
},
|
|
||||||
[],
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Form>
|
<Form>
|
||||||
<div className={Classes.DIALOG_BODY}>
|
<div className={Classes.DIALOG_BODY}>
|
||||||
@@ -81,38 +53,6 @@ export default function ItemCategoryForm({
|
|||||||
)}
|
)}
|
||||||
</FastField>
|
</FastField>
|
||||||
|
|
||||||
{/* ----------- Parent Category ----------- */}
|
|
||||||
<FastField name={'parent_category_id'}>
|
|
||||||
{({ form, field: { value }, meta: { error, touched } }) => (
|
|
||||||
<FormGroup
|
|
||||||
label={<T id={'parent_category'} />}
|
|
||||||
labelInfo={Hint}
|
|
||||||
className={classNames(
|
|
||||||
'form-group--select-list',
|
|
||||||
'form-group--parent-category',
|
|
||||||
Classes.FILL,
|
|
||||||
)}
|
|
||||||
inline={true}
|
|
||||||
helperText={<ErrorMessage name="parent_category_id" />}
|
|
||||||
intent={inputIntent({ error, touched })}
|
|
||||||
>
|
|
||||||
<ListSelect
|
|
||||||
items={categoriesList}
|
|
||||||
noResults={<MenuItem disabled={true} text="No results." />}
|
|
||||||
itemRenderer={parentCategoryItem}
|
|
||||||
itemPredicate={filterItemCategories}
|
|
||||||
popoverProps={{ minimal: true }}
|
|
||||||
onItemSelect={(parentCategory) => {
|
|
||||||
form.setFieldValue('parent_category_id', parentCategory.id);
|
|
||||||
}}
|
|
||||||
selectedItem={value}
|
|
||||||
selectedItemProp={'id'}
|
|
||||||
defaultText={<T id={'select_parent_category'} />}
|
|
||||||
labelProp={'name'}
|
|
||||||
/>
|
|
||||||
</FormGroup>
|
|
||||||
)}
|
|
||||||
</FastField>
|
|
||||||
|
|
||||||
{/* ----------- Description ----------- */}
|
{/* ----------- Description ----------- */}
|
||||||
<FastField name={'description'}>
|
<FastField name={'description'}>
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ import { compose, transformToForm } from 'utils';
|
|||||||
const defaultInitialValues = {
|
const defaultInitialValues = {
|
||||||
name: '',
|
name: '',
|
||||||
description: '',
|
description: '',
|
||||||
parent_category_id: '',
|
|
||||||
cost_account_id: '',
|
cost_account_id: '',
|
||||||
sell_account_id: '',
|
sell_account_id: '',
|
||||||
inventory_account_id: '',
|
inventory_account_id: '',
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ const Schema = Yup.object().shape({
|
|||||||
.required()
|
.required()
|
||||||
.max(DATATYPES_LENGTH.STRING)
|
.max(DATATYPES_LENGTH.STRING)
|
||||||
.label(formatMessage({ id: 'category_name_' })),
|
.label(formatMessage({ id: 'category_name_' })),
|
||||||
parent_category_id: Yup.number().nullable(),
|
|
||||||
cost_account_id: Yup.number().nullable(),
|
cost_account_id: Yup.number().nullable(),
|
||||||
sell_account_id: Yup.number().nullable(),
|
sell_account_id: Yup.number().nullable(),
|
||||||
inventory_account_id: Yup.number().nullable(),
|
inventory_account_id: Yup.number().nullable(),
|
||||||
|
|||||||
Reference in New Issue
Block a user