From e1b8c43cca26e57c9f28ea029474ee858fe9524c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adolfo=20G=C3=B3mez=20Garc=C3=ADa?= Date: Thu, 11 Feb 2016 05:44:38 +0100 Subject: [PATCH] Added "tag editing" admin control --- server/src/uds/static/adm/js/api-tools.coffee | 4 + server/src/uds/static/adm/js/gui-form.coffee | 8 ++ .../templates/uds/admin/tmpl/fld/taglist.html | 112 +++++++++++++++--- server/templates/admin/app/css/main.scss | 8 +- server/templates/admin/dist/css/main.css | 2 +- 5 files changed, 116 insertions(+), 18 deletions(-) diff --git a/server/src/uds/static/adm/js/api-tools.coffee b/server/src/uds/static/adm/js/api-tools.coffee index b7e08ed0e..62dcce345 100644 --- a/server/src/uds/static/adm/js/api-tools.coffee +++ b/server/src/uds/static/adm/js/api-tools.coffee @@ -32,6 +32,10 @@ first = mid - 1 remain = maxLen - mid - 2 str = str.substr(0, first) + "..." + str.substr(sl-remain) + + capitalize: (str) -> + str = str.toLowerCase() + return str.substr(0,1).toUpperCase() + str.substr(1) return str diff --git a/server/src/uds/static/adm/js/gui-form.coffee b/server/src/uds/static/adm/js/gui-form.coffee index 00c2bd109..8b27c1138 100644 --- a/server/src/uds/static/adm/js/gui-form.coffee +++ b/server/src/uds/static/adm/js/gui-form.coffee @@ -42,8 +42,12 @@ return value = newValue + # Generate an unique id so templates can use it if needed + id = "uniq" + Math.random().toString().split(".")[1] + originalValues[f.name] = value # Store original value html += api.templates.evaluate("tmpl_fld_" + f.gui.type, + id: id value: value # If no value present, use default value minValue: f.gui.minValue maxValue: f.gui.maxValue @@ -169,6 +173,10 @@ name = $field.attr("name") if $field.attr("type") is "checkbox" res[name] = $field.is(":checked") + else if $field.attr("data-uds") is "list" + res[name] = $field.val().split('/**/') + else if $field.attr("data-uds") is "commaList" + res[name] = $field.val().split(',') else res[name] = $field.val() res[name] = [] if not res[name]? and $field.is("select") diff --git a/server/src/uds/templates/uds/admin/tmpl/fld/taglist.html b/server/src/uds/templates/uds/admin/tmpl/fld/taglist.html index 3274b1f9a..71a360315 100644 --- a/server/src/uds/templates/uds/admin/tmpl/fld/taglist.html +++ b/server/src/uds/templates/uds/admin/tmpl/fld/taglist.html @@ -1,16 +1,14 @@ {% extends "uds/admin/tmpl/fld/form-group.html" %} {% load i18n %} {% block field %}{% verbatim %} - {{# each value }} - {{ this }} - {{/ each }} - {% endverbatim %}{% trans 'Add Tag...' %}{% verbatim %} +
+
- + {{# unless readonly }} + {% endverbatim %}{% trans 'Add Tag...' %}{% verbatim %} + {{/ unless }} + + {% endverbatim %} {% comment %}