Skip to content

Commit cec270e

Browse files
committed
In the table component, allow simple objects in custom_actions instead of requiring arrays of objects.
fix #1079
1 parent 26e091a commit cec270e

3 files changed

Lines changed: 27 additions & 32 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- `compress_responses` is now set to `false` by default in the configuration.
88
- When response compression is enabled, additional buffering is needed. Users reported a better experience with pages that load more progressively, reducing the time before the pages' shell is rendered.
99
- When SQLPage is deployed behind a reverse proxy, compressing responses between sqlpage and the proxy is wasteful.
10+
- In the table component, allow simple objects in custom_actions instead of requiring arrays of objects.
1011

1112
## v0.39.0 (2025-10-28)
1213
- Ability to execute sql for URL paths with another extension. If you create sitemap.xml.sql, it will be executed for example.com/sitemap.xml

examples/official-site/sqlpage/migrations/01_documentation.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,7 +1022,9 @@ This is helpful if you want a more complex logic, for instance to disable a butt
10221022
> You can leave blank spaces by including an object with only the `name` property.
10231023
10241024
The table has a column of buttons, each button defined by the `_sqlpage_actions` column at the table level, and by the `_sqlpage_actions` property at the row level.
1025+
10251026
### `custom_actions` & `_sqlpage_actions` JSON properties.
1027+
10261028
Each button is defined by the following properties:
10271029
* `name`: sets the column header and the tooltip if no tooltip is provided,
10281030
* `tooltip`: text to display when hovering over the button,
@@ -1037,14 +1039,12 @@ Each button is defined by the following properties:
10371039
"component": "table",
10381040
"edit_url": "/examples/show_variables.sql?action=edit&update_id={id}",
10391041
"delete_url": "/examples/show_variables.sql?action=delete&delete_id={id}",
1040-
"custom_actions": [
1041-
{
1042+
"custom_actions": {
10421043
"name": "history",
10431044
"tooltip": "View Standard History",
10441045
"link": "/examples/show_variables.sql?action=history&standard_id={id}",
10451046
"icon": "history"
1046-
}
1047-
]
1047+
}
10481048
},
10491049
{
10501050
"name": "CalStd",

sqlpage/templates/table.handlebars

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,13 @@
5555
{{/each}}
5656
{{#if ../edit_url}}<th class="_col_edit text-center">Edit</th>{{/if}}
5757
{{#if ../delete_url}}<th class="_col_delete text-center">Delete</th>{{/if}}
58-
{{#if ../custom_actions}}
59-
{{#each ../custom_actions}}
60-
<th class="_col_custom text-center">{{this.name}}</th>
61-
{{/each}}
62-
{{/if}}
63-
{{#if _sqlpage_actions}}
64-
{{#each _sqlpage_actions}}
65-
<th class="_col_action text-center">{{this.name}}</th>
66-
{{/each}}
67-
{{/if}}
58+
{{#each (to_array ../custom_actions)}}
59+
<th class="_col_custom text-center">{{this.name}}</th>
60+
{{/each}}
61+
62+
{{#each (to_array _sqlpage_actions)}}
63+
<th class="_col_action text-center">{{this.name}}</th>
64+
{{/each}}
6865
</tr>
6966
</thead>
7067
<tbody class="table-tbody list">{{#delay}}</tbody>{{/delay}}
@@ -105,24 +102,21 @@
105102
</a>
106103
</td>
107104
{{/if}}
108-
{{#if ../custom_actions}}
109-
{{#each ../custom_actions}}
110-
<td class="align-middle _col_{{this.name}} text-center">
111-
<a href="{{replace this.link '{id}' ../_sqlpage_id}}" class="align-middle link-secondary _col_{{this.name}}" data-action="{{this.name}}" title="{{default this.tooltip this.name}}">{{!Title property sets the tooltip text}}
112-
{{~icon_img this.icon~}}
113-
</a>
114-
</td>
115-
{{/each}}
116-
{{/if}}
117-
{{#if _sqlpage_actions}}
118-
{{#each _sqlpage_actions}}
119-
<td class="align-middle _col_{{this.name}} text-center">
120-
<a href="{{replace this.link '{id}' ../_sqlpage_id}}" class="align-middle link-secondary _col_{{this.name}}" data-action="{{this.name}}" title="{{default this.tooltip this.name}}">
121-
{{~icon_img this.icon~}}
122-
</a>
123-
</td>
124-
{{/each}}
125-
{{/if}}
105+
{{#each (to_array ../custom_actions)}}
106+
<td class="align-middle _col_{{this.name}} text-center">
107+
<a href="{{replace this.link '{id}' ../_sqlpage_id}}" class="align-middle link-secondary _col_{{this.name}}" data-action="{{this.name}}" title="{{default this.tooltip this.name}}">{{!Title property sets the tooltip text}}
108+
{{~icon_img this.icon~}}
109+
</a>
110+
</td>
111+
{{/each}}
112+
113+
{{#each (to_array _sqlpage_actions)}}
114+
<td class="align-middle _col_{{this.name}} text-center">
115+
<a href="{{replace this.link '{id}' ../_sqlpage_id}}" class="align-middle link-secondary _col_{{this.name}}" data-action="{{this.name}}" title="{{default this.tooltip this.name}}">
116+
{{~icon_img this.icon~}}
117+
</a>
118+
</td>
119+
{{/each}}
126120
</tr>
127121
{{!~
128122
After this <tr> has been rendered, if this was a footer, we need to reopen a new <tbody>

0 commit comments

Comments
 (0)