diff --git a/flask_bootstrap/templates/base/table.html b/flask_bootstrap/templates/base/table.html index bf561a76..b5818f85 100644 --- a/flask_bootstrap/templates/base/table.html +++ b/flask_bootstrap/templates/base/table.html @@ -39,6 +39,7 @@ model=None, show_actions=False, actions_title='Actions', + actions_first=False, custom_actions=None, view_url=None, edit_url=None, @@ -57,9 +58,11 @@ {% endif %} - {% for title in titles %} - {{ title[1] }} - {% endfor %} + {% if not actions_first %} + {% for title in titles %} + {{ title[1] }} + {% endfor %} + {% endif %} {% if show_actions %} {{ actions_title }} {% if new_url %} @@ -75,38 +78,48 @@ {% endif %} {% endif %} + {% if actions_first %} + {% for title in titles %} + {{ title[1] }} + {% endfor %} + {% endif %} {% for row in data %} - {% for title in titles %} - {% set key = title[0] %} - {% set value = row[key] %} - {%- if key == primary_key -%} - - {%- else -%} - - {%- endif -%} - {%- if value is string -%} - {%- if safe_columns and key in safe_columns -%} - {{ value|safe }} + {% set show_main_cols %} + {% for title in titles %} + {% set key = title[0] %} + {% set value = row[key] %} + {%- if key == primary_key -%} + {%- else -%} - {%- if urlize_columns and key in urlize_columns -%} - {{ value|urlize }} + + {%- endif -%} + {%- if value is string -%} + {%- if safe_columns and key in safe_columns -%} + {{ value|safe }} {%- else -%} - {{ value }} + {%- if urlize_columns and key in urlize_columns -%} + {{ value|urlize }} + {%- else -%} + {{ value }} + {%- endif -%} {%- endif -%} + {%- else -%} + {{ value }} {%- endif -%} - {%- else -%} - {{ value }} - {%- endif -%} - {%- if key == primary_key -%} - - {%- else -%} - - {%- endif -%} - {% endfor %} + {%- if key == primary_key -%} + + {%- else -%} + + {%- endif -%} + {% endfor %} + {% endset %} + {% if not actions_first %} + {{show_main_cols}} + {% endif %} {% if show_actions %} {% if custom_actions %} @@ -161,6 +174,9 @@ {% endif %} {% endif %} + {% if actions_first %} + {{show_main_cols}} + {% endif %} {% endfor %}