Skip to content

Commit df8cd48

Browse files
committed
Fix bug in list component
Fix a bug in the [link](https://sql-page.com/component.sql?component=link) component where the properties `view_link`, `edit_link`, and `delete_link` had become incompatible with the main `link` property. fixes #759
1 parent be2a976 commit df8cd48

File tree

3 files changed

+28
-31
lines changed

3 files changed

+28
-31
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ This is a bugfix release.
66

77
- Fix a bug where the form component would not display the right checked state in radio buttons and checkboxes.
88
- https://github.com/sqlpage/SQLPage/issues/751
9+
- Fix a bug in the [link](https://sql-page.com/component.sql?component=link) component where the properties `view_link`, `edit_link`, and `delete_link` had become incompatible with the main `link` property.
910

1011
## 0.32.0 (2024-12-29)
1112

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,11 @@ This example illustrates creating a nice list where each item has a title, a des
6969
{"title":"SQL Maps", "image_url": "https://upload.wikimedia.org/wikipedia/commons/1/15/Vatican_City_map_EN.png", "description_md":"Show database contents on a map using the *map* component. Works well with *PostGIS* and *SpatiaLite*.", "link": "?component=map"}
7070
]')),
7171
('list', 'A beautiful list with bells and whistles.',
72-
json('[{"component":"list", "title":"Top SQLPage features" }, '||
73-
'{"title":"Authentication", "link":"?component=authentication", "description": "Authenticate users with a login form or HTTP basic authentication", "color": "red", "icon":"lock", "active": true }, '||
74-
'{"title":"Editing data", "description": "SQLPage makes it easy to UPDATE, INSERT and DELETE data in your database tables", "color": "blue", "icon":"database", "edit_link": "?component=form", "delete_link": "?component=alert" }]'));
72+
json('[{"component":"list", "title":"Top SQLPage features", "compact": true },
73+
{"title":"Authentication", "link":"?component=authentication", "description": "Authenticate users with a login form or HTTP basic authentication", "color": "red", "icon":"lock", "active": true, "view_link": "?component=authentication#view" },
74+
{"title":"Editing data", "link":"?component=form", "description": "SQLPage makes it easy to UPDATE, INSERT and DELETE data in your database tables", "color": "blue", "icon":"database", "edit_link": "?component=form#edit", "delete_link": "?component=form#delete" },
75+
{"title":"API", "link":"?component=json", "description": "Generate a REST API from a single SQL query to connect with other applications and services", "color": "green", "icon":"plug-connected", "edit_link": "?component=json#edit", "delete_link": "?component=json#delete" }
76+
]'));
7577

7678
INSERT INTO component(name, icon, description) VALUES
7779
('datagrid', 'grid-dots', 'Display small pieces of information in a clear and readable way. Each item has a name and is associated with a value.');

sqlpage/templates/list.handlebars

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,11 @@
66
{{/if}}
77
<div class="list-group list-group-flush list-group-hoverable">
88
{{#each_row}}
9-
{{#if link}}
10-
<a href="{{link}}" {{#if id}}id="{{id}}"{{/if}}
11-
class="list-group-item list-group-item-action {{#if active}}active{{/if}} {{#if ../compact}}py-1{{/if}} {{class}} text-decoration-none link-body-emphasis">
12-
{{else}}
13-
<div {{#if id}}id="{{id}}"{{/if}}
14-
class="list-group-item list-group-item-action {{#if active}}active{{/if}} {{#if ../compact}}py-1{{/if}} {{class}}">
15-
{{/if}}
16-
<div class="row align-items-center">
9+
<div {{#if id}}id="{{id}}"{{/if}}
10+
class="list-group-item list-group-item-action p-0 {{#if active}}active{{/if}} {{class}}">
11+
<div class="row align-items-center m-0">
12+
<a {{#if link}} href="{{link}}" {{/if}}
13+
class="col row align-items-center text-decoration-none link-body-emphasis m-0 {{#if ../compact}}p-1{{else}}p-3{{/if}}">
1714
{{#if color}}
1815
<div class="col-auto"><span class="badge bg-{{color}}"></span></div>
1916
{{/if}}
@@ -37,29 +34,26 @@
3734
</div>
3835
</div>
3936

40-
{{#if view_link}}
41-
<a href="{{view_link}}" class="link-secondary col-auto" title="View">
42-
{{~icon_img 'eye'~}}
43-
</a>
44-
{{/if}}
37+
</a>
38+
{{#if view_link}}
39+
<a href="{{view_link}}" class="link-secondary col-auto" title="View">
40+
{{~icon_img 'eye'~}}
41+
</a>
42+
{{/if}}
4543

46-
{{#if delete_link}}
47-
<a href="{{delete_link}}" class="link-secondary col-auto" title="Delete">
48-
{{~icon_img 'trash'~}}
49-
</a>
50-
{{/if}}
44+
{{#if delete_link}}
45+
<a href="{{delete_link}}" class="link-secondary col-auto" title="Delete">
46+
{{~icon_img 'trash'~}}
47+
</a>
48+
{{/if}}
5149

52-
{{#if edit_link}}
53-
<a href="{{edit_link}}" class="link-secondary col-auto" title="Edit">
54-
{{~icon_img 'edit'~}}
55-
</a>
56-
{{/if}}
57-
</div>
58-
{{#if link}}
59-
</a>
60-
{{else}}
50+
{{#if edit_link}}
51+
<a href="{{edit_link}}" class="link-secondary col-auto" title="Edit">
52+
{{~icon_img 'edit'~}}
53+
</a>
54+
{{/if}}
6155
</div>
62-
{{/if}}
56+
</div>
6357
{{/each_row}}
6458
{{#if (eq @row_index 0)}}
6559
<a href="{{default empty_link '#'}}" class="list-group-item list-group-item-action">

0 commit comments

Comments
 (0)