Mercurial > hg > ltpdarepo
view src/ltpdarepo/templates/query.html @ 108:f075650d3e1d
Disable "save query" button in timeseries search view.
author | Daniele Nicolodi <daniele@grinta.net> |
---|---|
date | Tue, 23 Aug 2011 19:11:25 +0200 |
parents | 22b950fee548 |
children | 5af343faf647 |
line wrap: on
line source
{% extends "objs.html" %} {% block head %} <link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='dropdown.css') }}" /> <script type="text/javascript" src="{{ url_for('static', filename='jquery.js') }}"></script> <script type="text/javascript" src="{{ url_for('static', filename='dropdown.js') }}"></script> <script type="text/javascript" src="{{ url_for('static', filename='querywidget.js') }}"></script> <script type="text/javascript"> var criteria = {{ indexes|tojson|safe }}; $(function () { $.dropdown.replace($("select")); $("#save").live('click', function () { var query = $(".query form").serialize(); if (! query) return false; var form = $(document.createElement('form')).attr({ 'action': '{{ url_for('manage.queries.create') }}', 'method': 'POST' }); form.append($(document.createElement('input')).attr({ 'type': 'hidden', 'name': 'query', 'value': query })); form.append($(document.createElement('input')).attr({ 'type': 'hidden', 'name': 'db', 'value': '{{ database.id }}' })); $("body").append(form); form.submit(); form.remove(); return false; }); }); </script> {% endblock %} {% block above %} <div class="query wrapper"> <form method="GET" action=""> {% block extra %}{% endblock %} <div id="criteria" class="wrapper"> {% for field, op, value, error in query %} {% set cssclass = '' %} {% if error %}{% set cssclass = cssclass + 'error' %}{% endif %} <div class="criteria wrapper"> <span class="querywidget field">{{ indexes[field]['name'] }}</span> <input type="hidden" name="field" value="{{ field }}" /> <select class="querywidget operator" name="operator"> {% for name in indexes[field]['operators'] %} {% if op == name %} <option value="{{ name }}" selected="selected">{{ name }}</option> {% else %} <option value="{{ name }}">{{ name }}</option> {% endif %} {% endfor %} </select> {% if indexes[field]['type'] == 'enum' %} <select class="querywidget value" name="value"> {% for name in indexes[field]['values'] %} {% if value == name %} <option value="{{ name }}" selected="selected">{{ name }}</option> {% else %} <option value="{{ name }}">{{ name }}</option> {% endif %} {% endfor %} </select> {% else %} <input class="querywidget value {{ cssclass }}" autocomplete="off" type="text" name="value" value="{{ value }}" /> {% endif %} <input class="querywidget remove" type="button" name="remove" value="×" /> </div> {% endfor %} </div> <select id="add"> <option value="" selected="selected">Add criteria…</option> {% for key, index in indexes.iteritems() %} <option value="{{ key }}">{{ index['name'] }}</option> {% endfor %} </select> <input type="submit" value="search" /> {% if 'query' in request.endpoint and 'admin' in g.identity.roles %} <input id="save" type="submit" name="save" value="save query" /> {% endif %} </form> </div> {% endblock %}