- 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;
|
return $tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
App.prototype.setupAutoSubmit = function () {
|
||||||
|
$('.select-auto-submit').change(function () {
|
||||||
|
if ($(this).val()) {
|
||||||
|
this.form.submit();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
App.prototype.setupScrollView = function () {
|
App.prototype.setupScrollView = function () {
|
||||||
$('.scrollable').scrollview();
|
$('.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 () {
|
App.prototype.setupWindowPopUp = function () {
|
||||||
$('a.new_window').click(function(event) {
|
$('a.new_window').click(function(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@@ -227,7 +243,11 @@ jQuery(document).ready(function() {
|
|||||||
|
|
||||||
app.setupScrollView();
|
app.setupScrollView();
|
||||||
|
|
||||||
|
app.setupItemsSelector();
|
||||||
|
|
||||||
app.setupTableSelector();
|
app.setupTableSelector();
|
||||||
|
|
||||||
app.setupWindowPopUp();
|
app.setupWindowPopUp();
|
||||||
|
|
||||||
|
app.setupAutoSubmit();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -30,25 +30,24 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</h4>
|
</h4>
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
<div class="well center-block">
|
<div class="well center-block">
|
||||||
|
<div class="clearfix">
|
||||||
<form action="{% url 'common:multi_object_action_view' %}" class="pure-form" method="get">
|
<div class="pull-right">
|
||||||
{% if object_list %}
|
<form action="{% url 'common:multi_object_action_view' %}" class="pure-form" method="get">
|
||||||
{% if not hide_multi_item_actions %}
|
{% if object_list %}
|
||||||
{% get_multi_item_links_form object_list %}
|
{% if not hide_multi_item_actions %}
|
||||||
{% endif %}
|
{% get_multi_item_links_form object_list %}
|
||||||
{% if multi_item_actions %}
|
{% endif %}
|
||||||
<fieldset>
|
{% if multi_item_actions %}
|
||||||
{{ multi_item_form }}
|
<fieldset>
|
||||||
<button class="btn btn-primary btn-xs" type="submit" name="{{ form.prefix }}-submit">
|
<input class="check-all" type="checkbox"/>
|
||||||
{% trans 'Submit' %}
|
{{ multi_item_form }}
|
||||||
</button>
|
</fieldset>
|
||||||
</fieldset>
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
</div>
|
||||||
|
</div>
|
||||||
<hr/>
|
<hr style="border-bottom: 1px solid lightgrey;">
|
||||||
{% if scrollable_content %}
|
{% if scrollable_content %}
|
||||||
<div style="border: 1px solid; height: {{ scrollable_content_height }}; overflow: auto;">
|
<div style="border: 1px solid; height: {{ scrollable_content_height }}; overflow: auto;">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
@@ -29,9 +29,6 @@
|
|||||||
{% if multi_item_actions %}
|
{% if multi_item_actions %}
|
||||||
<fieldset>
|
<fieldset>
|
||||||
{{ multi_item_form }}
|
{{ multi_item_form }}
|
||||||
<button class="btn btn-primary btn-xs" type="submit" name="{{ form.prefix }}-submit">
|
|
||||||
{% trans 'Submit' %}
|
|
||||||
</button>
|
|
||||||
</fieldset>
|
</fieldset>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
@@ -7,8 +7,15 @@ from django.utils.translation import ugettext_lazy as _
|
|||||||
class MultiItemForm(forms.Form):
|
class MultiItemForm(forms.Form):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
actions = kwargs.pop('actions', [])
|
actions = kwargs.pop('actions', [])
|
||||||
|
if actions:
|
||||||
|
actions.insert(0, ['', '---'])
|
||||||
|
|
||||||
super(MultiItemForm, self).__init__(*args, **kwargs)
|
super(MultiItemForm, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
self.fields['action'].choices = actions
|
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