|
1 | 1 | {% from 'bootstrap/utils.html' import render_icon, arg_url_for %} |
2 | 2 |
|
3 | 3 | {% macro deprecate_placeholder_url() %} |
4 | | - {{ warn('Passing an URL with primary key palceholder for view_url/edit_url/delete_url/custom_actions is deprecated. You will need to pass an fixed URL or an URL tuple to URL arguments, see the docs for more details (https://bootstrap-flask.readthedocs.io/en/stable/macros.html#render-table). The support to URL string will be removed in version 2.0.') }} |
| 4 | + {{ warn('Passing an URL with primary key palceholder for view_url/edit_url/delete_url/custom_actions is deprecated. You will need to pass an fixed URL or an URL tuple to URL arguments, see the docs for more details (https://bootstrap-flask.readthedocs.io/en/stable/macros.html#render-table). The support to URL string will be removed in version 2.0.', stacklevel=2) }} |
5 | 5 | {% endmacro %} |
6 | 6 |
|
7 | 7 | {% macro build_url(endpoint, model, pk, url_tuples) %} |
|
94 | 94 | {% for (action_name, action_icon, action_url) in custom_actions %} |
95 | 95 | {% if ':primary_key' in action_url | join('') %} |
96 | 96 | {% set action_pk_placeholder = ':primary_key' %} |
97 | | - {% set _ = deprecate_placeholder_url() %} |
98 | 97 | {% endif %} |
99 | 98 | <a class="action-icon text-decoration-none" |
100 | 99 | {% if action_url is string %} |
| 100 | + {% if ':' in action_url %}{% set _ = deprecate_placeholder_url() %}{% endif %} |
101 | 101 | href="{{ action_url | replace(action_pk_placeholder, row[primary_key]) }}" |
102 | 102 | {% else %} |
103 | 103 | href="{{ build_url(action_url[0], model, row[primary_key], action_url[1]) | trim }}" |
|
108 | 108 | {% if view_url %} |
109 | 109 | {% if ':primary_key' in view_url | join('') %} |
110 | 110 | {% set action_pk_placeholder = ':primary_key' %} |
111 | | - {% set _ = deprecate_placeholder_url() %} |
112 | 111 | {% endif %} |
113 | 112 | <a class="action-icon text-decoration-none" |
114 | 113 | {% if view_url is string %} |
| 114 | + {% if ':' in view_url %}{% set _ = deprecate_placeholder_url() %}{% endif %} |
115 | 115 | href="{{ view_url | replace(action_pk_placeholder, row[primary_key]) }}" |
116 | 116 | {% else %} |
117 | 117 | href="{{ build_url(view_url[0], model, row[primary_key], view_url[1]) | trim }}" |
|
123 | 123 | {% if edit_url -%} |
124 | 124 | {% if ':primary_key' in edit_url | join('') %} |
125 | 125 | {% set action_pk_placeholder = ':primary_key' %} |
126 | | - {% set w = deprecate_placeholder_url() %} |
127 | 126 | {% endif %} |
128 | 127 | <a class="action-icon text-decoration-none" |
129 | 128 | {% if edit_url is string %} |
| 129 | + {% if ':' in edit_url %}{% set _ = deprecate_placeholder_url() %}{% endif %} |
130 | 130 | href="{{ edit_url | replace(action_pk_placeholder, row[primary_key]) }}" |
131 | 131 | {% else %} |
132 | 132 | href="{{ build_url(edit_url[0], model, row[primary_key], edit_url[1]) | trim }}" |
|
138 | 138 | {% if delete_url %} |
139 | 139 | {% if ':primary_key' in delete_url | join('') %} |
140 | 140 | {% set action_pk_placeholder = ':primary_key' %} |
141 | | - {% set _ = deprecate_placeholder_url() %} |
142 | 141 | {% endif %} |
143 | 142 | <form style="display:inline" |
144 | 143 | {% if delete_url is string %} |
| 144 | + {% if ':' in delete_url %}{% set _ = deprecate_placeholder_url() %}{% endif %} |
145 | 145 | action="{{ delete_url | replace(action_pk_placeholder, row[primary_key]) }}" |
146 | 146 | {% else %} |
147 | 147 | action="{{ build_url(delete_url[0], model, row[primary_key], delete_url[1]) | trim }}" |
|
0 commit comments