Add double click to submit, addtional form buttons

Rename form template variable 'form_class' to 'form_css_classes'

Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
Roberto Rosario
2019-04-24 22:17:57 -04:00
parent 575b2bc61c
commit fcfadb0caa
5 changed files with 42 additions and 10 deletions
+5
View File
@@ -141,6 +141,11 @@
* Remove the full name from the user list. * Remove the full name from the user list.
* Add the first name and last name to the user list. * Add the first name and last name to the user list.
* Add file metadata app. * Add file metadata app.
* Add support for submitting forms by pressing the
Enter key or by double clicking.
* Rename form template 'form_class' to 'form_css_classes'.
* Add support for adding form button aside from the
default submit and cancel.
3.1.11 (2019-04-XX) 3.1.11 (2019-04-XX)
=================== ===================
+5
View File
@@ -173,6 +173,11 @@ Other changes
* Remove the full name from the user list. * Remove the full name from the user list.
* Add the first name and last name to the user list. * Add the first name and last name to the user list.
* Add file metadata app. * Add file metadata app.
* Add support for submitting forms by pressing the
Enter key or by double clicking.
* Rename form template 'form_class' to 'form_css_classes'.
* Add support for adding form button aside from the
default submit and cancel.
Removals Removals
-------- --------
@@ -156,6 +156,7 @@ class MayanApp {
this.setupAJAXSpinner(); this.setupAJAXSpinner();
this.setupAutoSubmit(); this.setupAutoSubmit();
this.setupFormHotkeys();
this.setupFullHeightResizing(); this.setupFullHeightResizing();
this.setupItemsSelector(); this.setupItemsSelector();
this.setupNavbarCollapse(); this.setupNavbarCollapse();
@@ -195,6 +196,21 @@ class MayanApp {
}); });
} }
setupFormHotkeys () {
$('body').on('keypress', '.form-hotkey-enter', function (e) {
if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) {
$(this).find('.btn-hotkey-default').click();
return false;
} else {
return true;
}
});
$('body').on('dblclick', '.form-hotkey-double-click', function (e) {
$(this).find('.btn-hotkey-default').click();
return false;
});
}
setupFullHeightResizing () { setupFullHeightResizing () {
var self = this; var self = this;
@@ -10,9 +10,9 @@
<div class="well"> <div class="well">
{% if form.is_multipart %} {% if form.is_multipart %}
<form action="{{ form_action }}" class="{{ form_class|default:'' }}" enctype="multipart/form-data" method="{{ submit_method|default:'post' }}" name="{{ form.prefix }}" target="{{ submit_target|default:'_self' }}"> <form action="{{ form_action }}" class="{{ form_css_classes|default:'' }}" enctype="multipart/form-data" method="{{ submit_method|default:'post' }}" name="{{ form.prefix }}" target="{{ submit_target|default:'_self' }}">
{% else %} {% else %}
<form action="{{ form_action }}" class="{{ form_class|default:'' }}" method="{{ submit_method|default:'post' }}" name="{{ form.prefix }}" target="{{ submit_target|default:'_self' }}"> <form action="{{ form_action }}" class="{{ form_css_classes|default:'' }}" method="{{ submit_method|default:'post' }}" name="{{ form.prefix }}" target="{{ submit_target|default:'_self' }}">
{% endif %} {% endif %}
{{ wizard.management_form }} {{ wizard.management_form }}
@@ -58,11 +58,7 @@
{% include 'appearance/generic_form_instance.html' %} {% include 'appearance/generic_form_instance.html' %}
{% empty %} {% empty %}
<tr><td class="text-center" colspan=99> <tr><td class="text-center" colspan=99>
{% if form_empty_label %}{{ form_empty_label }}{% else %}
{% include 'appearance/no_results.html' %} {% include 'appearance/no_results.html' %}
{% endif %}
</td></tr> </td></tr>
{% endfor %} {% endfor %}
@@ -79,7 +75,7 @@
{% if not form.management_form or wizard.management_form or form.forms %} {% if not form.management_form or wizard.management_form or form.forms %}
{# Is a normal form, a wizard form, or a formset with at least one form #} {# Is a normal form, a wizard form, or a formset with at least one form #}
<div class="form-group"> <div class="form-group">
<button class="btn btn-primary" name="{% if form.prefix %}{{ form.prefix }}-submit{% else %}submit{% endif %}" type="submit"> <button class="btn btn-primary btn-hotkey-default" name="{% if form.prefix %}{{ form.prefix }}-submit{% else %}submit{% endif %}" type="submit">
{% if submit_icon_class %} {% if submit_icon_class %}
{{ submit_icon_class.render }} {{ submit_icon_class.render }}
{% elif submit_icon %} {% elif submit_icon %}
@@ -94,6 +90,15 @@
<i class="fa fa-times"></i> {% if cancel_label %}{{ cancel_label }}{% else %}{% trans 'Cancel' %}{% endif %} <i class="fa fa-times"></i> {% if cancel_label %}{{ cancel_label }}{% else %}{% trans 'Cancel' %}{% endif %}
</a> </a>
{% endif %} {% endif %}
{% for button in extra_buttons %}
<button class="btn btn-default" name="{% if form.prefix %}{{ form.prefix }}-{{ button.name }}{% else %}{{ button.name }}{% endif %}" type="submit">
{% if button.icon_class %}
{{ button.icon_class.render }}
{% endif %}
{% if button.label %}{{ button.label }}{% else %}{% if object %}{% trans 'Save' %}{% else %}{% trans 'Submit' %}{% endif %}{% endif %}
</button>
{% endfor %}
</div> </div>
{% endif %} {% endif %}
{% endif %} {% endif %}
@@ -2,9 +2,9 @@
{% load static %} {% load static %}
<div class="well"> <div class="well">
{% if is_multipart %} {% if is_multipart %}
<form action="{{ form_action }}" class="{{ form_class|default:'' }}" enctype="multipart/form-data" id="{{ form_id|default:'' }}" method="{{ submit_method|default:'post' }}"> <form action="{{ form_action }}" class="{{ form_css_classes|default:'' }}" enctype="multipart/form-data" id="{{ form_id|default:'' }}" method="{{ submit_method|default:'post' }}">
{% else %} {% else %}
<form action="{{ form_action }}" class="{{ form_class|default:'' }}" id="{{ form_id|default:'' }}" method="{{ submit_method|default:'post' }}"> <form action="{{ form_action }}" class="{{ form_css_classes|default:'' }}" id="{{ form_id|default:'' }}" method="{{ submit_method|default:'post' }}">
{% endif %} {% endif %}
{% for form_name, form in forms.items %} {% for form_name, form in forms.items %}
@@ -56,7 +56,7 @@
<div class="form-group"> <div class="form-group">
{% if not form_disable_submit %} {% if not form_disable_submit %}
<button class="btn btn-primary" name="{% if form.prefix %}{{ form.prefix }}-submit{% else %}submit{% endif %}" type="submit"><i class="{{ submit_icon|default:'fa fa-check' }}"></i> {% if submit_label %}{{ submit_label }}{% else %}{% if object %}{% trans 'Save' %}{% else %}{% trans 'Submit' %}{% endif %}{% endif %}</button> <button class="btn btn-primary btn-hotkey-default" name="{% if form.prefix %}{{ form.prefix }}-submit{% else %}submit{% endif %}" type="submit"><i class="{{ submit_icon|default:'fa fa-check' }}"></i> {% if submit_label %}{{ submit_label }}{% else %}{% if object %}{% trans 'Save' %}{% else %}{% trans 'Submit' %}{% endif %}{% endif %}</button>
{% endif %} {% endif %}
{% if previous %} {% if previous %}
&nbsp;<a class="btn btn-default" onclick='history.back();'> &nbsp;<a class="btn btn-default" onclick='history.back();'>
@@ -64,6 +64,7 @@
</a> </a>
{% endif %} {% endif %}
</div> </div>
{% endif %} {% endif %}
</form> </form>
</div> </div>