diff options
| author | Alexis Metaireau <alexis@notmyidea.org> | 2017-07-07 00:06:56 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-07-07 00:06:56 +0200 |
| commit | 3a4282fd75e3b3317b2b08b4aa2e6ac154310e73 (patch) | |
| tree | 9470c907ba1f884246af87d26d55c3aaac6d6dc5 /ihatemoney/templates/forms.html | |
| parent | 0e374cd5e0ef5a9be67084365f91de2ab84f636c (diff) | |
| download | ihatemoney-mirror-3a4282fd75e3b3317b2b08b4aa2e6ac154310e73.zip ihatemoney-mirror-3a4282fd75e3b3317b2b08b4aa2e6ac154310e73.tar.gz ihatemoney-mirror-3a4282fd75e3b3317b2b08b4aa2e6ac154310e73.tar.bz2 | |
Absolute imports & some other improvements (#243)
* Use absolute imports and rename package to ihatemoney
* Add a ihatemoney command
* Factorize application creation logic
* Refactor the tests
* Update the wsgi.py module with the new create_app() function
* Fix some styling thanks to Flake8.
* Automate Flake8 check in the CI.
Diffstat (limited to 'ihatemoney/templates/forms.html')
| -rw-r--r-- | ihatemoney/templates/forms.html | 168 |
1 files changed, 168 insertions, 0 deletions
diff --git a/ihatemoney/templates/forms.html b/ihatemoney/templates/forms.html new file mode 100644 index 0000000..ffdd165 --- /dev/null +++ b/ihatemoney/templates/forms.html @@ -0,0 +1,168 @@ +{% macro input(field, multiple=False, class='form-control', inline=False) -%} + <div class="form-group{% if inline %} row{% endif %}"> + {% if field.type != "SubmitField" %} + {% if inline %} + {{ field.label(class="col-3") }} + {% else %} + {{ field.label() }} + {% endif %} + {% endif %} + <div class="controls{% if inline %} col-9{% endif %}"> + {% if multiple == True %} + {{ field(multiple=True, class=class) }} + {% else %} + {{ field(class=class) | safe }} + {% endif %} + {% if field.description %} + <p class="help-inline">{{ field.description }}</p> + {% endif %} + </div> + </div> +{% endmacro %} + +{% macro submit(field, cancel=False, home=False) -%} + <div class="actions"> + <button type="submit" class="btn btn-primary">{{ field.name }}</button> + {% if home %} + <a href="{{ url_for(".remind_password") }}">{{ _("Can't remember the password?") }}</a> + {% endif %} + {% if cancel %} + <button type="reset" class="btn">{{ _("Cancel") }}</button> + {% endif %} + </div> +{% endmacro %} + +{% macro authenticate(form, home=False) %} + + {% include "display_errors.html" %} + + {{ form.hidden_tag() }} + {{ input(form.id) }} + {{ input(form.password) }} + {% if not home %} + {{ submit(form.submit, home=True) }} + {% endif %} + +{% endmacro %} + +{% macro admin(form) %} + + {% include "display_errors.html" %} + + {{ form.hidden_tag() }} + {{ input(form.admin_password) }} + {{ submit(form.submit) }} + +{% endmacro %} + +{% macro create_project(form, home=False) %} + + {% include "display_errors.html" %} + {{ form.hidden_tag() }} + {% if not home %} + {{ input(form.id) }} + {% endif %} + {{ input(form.name) }} + {{ input(form.password) }} + {{ input(form.contact_email) }} + {% if not home %} + {{ submit(form.submit, home=True) }} + {% endif %} + +{% endmacro %} + +{% macro edit_project(form) %} + + {% include "display_errors.html" %} + {{ form.hidden_tag() }} + {{ input(form.name) }} + {{ input(form.password) }} + {{ input(form.contact_email) }} + <div class="actions"> + <button class="btn btn-primary">{{ _("Edit the project") }}</button> + <a id="delete-project" style="color:red; margin-left:10px; cursor:pointer; ">{{ _("delete") }}</a> + </div> + +{% endmacro %} + +{% macro add_bill(form, edit=False, title=True) %} + + <fieldset> + {% if title %}<legend>{% if edit %}{{ _("Edit this bill") }} {% else %}{{ _("Add a bill") }} {% endif %}</legend>{% endif %} + {% include "display_errors.html" %} + {{ form.hidden_tag() }} + {{ input(form.date, class="form-control datepicker", inline=True) }} + {{ input(form.what, inline=True) }} + {{ input(form.payer, inline=True, class="form-control custom-select") }} + {{ input(form.amount, inline=True) }} + + <div class="form-group row"> + <label class="col-3" for="payed_for">{{ _("For whom?") }}</label> + <div class="controls col-9"> + <ul id="payed_for" class="inputs-list"> + <p><a href="#" id="selectall" onclick="selectall()">{{ _("Select all") }}</a> | <a href="#" id="selectnone" onclick="selectnone()">{{_("Select none")}}</a></p> + {% for key, value, checked in form.payed_for.iter_choices() %} + <p class="form-check"><label for="payed_for-{{key}}" class="form-check-label"><input name="payed_for" type="checkbox" {% if checked %}checked{% endif %} class="form-check-input" value="{{key}}" id="payed_for-{{key}}"/><span>{{value}}</span></label></p> + {% endfor %} + </ul> + </div> + </div> + </fieldset> + <div class="actions"> + {{ form.submit(class="btn btn-primary") }} + {% if not edit %} {{ form.submit2(class="btn") }}{% endif %} + </div> + +{% endmacro %} + +{% macro add_member(form) %} +{{ form.hidden_tag() }} + <div class="input-group"> + <label class="sr-only" for="name">_("Type user name here")</label> + {{ form.name(placeholder=_("Type user name here"), class="form-control") }} + <button class=" input-group-addon btn">{{ _("Add") }}</button> + </div> +{% endmacro %} + +{% macro edit_member(form, title=True) %} + <fieldset> + {% if title %}<legend>{{ _("Edit this member") }}</legend>{% endif %} + {% include "display_errors.html" %} + {{ form.hidden_tag() }} + {{ input(form.name) }} + {{ input(form.weight) }} + </fieldset> + <div class="actions"> + {{ form.submit(class="btn btn-primary") }} + </div> +{% endmacro %} + + +{% macro invites(form) %} + {{ form.hidden_tag() }} + {{ input(form.emails) }} + <div class="actions"> + <button class="btn btn-primary">{{ _("Send the invitations") }}</button> + <a href="{{ url_for(".list_bills") }}">{{ _("No, thanks") }}</a> + </div> +{% endmacro %} + +{% macro export_project(form) %} + <fieldset> + {{ form.hidden_tag() }} + {{ input(form.export_type) }} + {{ input(form.export_format) }} + </fieldset> + <div class="actions"> + <button class="btn btn-primary">{{ _("Download") }}</button> + </div> +{% endmacro %} + +{% macro remind_password(form) %} + + {% include "display_errors.html" %} + {{ form.hidden_tag() }} + {{ input(form.id) }} + {{ submit(form.submit) }} + +{% endmacro %} |
