mirror of
https://github.com/actualbudget/actual.git
synced 2026-03-09 06:02:22 -05:00
Add Tag API docs (#6979)
* Add Tag object type definition for API docs * Add Tags nav entry to API reference sidebar * Add Tags methods and examples to API reference
This commit is contained in:
@@ -59,6 +59,14 @@ import APIList from './APIList';
|
||||
"mergePayees"
|
||||
]} />
|
||||
|
||||
<APIList title="Tags" sections={[
|
||||
"Tag",
|
||||
"getTags",
|
||||
"createTag",
|
||||
"updateTag",
|
||||
"deleteTag"
|
||||
]} />
|
||||
|
||||
<APIList title="Rules" sections={[
|
||||
"ConditionOrAction",
|
||||
"Rule",
|
||||
@@ -487,6 +495,59 @@ Delete a payee.
|
||||
|
||||
Merge one or more payees into the target payee, retaining the name of the target.
|
||||
|
||||
## Tags
|
||||
|
||||
#### Tag
|
||||
|
||||
<StructType fields={objects.tag} />
|
||||
|
||||
#### Methods
|
||||
|
||||
#### `getTags`
|
||||
|
||||
<Method name="getTags" args={[]} returns="Promise<Tag[]>" />
|
||||
|
||||
Get all tags.
|
||||
|
||||
#### `createTag`
|
||||
|
||||
<Method name="createTag" args={[{ name: 'tag', type: 'Tag' }]} returns="Promise<id>" />
|
||||
|
||||
Create a tag. Returns the `id` of the new tag.
|
||||
|
||||
#### `updateTag`
|
||||
|
||||
<Method name="updateTag" args={[{ name: 'id', type: 'id' }, { name: 'fields', type: 'object' }]} returns="Promise<null>" />
|
||||
|
||||
Update fields of a tag. `fields` can specify any field described in [`Tag`](#tag).
|
||||
|
||||
#### `deleteTag`
|
||||
|
||||
<Method name="deleteTag" args={[{ name: 'id', type: 'id' }]} returns="Promise<null>" />
|
||||
|
||||
Delete a tag.
|
||||
|
||||
#### Examples
|
||||
|
||||
```js
|
||||
// Create a tag
|
||||
await createTag({
|
||||
tag: 'groceries',
|
||||
color: '#ff0000',
|
||||
description: 'Grocery shopping expenses',
|
||||
});
|
||||
```
|
||||
|
||||
```js
|
||||
// Get all tags
|
||||
let tags = await getTags();
|
||||
```
|
||||
|
||||
```js
|
||||
// Update a tag's color
|
||||
await updateTag(id, { color: '#00ff00' });
|
||||
```
|
||||
|
||||
## Rules
|
||||
|
||||
#### ConditionOrAction
|
||||
|
||||
@@ -418,6 +418,13 @@ export const objects = {
|
||||
},
|
||||
],
|
||||
|
||||
tag: [
|
||||
{ name: 'id', type: types.id },
|
||||
{ name: 'tag', type: 'string', required: true },
|
||||
{ name: 'color', type: 'string' },
|
||||
{ name: 'description', type: 'string' },
|
||||
],
|
||||
|
||||
condition: [
|
||||
{ name: 'field', type: 'string', required: true },
|
||||
{ name: 'op', type: 'string', required: true },
|
||||
|
||||
Reference in New Issue
Block a user