From fe579932403289b31457e2b4eaa00892507828f1 Mon Sep 17 00:00:00 2001 From: Khanh Ngo Date: Sun, 19 Apr 2020 00:44:51 +0700 Subject: [PATCH] Adjust AllowedIPs field to use input tag plugin --- templates/base.html | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/templates/base.html b/templates/base.html index 08b0107..a1e6393 100644 --- a/templates/base.html +++ b/templates/base.html @@ -17,6 +17,8 @@ + + @@ -140,7 +142,8 @@
- +
@@ -208,6 +211,8 @@ + + @@ -219,14 +224,14 @@ var name = $("#client_name").val(); var email = $("#client_email").val(); var allocated_ips = $("#client_allocated_ips").select2('val'); - var allowed_ips = $("#client_allowed_ips").val(); + var allowed_ips = $("#client_allowed_ips").val().split(","); var enabled = false; if ($("#enabled").is(':checked')){ enabled = true; } - var data = {"name": name, "email": email, "allocated_ips": [allocated_ips], "allowed_ips": [allowed_ips], + var data = {"name": name, "email": email, "allocated_ips": [allocated_ips], "allowed_ips": allowed_ips, "enabled": enabled}; console.log(data); @@ -249,6 +254,18 @@ //Initialize Select2 Elements $('.select2').select2() + // AllowedIPs tag input + $('#client_allowed_ips').tagsInput({ + 'width': '100%', + 'height': '75%', + 'interactive': true, + 'defaultText': 'Add More', + 'removeWithBackspace': true, + 'minChars': 0, + 'maxChars': 18, + 'placeholderColor': '#666666' + }); + // New client form validation $(document).ready(function () { $.validator.setDefaults({