forked from shaba/openuds
Adding tags & tag edition to mayor elemets of uds administration (for filtering, etc..)
This commit is contained in:
parent
134f2059dd
commit
6bb1109fe1
@ -89,6 +89,7 @@ class Authenticators(ModelHandler):
|
||||
return {
|
||||
'id': auth.uuid,
|
||||
'name': auth.name,
|
||||
'tags': [tag.tag for tag in auth.tags.all()],
|
||||
'comments': auth.comments,
|
||||
'priority': auth.priority,
|
||||
'small_name': auth.small_name,
|
||||
|
@ -66,6 +66,7 @@ class Calendars(ModelHandler):
|
||||
return {
|
||||
'id': calendar.uuid,
|
||||
'name': calendar.name,
|
||||
'tags': [tag.tag for tag in calendar.tags.all()],
|
||||
'comments': calendar.comments,
|
||||
'modified': calendar.modified,
|
||||
'permission': permissions.getEffectivePermission(self._user, calendar)
|
||||
|
@ -88,6 +88,7 @@ class Networks(ModelHandler):
|
||||
return {
|
||||
'id': item.uuid,
|
||||
'name': item.name,
|
||||
'tags': [tag.tag for tag in item.tags.all()],
|
||||
'net_string': item.net_string,
|
||||
'networks_count': item.transports.count(),
|
||||
'permission': permissions.getEffectivePermission(self._user, item)
|
||||
|
@ -64,6 +64,7 @@ class OsManagers(ModelHandler):
|
||||
return {
|
||||
'id': osm.uuid,
|
||||
'name': osm.name,
|
||||
'tags': [tag.tag for tag in osm.tags.all()],
|
||||
'deployed_count': osm.deployedServices.count(),
|
||||
'type': type_.type(),
|
||||
'servicesTypes': type_.servicesType,
|
||||
|
@ -84,6 +84,7 @@ class Providers(ModelHandler):
|
||||
return {
|
||||
'id': provider.uuid,
|
||||
'name': provider.name,
|
||||
'tags': [tag.vtag for tag in provider.tags.all()],
|
||||
'services_count': provider.services.count(),
|
||||
'user_services_count': UserService.objects.filter(deployed_service__service__provider=provider).count(),
|
||||
'maintenance_mode': provider.maintenance_mode,
|
||||
@ -104,7 +105,7 @@ class Providers(ModelHandler):
|
||||
# Gui related
|
||||
def getGui(self, type_):
|
||||
try:
|
||||
return self.addDefaultFields(services.factory().lookup(type_).guiDescription(), ['name', 'comments'])
|
||||
return self.addDefaultFields(services.factory().lookup(type_).guiDescription(), ['name', 'comments', 'tags'])
|
||||
except Exception:
|
||||
raise NotFound('type not found')
|
||||
|
||||
|
@ -84,6 +84,7 @@ class Services(DetailHandler): # pylint: disable=too-many-public-methods
|
||||
retVal = {
|
||||
'id': item.uuid,
|
||||
'name': item.name,
|
||||
'tags': [tag.tag for tag in item.tags.all()],
|
||||
'comments': item.comments,
|
||||
'type': item.data_type,
|
||||
'type_name': _(itemType.name()),
|
||||
|
@ -84,6 +84,7 @@ class ServicesPools(ModelHandler):
|
||||
val = {
|
||||
'id': item.uuid,
|
||||
'name': item.name,
|
||||
'tags': [tag.tag for tag in item.tags.all()],
|
||||
'parent': item.service.name,
|
||||
'parent_type': item.service.data_type,
|
||||
'comments': item.comments,
|
||||
|
@ -88,6 +88,7 @@ class Transports(ModelHandler):
|
||||
return {
|
||||
'id': item.uuid,
|
||||
'name': item.name,
|
||||
'tags': [tag.tag for tag in item.tags.all()],
|
||||
'comments': item.comments,
|
||||
'priority': item.priority,
|
||||
'nets_positive': item.nets_positive,
|
||||
|
@ -52,7 +52,7 @@ import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
__updated__ = '2015-10-23'
|
||||
__updated__ = '2016-02-10'
|
||||
|
||||
|
||||
# a few constants
|
||||
@ -112,6 +112,14 @@ class BaseModelHandler(Handler):
|
||||
:param gui: Gui list where the "default" fielsds will be added
|
||||
:param flds: List of fields names requested to be added. Valid values are 'name', 'comments', 'priority' and 'small_name'
|
||||
'''
|
||||
if 'tags' in flds:
|
||||
self.addField(gui, {
|
||||
'name': 'tags',
|
||||
'label': _('Tags'),
|
||||
'type': 'taglist',
|
||||
'tooltip': _('Tags for this element'),
|
||||
'order': 0 - 101,
|
||||
})
|
||||
if 'name' in flds:
|
||||
self.addField(gui, {
|
||||
'name': 'name',
|
||||
@ -137,17 +145,17 @@ class BaseModelHandler(Handler):
|
||||
'required': True,
|
||||
'value': 1,
|
||||
'length': 4,
|
||||
'order': 0 - 98,
|
||||
'order': 0 - 97,
|
||||
})
|
||||
if 'small_name' in flds:
|
||||
self.addField(gui, {
|
||||
'name': 'small_name',
|
||||
'type': 'text',
|
||||
'label': _('Tag'),
|
||||
'tooltip': _('Tag for this element'),
|
||||
'label': _('Label'),
|
||||
'tooltip': _('Label for this element'),
|
||||
'required': True,
|
||||
'length': 128,
|
||||
'order': 0 - 97,
|
||||
'order': 0 - 96,
|
||||
})
|
||||
|
||||
return gui
|
||||
|
@ -60,6 +60,10 @@ class Tag(UUIDModel):
|
||||
db_table = 'uds_tag'
|
||||
app_label = 'uds'
|
||||
|
||||
@property
|
||||
def vtag(self):
|
||||
return self.tag.capitalize()
|
||||
|
||||
def __unicode__(self):
|
||||
return 'Tag: {} {}'.format(self.uuid, self.tag)
|
||||
|
||||
@ -68,4 +72,4 @@ class TaggingMixin(models.Model):
|
||||
tags = models.ManyToManyField(Tag)
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
abstract = True
|
||||
|
File diff suppressed because one or more lines are too long
@ -225,6 +225,7 @@
|
||||
{% js_template 'fld/text' %}
|
||||
{% js_template 'fld/textbox' %}
|
||||
{% js_template 'fld/date' %}
|
||||
{% js_template 'fld/taglist' %}
|
||||
|
||||
</body>
|
||||
</html>
|
@ -14,8 +14,8 @@
|
||||
(function(){
|
||||
"use strict";
|
||||
var id = '{{ name }}_field_';
|
||||
var idTxt = '#' + id + 'txt';
|
||||
var idHidden = '#' + id + 'hdn';
|
||||
var idTxt = 'input#' + id + 'txt';
|
||||
var idHidden = 'input#' + id + 'hdn';
|
||||
$(idTxt).tooltip({
|
||||
placement: 'bottom',
|
||||
title: "{% endverbatim %}{% trans 'Click to edit list' %}{% verbatim %}",
|
||||
|
29
server/src/uds/templates/uds/admin/tmpl/fld/taglist.html
Normal file
29
server/src/uds/templates/uds/admin/tmpl/fld/taglist.html
Normal file
@ -0,0 +1,29 @@
|
||||
{% extends "uds/admin/tmpl/fld/form-group.html" %}
|
||||
{% load i18n %}
|
||||
{% block field %}{% verbatim %}
|
||||
{{# each value }}
|
||||
<span class="label label-default"><i class="fa fa-close closeable tag_eliminator"></i> <b class="tag">{{ this }}</b></span>
|
||||
{{/ each }}
|
||||
</select>
|
||||
{% endverbatim %}
|
||||
{% comment %}<script>/*This is a little trick to make IDE recognize sintax hightlight, will not be show on render :-)*/{% endcomment %}
|
||||
|
||||
{% verbatim %}{{# javascript }}
|
||||
(function(){
|
||||
"use strict";
|
||||
$('i.tag_eliminator').on('click', function() {
|
||||
var $this = $(this);
|
||||
var val = $this.parent().find('b.tag').text();
|
||||
if(prompt(gettext('Remove') + val) == true) {
|
||||
$(this).parent().html('');
|
||||
}
|
||||
|
||||
})
|
||||
}());
|
||||
|
||||
|
||||
|
||||
{{/ javascript }}{% endverbatim %}
|
||||
{% comment %}</script>{% endcomment %}
|
||||
|
||||
{% endblock %}
|
@ -338,6 +338,14 @@ body {
|
||||
}
|
||||
}
|
||||
|
||||
// tag elimicator (close)
|
||||
.closeable {
|
||||
&:hover {
|
||||
cursor: pointer;
|
||||
color: red;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* theme */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user