Move tag specific JavaScript to the tags app
Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
@@ -51,6 +51,7 @@
|
||||
* Integrate django-autoadmin into the core apps.
|
||||
* Update middleware to new style classes.
|
||||
* Add server side invalid document template.
|
||||
* Move tag specific JavaScript to the tags app.
|
||||
|
||||
3.1.11 (2019-04-XX)
|
||||
===================
|
||||
|
||||
@@ -75,6 +75,7 @@ Other changes
|
||||
* Integrate django-autoadmin into the core apps.
|
||||
* Update middleware to new style classes.
|
||||
* Add server side invalid document template.
|
||||
* Move tag specific JavaScript to the tags app.
|
||||
|
||||
Removals
|
||||
--------
|
||||
|
||||
@@ -52,22 +52,6 @@ class MayanApp {
|
||||
});
|
||||
}
|
||||
|
||||
static tagSelectionTemplate (tag, container) {
|
||||
var $tag = $(
|
||||
'<span class="label label-tag" style="background: ' + tag.element.dataset.color + ';"> ' + tag.text + '</span>'
|
||||
);
|
||||
container[0].style.background = tag.element.dataset.color;
|
||||
return $tag;
|
||||
}
|
||||
|
||||
static tagResultTemplate (tag) {
|
||||
if (!tag.element) { return ''; }
|
||||
var $tag = $(
|
||||
'<span class="label label-tag" style="background: ' + tag.element.dataset.color + ';"> ' + tag.text + '</span>'
|
||||
);
|
||||
return $tag;
|
||||
}
|
||||
|
||||
// Instance methods
|
||||
|
||||
callbackAJAXSpinnerUpdate () {
|
||||
@@ -283,12 +267,6 @@ class MayanApp {
|
||||
dropdownAutoWidth: true,
|
||||
width: '100%'
|
||||
});
|
||||
|
||||
$('.select2-tags').select2({
|
||||
templateSelection: MayanApp.tagSelectionTemplate,
|
||||
templateResult: MayanApp.tagResultTemplate,
|
||||
width: '100%'
|
||||
});
|
||||
}
|
||||
|
||||
resizeFullHeight () {
|
||||
|
||||
@@ -15,6 +15,9 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class TagMultipleSelectionForm(forms.Form):
|
||||
class Media:
|
||||
js = ('tags/js/tags_form.js',)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
help_text = kwargs.pop('help_text', None)
|
||||
permission = kwargs.pop('permission', permission_tag_view)
|
||||
|
||||
25
mayan/apps/tags/static/tags/js/tags_form.js
Normal file
25
mayan/apps/tags/static/tags/js/tags_form.js
Normal file
@@ -0,0 +1,25 @@
|
||||
'use strict';
|
||||
|
||||
var tagSelectionTemplate = function (tag, container) {
|
||||
var $tag = $(
|
||||
'<span class="label label-tag" style="background: ' + tag.element.dataset.color + ';"> ' + tag.text + '</span>'
|
||||
);
|
||||
container[0].style.background = tag.element.dataset.color;
|
||||
return $tag;
|
||||
}
|
||||
|
||||
var tagResultTemplate = function (tag) {
|
||||
if (!tag.element) { return ''; }
|
||||
var $tag = $(
|
||||
'<span class="label label-tag" style="background: ' + tag.element.dataset.color + ';"> ' + tag.text + '</span>'
|
||||
);
|
||||
return $tag;
|
||||
}
|
||||
|
||||
jQuery(document).ready(function() {
|
||||
$('.select2-tags').select2({
|
||||
templateSelection: tagSelectionTemplate,
|
||||
templateResult: tagResultTemplate,
|
||||
width: '100%'
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user