From 263d646c7c997b645845aa789747894689cae41a Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Thu, 20 Dec 2018 20:40:26 -0400 Subject: [PATCH] Appearance: Select card by clicking on the card Add support for selecting a document from the UI by just clicking on the title of the body of the card, not just on the checkbox next to the title. Signed-off-by: Roberto Rosario --- HISTORY.rst | 3 ++ .../static/appearance/js/mayan_app.js | 43 +++++++++++++++++++ .../appearance/templates/appearance/root.html | 1 - 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/HISTORY.rst b/HISTORY.rst index ab62c04a34..0729434214 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -207,6 +207,9 @@ navigation links will be displayed here. The notification, user and system tools are now displayed at the top navigation bar. +- Added support for selecting a document from the UI by just + clicking on the title of the body of the card, not just on + the checkbox next to the title. 3.1.9 (2018-11-01) ================== diff --git a/mayan/apps/appearance/static/appearance/js/mayan_app.js b/mayan/apps/appearance/static/appearance/js/mayan_app.js index 50c6716c95..76c00aeeed 100644 --- a/mayan/apps/appearance/static/appearance/js/mayan_app.js +++ b/mayan/apps/appearance/static/appearance/js/mayan_app.js @@ -223,6 +223,7 @@ class MayanApp { value.app = self; app.doRefreshAJAXMenu(value); }); + this.setupPanelSelection(); partialNavigation.initialize(); } @@ -312,6 +313,7 @@ class MayanApp { app.lastChecked = this; return; } + if(e.shiftKey) { var $checkBoxes = $('.check-all-slave'); @@ -348,6 +350,47 @@ class MayanApp { }); } + setupPanelSelection () { + var app = this; + + $('body').on('click', '.panel-item', function (event) { + var $this = $(this); + var targetSrc = $(event.target).prop('src'); + var targetHref = $(event.target).prop('href'); + var lastChecked = null; + + if ((targetSrc === undefined) && (targetHref === undefined)) { + var $checkbox = $this.find('.check-all-slave'); + var checked = $checkbox.prop('checked'); + + if (checked) { + $checkbox.prop('checked', ''); + $checkbox.trigger('change'); + } else { + $checkbox.prop('checked', 'checked'); + $checkbox.trigger('change'); + } + + if(!app.lastChecked) { + app.lastChecked = $checkbox; + } + + if (event.shiftKey) { + var $checkBoxes = $('.check-all-slave'); + + var start = $checkBoxes.index($checkbox); + var end = $checkBoxes.index(app.lastChecked); + + $checkBoxes.slice( + Math.min(start, end), Math.max(start, end) + 1 + ).prop('checked', app.lastChecked.prop('checked')).trigger('change'); + } + app.lastChecked = $checkbox; + window.getSelection().removeAllRanges(); + } + }); + } + setupScrollView () { $('.scrollable').scrollview(); } diff --git a/mayan/apps/appearance/templates/appearance/root.html b/mayan/apps/appearance/templates/appearance/root.html index 10489a7e2e..b8a0ab677e 100644 --- a/mayan/apps/appearance/templates/appearance/root.html +++ b/mayan/apps/appearance/templates/appearance/root.html @@ -107,7 +107,6 @@ {# Transfer variable from Django to javascript #} var initialURL = '{% url home_view %}'; var djangoDEBUG = {% if debug %}true{% else %}false{% endif %}; - var apiTemplateMainMenuURL = '{% url "rest_api:template-detail" "menu_main" %}';