diff --git a/mayan/apps/appearance/static/appearance/js/base.js b/mayan/apps/appearance/static/appearance/js/base.js index a49ba26e43..5be92bdef7 100644 --- a/mayan/apps/appearance/static/appearance/js/base.js +++ b/mayan/apps/appearance/static/appearance/js/base.js @@ -1,19 +1,19 @@ 'use strict'; var app = new App(); +var partialNavigation = new PartialNavigation({ + initialURL: initialURL, + excludeAnchorClasses: ['fancybox', 'new_window'], + formBeforeSerializeCallbacks: [App.MultiObjectFormProcess], +}); jQuery(document).ready(function() { app.setupFullHeightResizing(); - - var partialNavigation = new PartialNavigation({ - initialURL: initialURL, - excludeAnchorClasses: ['fancybox', 'new_window'], - }); + partialNavigation.initialize(); }); var afterBaseLoad = function () { MayanImage.intialize(); - app.doToastrMessages(); app.setupAutoSubmit(); app.setupItemsSelector(); diff --git a/mayan/apps/appearance/static/appearance/js/mayan_app.js b/mayan/apps/appearance/static/appearance/js/mayan_app.js index fc745b23e9..16c058bd39 100644 --- a/mayan/apps/appearance/static/appearance/js/mayan_app.js +++ b/mayan/apps/appearance/static/appearance/js/mayan_app.js @@ -10,6 +10,30 @@ var App = function (parameters) { // Class methods and variables +App.MultiObjectFormProcess = function ($form, options) { + /* + * ajaxForm callback to add the external item checkboxes to the + * submitted form + */ + + if ($form.hasClass('form-multi-object-action')) { + // Turn form data into an object + var formArray = $form.serializeArray().reduce(function (obj, item) { + obj[item.name] = item.value; + return obj; + }, {}); + + // Add all checked checkboxes to the form data + $('.form-multi-object-action-checkbox:checked').each(function() { + var $this = $(this); + formArray[$this.attr('name')] = $this.attr('value'); + }); + + // Set the form data as the data to send + options.data = formArray; + } +} + App.tagSelectionTemplate = function (tag, container) { var $tag = $( ' ' + tag.text + '' @@ -97,7 +121,7 @@ App.prototype.doToastrMessages = function () { App.prototype.setupAutoSubmit = function () { $('.select-auto-submit').change(function () { if ($(this).val()) { - this.form.submit(); + $(this.form).trigger('submit'); } }); } diff --git a/mayan/apps/appearance/static/appearance/js/partial_navigation.js b/mayan/apps/appearance/static/appearance/js/partial_navigation.js index 4a0e02270e..a0803bc609 100644 --- a/mayan/apps/appearance/static/appearance/js/partial_navigation.js +++ b/mayan/apps/appearance/static/appearance/js/partial_navigation.js @@ -12,14 +12,24 @@ $.fn.hasAnyClass = function() { var PartialNavigation = function (parameters) { parameters = parameters || {}; - this.initialURL = parameters.initialURL || null; - this.excludeAnchorClasses = parameters.excludeAnchorClasses || []; + // lastLocation - used as the AJAX referer this.lastLocation = null; + // initialURL - the URL to send users when trying to access the / URL + this.initialURL = parameters.initialURL || null; + + // excludeAnchorClasses - Anchors with any of these classes will not be processes as AJAX anchors + this.excludeAnchorClasses = parameters.excludeAnchorClasses || []; + + // formBeforeSerializeCallbacks - Callbacks to execute before submitting an ajaxForm + this.formBeforeSerializeCallbacks = parameters.formBeforeSerializeCallbacks || []; + if (!this.initialURL) { alert('Need to setup initialURL'); } +} +PartialNavigation.prototype.initialize = function () { this.setupAjaxAnchors(); this.setupAjaxNavigation(); this.setupAjaxForm(); @@ -137,6 +147,11 @@ PartialNavigation.prototype.setupAjaxForm = function () { $('form').ajaxForm({ async: false, + beforeSerialize: function($form, options) { + $.each(app.formBeforeSerializeCallbacks, function (index, value) { + value($form, options); + }); + }, beforeSubmit: function(arr, $form, options) { console.log('>> ajaxForm.beforeSubmit.$form.target: ' + $form.attr('action')); var uri = new URI(location); 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 192db9bf78..e648140264 100644 --- a/mayan/apps/appearance/templates/appearance/generic_list_items_subtemplate.html +++ b/mayan/apps/appearance/templates/appearance/generic_list_items_subtemplate.html @@ -33,7 +33,7 @@
{% trans 'No results' %}
+| - {% endif %} - - {% if not hide_object %} - | {% trans 'Identifier' %} | - {% endif %} - - {% if not hide_columns %} - {% for column in object_list|get_source_columns %} -{{ column.label }} | - {% endfor %} - {% endif %} - - {% for column in extra_columns %} -{{ column.name }} | - {% endfor %} - - {% if not hide_links %} -- {% endif %} - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| {% endif %} - {% for object in object_list %} - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| - {% if multi_select_item_properties %} - - {% else %} - - {% endif %} - | - {% endif %} - {% if not hide_object %} - {% if main_object %} - {% with object|object_property:main_object as object %} -{% if not hide_link %}{{ object }}{% else %}{{ object }}{% endif %} | - {% endwith %} - {% else %} -{% if not hide_link %}{{ object }}{% else %}{{ object }}{% endif %} | - {% endif %} - {% endif %} - {% if not hide_columns %} - {% for column in object|get_source_columns %} -{% source_column_resolve column=column %}{{ column_result }} | - {% endfor %} - {% endif %} - {% for column in extra_columns %} -{{ object|object_property:column.attribute }} | + {% if not hide_object %} +{% trans 'Identifier' %} | + {% endif %} + + {% if not hide_columns %} + {% for column in object_list|get_source_columns %} +{{ column.label }} | {% endfor %} - {% if not hide_links %} -- {% get_menu_links 'object menu' source=object as resolved_links %} - {% for object_navigation_links in resolved_links %} - {% with 'true' as horizontal %} - {% include 'navigation/generic_navigation.html' %} - {% endwith %} - {% endfor %} - | - {% endif %} -|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {% trans 'No results' %} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||