Skip to content

Commit ea3abcb

Browse files
committed
Update widget related documentation
1 parent fa26d2e commit ea3abcb

File tree

2 files changed

+39
-12
lines changed

2 files changed

+39
-12
lines changed

docs/building_admin_modules/widgets.md

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@ $widgets = service('widgets');
2525
$users = new UserModel();
2626
$statsItem = new StatsItem([
2727
'bgColor' => 'bg-blue',
28-
'title' => 'Users',
29-
'value' => $users->countAll(),
30-
'url' => ADMIN_AREA . '/users',
31-
'faIcon' => 'fa fa-user',
28+
'title' => 'Users',
29+
'value' => $users->countAll(),
30+
'id' => 'countAllUsers643',
31+
'url' => ADMIN_AREA . '/users',
32+
'faIcon' => 'fa fa-user',
3233
]);
3334
$widgets->widget("stats")->collection('stats')->addItem($statsItem);
3435
```
@@ -64,7 +65,13 @@ The title of the widget displayed at the top left
6465

6566
**value**
6667

67-
The value of the widget displayed under the title: typically the total number of records
68+
The value of the widget displayed under the title: typically the total number of records.
69+
70+
However, more elaborate data can be passed as a string, like an html table with tabulated data. See how that is done in `src/Users/Module.php` with a private method `buildTableUsersByGroup()`. **value** can also be passed to the stats item by a standard `addValue()` method, see the same file for an example.
71+
72+
**id**
73+
74+
A uniwue widget ID throughout application (make it descriptive and add extra symbols to make sure the uniqueness).
6875

6976
**url**
7077

@@ -74,26 +81,25 @@ The address that displays the list of objects on your module. It will be associa
7481

7582
The FontAwesome icon
7683

77-
78-
7984
## Configuration
8085

8186
All settings are available in the `Bonfire\Widgets\Config\Stats` class, or in the admin settings area.
8287

83-
In the administration settings area, you can choose to:
88+
In the administration settings area, you can also choose to:
8489
- Display the "View Detail" link
8590

8691
---
8792

88-
# Charts widget
93+
## Charts widget
8994

9095
Adding a new chart widget is done in the `initAdmin` method of your `Module.php` file, similar to adding a menu:
9196

9297
```php
9398
$statsItem = new ChartsItem([
94-
'title' => 'User classification by group',
95-
'type' => 'line',
96-
'cssClass' => 'col-6',
99+
'title' => 'User classification by group',
100+
'type' => 'line',
101+
'id' => 'usersByGroupLine123',
102+
'cssClass' => 'col-6',
97103
]);
98104
$statsItem->addDataset('auth_groups_users', 'group', 'user_id');
99105
$widgets->widget('charts')->collection('charts')->addItem($statsItem);
@@ -115,6 +121,10 @@ The available options are:
115121
- polarArea
116122
```
117123

124+
**id**
125+
126+
A uniwue widget ID throughout application (make it descriptive and add extra symbols to make sure the uniqueness).
127+
118128
**cssClass**
119129

120130
Set the width of the chart.
@@ -167,6 +177,7 @@ Each type of widget has its own specific settings.
167177
You can set the default values in the `Bonfire\Widgets\Config\LineChart` Class
168178

169179
In the administration settings area, you can choose to:
180+
170181
- Display the title
171182
- View the legend
172183
- Choose the location of the legend
@@ -185,6 +196,7 @@ Advanced settings:
185196
You can set the default values in the `Bonfire\Widgets\Config\BarChart` Class
186197

187198
In the administration settings area, you can choose to:
199+
188200
- Display the title
189201
- View the legend
190202
- Choose the location of the legend
@@ -198,6 +210,7 @@ In the administration settings area, you can choose to:
198210
You can set the default values in the `Bonfire\Widgets\Config\DoughnutChart` Class
199211

200212
In the administration settings area, you can choose to:
213+
201214
- Display the title
202215
- View the legend
203216
- Choose the location of the legend
@@ -211,6 +224,7 @@ In the administration settings area, you can choose to:
211224
You can set the default values in the `Bonfire\Widgets\Config\PieChart` Class
212225

213226
In the administration settings area, you can choose to:
227+
214228
- Display the title
215229
- View the legend
216230
- Choose the location of the legend
@@ -224,6 +238,7 @@ In the administration settings area, you can choose to:
224238
You can set the default values in the `Bonfire\Widgets\Config\PolarAreaChart` Class
225239

226240
In the administration settings area, you can choose to:
241+
227242
- Display the title
228243
- View the legend
229244
- Choose the location of the legend

docs/intro/changelog.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@ This holds the change history for Bonfire as we lead up to a 1.0 release. It's n
44

55
**IMPORTANT!** *Breaking changes* are marked with words `breaking change` in parentheses right after the date.
66

7+
## 18 March 2025 (breaking change)
8+
9+
The way widgets are enabled has changed in the database, so if you had widgets enabled before, they will
10+
all be disabled. To clear the database of the orphaned data about enabled widgets run this in your DB:
11+
12+
```sql
13+
DELETE FROM `settings`
14+
WHERE `class` = 'Bonfire\Widgets\Config\Stats' AND `key` LIKE 'Stats_%';
15+
DELETE FROM `settings`
16+
WHERE `class` = 'Bonfire\Widgets\Config\Stats' AND `key` LIKE 'Charts_%';
17+
```
18+
719
## 26 February 2025 (breaking change)
820

921
Finished implementation of **<x-button\>** component in the Admin theme. Users need to update the

0 commit comments

Comments
 (0)