Mercurial > farol > farol
diff farol/templates/base.j2 @ 102:65341d05a8f8
Spawn a Modal when loading a doc, and another one is already loaded
author | Benoît Allard <benoit.allard@greenbone.net> |
---|---|
date | Tue, 14 Oct 2014 10:25:43 +0200 |
parents | 641a2b589613 |
children | ce64f90e58c4 |
line wrap: on
line diff
--- a/farol/templates/base.j2 Tue Oct 14 10:23:08 2014 +0200 +++ b/farol/templates/base.j2 Tue Oct 14 10:25:43 2014 +0200 @@ -23,6 +23,8 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -#} +{% from "macros.j2" import modal, POST_button -%} + <!doctype html> <html lang="en"> @@ -96,10 +98,20 @@ <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown">Cache <span class="caret"></span></a> <ul class="dropdown-menu" role="menu"> - <li role="presentation"{{ ' class="disabled"' if not has_current }}><a role="menuitem" tabindex="-1" href="{{ url_for('cache.save') }}">Save current</a> + <li role="presentation"{{ ' class="disabled"' if not has_current }}><a role="menuitem" tabindex="-1" href="{{ url_for('cache.save') }}">Save {{ current_id }}</a> </li> <li role="presentation" class="divider"></li> - {% for element in cache | sort %}<li role="presentation"><a href="{{ url_for('cache.load', element=element)}}">{{ element }}</a></li>{% endfor %} + {% for element in cache | sort %} + <li role="presentation"> + {% if has_current %} + <a href="#{{element}}_modal" data-toggle="modal">Load {{ element }}</a> + {% else %} + {% call(selector) POST_button(url_for('cache.load', element=element), out=True) %} + <a role="menuitem" href="#" onclick="{{ selector }}.submit();return false;">Load {{ element }}</a> + {% endcall %} + {% endif %} + </li> + {% endfor %} </ul> </li> {% endif %} @@ -107,6 +119,19 @@ </div>{# /.navbar-collapse #} </div>{# /.container-fluid #} </nav> + {% if has_current %} + {% for element in cache %} + {# Put the modals for the load action here #} + {% call modal(element + '_modal', 'Load %s from cache' % element) %} + <p>You asked to load <strong>{{ element }}</strong>, your changes to <strong>{{ current_id }}</strong> will be lost.</p> + <p>Do you want to save <strong>{{ current_id }}</strong> first ?</p> + </div> + <div class="modal-footer"> + <a href="{{ url_for('cache.save') }}" class="btn btn-success">Save {{ current_id }}</a> + {{ POST_button(url_for('cache.load', element=element), text="Load " + element, style="btn-danger") }} + {% endcall %} + {% endfor %} + {% endif %} <div class="main container"> {% with messages = get_flashed_messages(with_categories=True) %} {% if messages %}