- Make the multi object form perform an auto submit when the value is changed.
- Add multiple object select checkbox that was missing in the list item subtemplate. Signed-off-by: Eric Riggs <ericriggs42@gmail.com>
This commit is contained in:
committed by
Roberto Rosario
parent
0a05c87c9c
commit
eceb3ed877
@@ -24,6 +24,14 @@ App.tagResultTemplate = function (tag) {
|
||||
return $tag;
|
||||
}
|
||||
|
||||
App.prototype.setupAutoSubmit = function () {
|
||||
$('.select-auto-submit').change(function () {
|
||||
if ($(this).val()) {
|
||||
this.form.submit();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
App.prototype.setupScrollView = function () {
|
||||
$('.scrollable').scrollview();
|
||||
}
|
||||
@@ -36,6 +44,14 @@ App.prototype.setupTableSelector = function () {
|
||||
});
|
||||
}
|
||||
|
||||
App.prototype.setupItemsSelector = function () {
|
||||
$('.check-all').click(function(e) {
|
||||
var parent = $(e.target).closest('.well');
|
||||
var checked = $(e.target).prop('checked');
|
||||
$('.panel-item input:checkbox', parent).prop('checked', checked);
|
||||
});
|
||||
}
|
||||
|
||||
App.prototype.setupWindowPopUp = function () {
|
||||
$('a.new_window').click(function(event) {
|
||||
event.preventDefault();
|
||||
@@ -227,7 +243,11 @@ jQuery(document).ready(function() {
|
||||
|
||||
app.setupScrollView();
|
||||
|
||||
app.setupItemsSelector();
|
||||
|
||||
app.setupTableSelector();
|
||||
|
||||
app.setupWindowPopUp();
|
||||
|
||||
app.setupAutoSubmit();
|
||||
});
|
||||
|
||||
@@ -30,25 +30,24 @@
|
||||
{% endif %}
|
||||
</h4>
|
||||
<hr>
|
||||
|
||||
<div class="well center-block">
|
||||
|
||||
<form action="{% url 'common:multi_object_action_view' %}" class="pure-form" method="get">
|
||||
{% if object_list %}
|
||||
{% if not hide_multi_item_actions %}
|
||||
{% get_multi_item_links_form object_list %}
|
||||
{% endif %}
|
||||
{% if multi_item_actions %}
|
||||
<fieldset>
|
||||
{{ multi_item_form }}
|
||||
<button class="btn btn-primary btn-xs" type="submit" name="{{ form.prefix }}-submit">
|
||||
{% trans 'Submit' %}
|
||||
</button>
|
||||
</fieldset>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
<hr/>
|
||||
<div class="clearfix">
|
||||
<div class="pull-right">
|
||||
<form action="{% url 'common:multi_object_action_view' %}" class="pure-form" method="get">
|
||||
{% if object_list %}
|
||||
{% if not hide_multi_item_actions %}
|
||||
{% get_multi_item_links_form object_list %}
|
||||
{% endif %}
|
||||
{% if multi_item_actions %}
|
||||
<fieldset>
|
||||
<input class="check-all" type="checkbox"/>
|
||||
{{ multi_item_form }}
|
||||
</fieldset>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<hr style="border-bottom: 1px solid lightgrey;">
|
||||
{% if scrollable_content %}
|
||||
<div style="border: 1px solid; height: {{ scrollable_content_height }}; overflow: auto;">
|
||||
{% endif %}
|
||||
|
||||
@@ -29,9 +29,6 @@
|
||||
{% if multi_item_actions %}
|
||||
<fieldset>
|
||||
{{ multi_item_form }}
|
||||
<button class="btn btn-primary btn-xs" type="submit" name="{{ form.prefix }}-submit">
|
||||
{% trans 'Submit' %}
|
||||
</button>
|
||||
</fieldset>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
@@ -7,8 +7,15 @@ from django.utils.translation import ugettext_lazy as _
|
||||
class MultiItemForm(forms.Form):
|
||||
def __init__(self, *args, **kwargs):
|
||||
actions = kwargs.pop('actions', [])
|
||||
if actions:
|
||||
actions.insert(0, ['', '---'])
|
||||
|
||||
super(MultiItemForm, self).__init__(*args, **kwargs)
|
||||
|
||||
self.fields['action'].choices = actions
|
||||
|
||||
action = forms.ChoiceField(label=_('Actions'), required=False)
|
||||
action = forms.ChoiceField(
|
||||
label='', required=False, widget=forms.widgets.Select(
|
||||
attrs={'class': 'select-auto-submit'}
|
||||
)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user