From eceb3ed877b2c14b8dcc4f5f7c7ee30de4acc9e8 Mon Sep 17 00:00:00 2001 From: Eric Riggs Date: Thu, 22 Feb 2018 16:01:04 -0400 Subject: [PATCH] - 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 --- .../appearance/static/appearance/js/base.js | 20 +++++++++++ .../generic_list_items_subtemplate.html | 35 +++++++++---------- .../appearance/generic_list_subtemplate.html | 3 -- mayan/apps/navigation/forms.py | 9 ++++- 4 files changed, 45 insertions(+), 22 deletions(-) diff --git a/mayan/apps/appearance/static/appearance/js/base.js b/mayan/apps/appearance/static/appearance/js/base.js index 549e21988d..19ae8bf67c 100644 --- a/mayan/apps/appearance/static/appearance/js/base.js +++ b/mayan/apps/appearance/static/appearance/js/base.js @@ -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(); }); diff --git a/mayan/apps/appearance/templates/appearance/generic_list_items_subtemplate.html b/mayan/apps/appearance/templates/appearance/generic_list_items_subtemplate.html index fb19aab886..464cda3e57 100644 --- a/mayan/apps/appearance/templates/appearance/generic_list_items_subtemplate.html +++ b/mayan/apps/appearance/templates/appearance/generic_list_items_subtemplate.html @@ -30,25 +30,24 @@ {% endif %}
-
- -
- {% if object_list %} - {% if not hide_multi_item_actions %} - {% get_multi_item_links_form object_list %} - {% endif %} - {% if multi_item_actions %} -
- {{ multi_item_form }} -   -
- {% endif %} - {% endif %} - -
+
+
+ + {% if object_list %} + {% if not hide_multi_item_actions %} + {% get_multi_item_links_form object_list %} + {% endif %} + {% if multi_item_actions %} +
+   + {{ multi_item_form }} +
+ {% endif %} + {% endif %} +
+
+
{% if scrollable_content %}
{% endif %} diff --git a/mayan/apps/appearance/templates/appearance/generic_list_subtemplate.html b/mayan/apps/appearance/templates/appearance/generic_list_subtemplate.html index 6219bf1240..afa507de28 100644 --- a/mayan/apps/appearance/templates/appearance/generic_list_subtemplate.html +++ b/mayan/apps/appearance/templates/appearance/generic_list_subtemplate.html @@ -29,9 +29,6 @@ {% if multi_item_actions %}
{{ multi_item_form }} -  
{% endif %} {% endif %} diff --git a/mayan/apps/navigation/forms.py b/mayan/apps/navigation/forms.py index b2093e3a35..0a8312a69a 100644 --- a/mayan/apps/navigation/forms.py +++ b/mayan/apps/navigation/forms.py @@ -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'} + ) + )