From 76e8fd2b07072b22beb0ae2280628a63a074c351 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Wed, 24 May 2017 02:27:43 -0400 Subject: [PATCH] Auto select checkbox when updating metadata values. Closes GitLab issue #371. Signed-off-by: Roberto Rosario --- HISTORY.rst | 1 + docs/releases/2.2.1.rst | 4 +++- mayan/apps/appearance/templates/appearance/base.html | 11 +++++++++++ mayan/apps/metadata/forms.py | 7 ++++++- .../apps/metadata/static/metadata/js/metadata_form.js | 11 +++++++++++ 5 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 mayan/apps/metadata/static/metadata/js/metadata_form.js diff --git a/HISTORY.rst b/HISTORY.rst index 96074f7476..3e2e221fc9 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -1,6 +1,7 @@ 2.2.1 (2017-05-25) ================== - Allow for bigger indexing expression templates. +- Auto select checkbox when updating metadata values. GitLab issue #371. 2.2 (2017-04-26) ================ diff --git a/docs/releases/2.2.1.rst b/docs/releases/2.2.1.rst index d65004c2e0..da8b4abcfa 100644 --- a/docs/releases/2.2.1.rst +++ b/docs/releases/2.2.1.rst @@ -14,6 +14,8 @@ Changes ------------- - Index node expression template field changed from a 128 character field to an unlimited size text field to allow for complex indexing expressions. +- When updating the metadata of a document, any input in the value form field + will select the adjacent checkbox. Removals -------- @@ -68,6 +70,6 @@ Backward incompatible changes Bugs fixed or issues closed =========================== -* `GitLab issue #357 `_ It should be possible to retrieve all workflows for a given DocumentType from the API +* `GitLab issue #371 `_ Auto select checkbox when updating metadata .. _PyPI: https://pypi.python.org/pypi/mayan-edms/ diff --git a/mayan/apps/appearance/templates/appearance/base.html b/mayan/apps/appearance/templates/appearance/base.html index 57ab139e7e..34bd926549 100644 --- a/mayan/apps/appearance/templates/appearance/base.html +++ b/mayan/apps/appearance/templates/appearance/base.html @@ -33,6 +33,17 @@ {% block stylesheets %}{% endblock %} {% endcompress %} + {% if appearance_type == 'plain' %} diff --git a/mayan/apps/metadata/forms.py b/mayan/apps/metadata/forms.py index c220154ac4..38916ad583 100644 --- a/mayan/apps/metadata/forms.py +++ b/mayan/apps/metadata/forms.py @@ -16,11 +16,16 @@ class DocumentMetadataForm(forms.Form): label=_('Name'), required=False, widget=forms.TextInput(attrs={'readonly': 'readonly'}) ) - value = forms.CharField(label=_('Value'), required=False) + value = forms.CharField(label=_('Value'), required=False, + widget=forms.TextInput(attrs={'class': 'metadata-value'}) + ) update = forms.BooleanField( initial=True, label=_('Update'), required=False ) + class Media: + js = ('metadata/js/metadata_form.js',) + def __init__(self, *args, **kwargs): super(DocumentMetadataForm, self).__init__(*args, **kwargs) diff --git a/mayan/apps/metadata/static/metadata/js/metadata_form.js b/mayan/apps/metadata/static/metadata/js/metadata_form.js new file mode 100644 index 0000000000..a39726fac8 --- /dev/null +++ b/mayan/apps/metadata/static/metadata/js/metadata_form.js @@ -0,0 +1,11 @@ +'use strict'; + +waitForJQuery(function() { + jQuery(document).ready(function() { + $('.metadata-value').on('input', function(event) { + // Check the checkbox next to a metadata value input when there is + // data entry in the value's input. + $(event.target).parents('tr').find(':checkbox').prop('checked', true); + }); + }); +});