From 7d190d336050f9997f957fbedd88d23e5166a645 Mon Sep 17 00:00:00 2001 From: Jan Hermann Date: Tue, 26 Oct 2021 15:06:13 +0200 Subject: [PATCH] Update unique_url_slug.html --- unique_url_slug.html | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/unique_url_slug.html b/unique_url_slug.html index e19aa9d..90db670 100644 --- a/unique_url_slug.html +++ b/unique_url_slug.html @@ -49,7 +49,7 @@ -
+
@@ -69,7 +69,7 @@ var generates_from = ''; var autogenerate = '[autogenerated]'; var force_uniqueness = "false"; - var allowed_chars = '[^a-zA-Z0-9]'; + var restricted_chars = '[^a-zA-Z0-9]'; function updateDisabled(disabled) { if (disabled) { @@ -112,17 +112,26 @@ if (element.config.repeater) { repeater = element.config.repeater; } + else { + showError("Missing 'Repeater' URL for proxying requests from this element to Preview API"); + } if (element.config.codename) { codename = element.config.codename; } + else { + showError("Missing codename of 'Custom URL Slug' element"); + } if (element.config.generates_from) { generates_from = element.config.generates_from; } + else { + showError("Missing source 'Text' element codename"); + } if (element.config.force_uniqueness) { force_uniqueness = element.config.force_uniqueness; } - if (element.config.allowed_chars) { - allowed_chars = element.config.allowed_chars; + if (element.config.restricted_chars) { + restricted_chars = element.config.restricted_chars; } } if (element.value) { @@ -161,7 +170,7 @@ } function setValue(value) { - var re = new RegExp(allowed_chars,"g"); + var re = new RegExp(restricted_chars,"g"); value = value.replace(re,'-'); $('#unique').text(value); isUnique(value); @@ -229,8 +238,16 @@ } return result; } + + function showError(message) { + $('#element').hide(); + $('#unique-status').css("color","#ef5350"); + $('#unique-status').addClass("item-status--failed"); + $('#unique-status').text(message); + throw new Error(message); + } - \ No newline at end of file +