mirror of
https://github.com/actualbudget/actual.git
synced 2026-03-11 12:43:09 -05:00
API – Return Hidden for Category and CategoryGroup (#2062)
This commit is contained in:
@@ -119,6 +119,11 @@ describe('API CRUD operations', () => {
|
||||
name: 'test-budget',
|
||||
group_id: mainGroupId,
|
||||
});
|
||||
const categoryIdHidden = await api.createCategory({
|
||||
name: 'test-budget-hidden',
|
||||
group_id: mainGroupId,
|
||||
hidden: true,
|
||||
});
|
||||
|
||||
let categories = await api.getCategories();
|
||||
expect(categories).toEqual(
|
||||
@@ -126,6 +131,13 @@ describe('API CRUD operations', () => {
|
||||
expect.objectContaining({
|
||||
id: categoryId,
|
||||
name: 'test-budget',
|
||||
hidden: false,
|
||||
group_id: mainGroupId,
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: categoryIdHidden,
|
||||
name: 'test-budget-hidden',
|
||||
hidden: true,
|
||||
group_id: mainGroupId,
|
||||
}),
|
||||
]),
|
||||
@@ -137,12 +149,25 @@ describe('API CRUD operations', () => {
|
||||
group_id: secondaryGroupId,
|
||||
});
|
||||
|
||||
await api.updateCategory(categoryIdHidden, {
|
||||
name: 'updated-budget-hidden',
|
||||
group_id: secondaryGroupId,
|
||||
hidden: false,
|
||||
});
|
||||
|
||||
categories = await api.getCategories();
|
||||
expect(categories).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: categoryId,
|
||||
name: 'updated-budget',
|
||||
hidden: false,
|
||||
group_id: secondaryGroupId,
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: categoryIdHidden,
|
||||
name: 'updated-budget-hidden',
|
||||
hidden: false,
|
||||
group_id: secondaryGroupId,
|
||||
}),
|
||||
]),
|
||||
|
||||
@@ -274,6 +274,7 @@ function Budget(props: BudgetProps) {
|
||||
category.name,
|
||||
category.cat_group,
|
||||
category.is_income,
|
||||
category.hidden,
|
||||
);
|
||||
|
||||
setNewCategoryForGroup(null);
|
||||
|
||||
@@ -134,12 +134,14 @@ export function createCategory(
|
||||
name: string,
|
||||
groupId: string,
|
||||
isIncome: boolean,
|
||||
hidden: boolean,
|
||||
) {
|
||||
return async (dispatch: Dispatch) => {
|
||||
const id = await send('category-create', {
|
||||
name,
|
||||
groupId,
|
||||
isIncome,
|
||||
hidden,
|
||||
});
|
||||
dispatch(getCategories());
|
||||
return id;
|
||||
|
||||
@@ -32,6 +32,7 @@ export const categoryModel = {
|
||||
id: category.id,
|
||||
name: category.name,
|
||||
is_income: category.is_income ? true : false,
|
||||
hidden: category.hidden ? true : false,
|
||||
group_id: category.cat_group,
|
||||
};
|
||||
},
|
||||
@@ -41,6 +42,9 @@ export const categoryModel = {
|
||||
if ('is_income' in category) {
|
||||
result.is_income = category.is_income ? 1 : 0;
|
||||
}
|
||||
if ('hidden' in category) {
|
||||
result.hidden = category.hidden ? 1 : 0;
|
||||
}
|
||||
if ('group_id' in category) {
|
||||
result.cat_group = category.group_id;
|
||||
}
|
||||
@@ -56,6 +60,7 @@ export const categoryGroupModel = {
|
||||
id: group.id,
|
||||
name: group.name,
|
||||
is_income: group.is_income ? true : false,
|
||||
hidden: group.hidden ? true : false,
|
||||
categories: group.categories.map(categoryModel.toExternal),
|
||||
};
|
||||
},
|
||||
@@ -65,6 +70,9 @@ export const categoryGroupModel = {
|
||||
if ('is_income' in group) {
|
||||
result.is_income = group.is_income ? 1 : 0;
|
||||
}
|
||||
if ('hidden' in group) {
|
||||
result.hidden = group.hidden ? 1 : 0;
|
||||
}
|
||||
if ('categories' in group) {
|
||||
result.categories = group.categories.map(categoryModel.fromExternal);
|
||||
}
|
||||
|
||||
@@ -556,6 +556,7 @@ handlers['api/category-create'] = withMutation(async function ({ category }) {
|
||||
name: category.name,
|
||||
groupId: category.group_id,
|
||||
isIncome: category.is_income,
|
||||
hidden: category.hidden,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -278,6 +278,7 @@ handlers['category-create'] = mutator(async function ({
|
||||
name,
|
||||
groupId,
|
||||
isIncome,
|
||||
hidden,
|
||||
}) {
|
||||
return withUndo(async () => {
|
||||
if (!groupId) {
|
||||
@@ -288,6 +289,7 @@ handlers['category-create'] = mutator(async function ({
|
||||
name,
|
||||
cat_group: groupId,
|
||||
is_income: isIncome ? 1 : 0,
|
||||
hidden: hidden ? 1 : 0,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -74,7 +74,12 @@ export interface ServerHandlers {
|
||||
|
||||
'budget-set-type': (arg: { type }) => Promise<unknown>;
|
||||
|
||||
'category-create': (arg: { name; groupId; isIncome }) => Promise<unknown>;
|
||||
'category-create': (arg: {
|
||||
name;
|
||||
groupId;
|
||||
isIncome;
|
||||
hidden: boolean;
|
||||
}) => Promise<unknown>;
|
||||
|
||||
'category-update': (category) => Promise<unknown>;
|
||||
|
||||
|
||||
6
upcoming-release-notes/2062.md
Normal file
6
upcoming-release-notes/2062.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
category: Enhancements
|
||||
authors: [iOSLife]
|
||||
---
|
||||
|
||||
Adds a property to the returned items in the API for category and categoryGroup to inform if it is hidden.
|
||||
Reference in New Issue
Block a user