Skip to content
This repository was archived by the owner on Jul 28, 2025. It is now read-only.

Commit 7cf3d16

Browse files
committed
Merge branch 'feature/options_feedback'
2 parents 6ffdc66 + be46261 commit 7cf3d16

39 files changed

+1656
-1519
lines changed

docs/docs/features/Formulas.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,38 @@ The code can be written in the column settings. The generated values can be adde
1414

1515
### Exposed Variables
1616
Common variables that you can use in your formula are:
17+
1718
- `db` : the database object with predefined functions that can be used in the formula
1819
- `config` : the table's config information
1920

2021
To use an exposed variable, use the `${}` syntax. For example, to get a value of the `config`, you can use `${config.pagination_size}`.
22+
2123
#### Column Formula
2224
If you are using a column formula, you can also use the following variables:
25+
2326
- `row` : the row object
27+
2428
#### Footer Formula
2529
In case you are using a footer formula, you can also use the following variables:
30+
2631
- `values` : An Array of cell values in the column
2732

33+
#### Options Formula
34+
The options formula is a special case. It is used to generate the options for a column with the type `select` or `tag`. The formula must return an array of objects with the following structure:
35+
36+
```javascript
37+
{
38+
value: "value",
39+
label: "label"
40+
color: "color" // HSL, RGB, HEX, or color name but with string representation
41+
}
42+
```
43+
Due the nature of the formula, the variables are called directly instead of using the `${}` syntax. For example, to get a value of the `db`, you can use `db.js.myOptionsFormula()`.
44+
45+
You can also use the following variables:
46+
- `column` : Object with the column information
47+
48+
2849
### Exposed Functions
2950

3051
The root object `db` has the following functions:
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* Generate a list of options in function of the tags of Obsidian
3+
*
4+
* Formula: ${db.js.tagsAsOptions(db)}
5+
*/
6+
function tagsAsOptions(db) {
7+
options = [];
8+
tagArray = app.metadataCache.getTags(); // Record<string, number>
9+
Object.keys(tagArray).forEach(tag => {
10+
options.push({
11+
value: tag,
12+
label: tag.slice(1),
13+
color: db.colors.randomColor()
14+
})
15+
});
16+
return options;
17+
}
18+
19+
module.exports = tagsAsOptions

0 commit comments

Comments
 (0)