From b00a98f9bde407eddcc1d084e8bf5f01f64ebd46 Mon Sep 17 00:00:00 2001
From: Thomas Steur <tsteur@users.noreply.github.com>
Date: Wed, 17 May 2017 08:35:23 +1200
Subject: [PATCH] Add support for email and url form fields (#11708)

* add support for email and url form fields

* UI test
---
 CHANGELOG.md                                    |   1 +
 core/Settings/FieldConfig.php                   |  10 ++++++++++
 .../form-field/form-field.directive.js          |   2 +-
 plugins/Morpheus/templates/demo.twig            |  10 ++++++++--
 tests/UI/expected-screenshots/Morpheus_load.png | Bin 132 -> 132 bytes
 5 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index ce9011186d..3d53f51515 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,6 +13,7 @@ The Product Changelog at **[piwik.org/changelog](http://piwik.org/changelog)** l
 * A new JavaScript tracker method `getCurrentUrl` has been added to retrieve the current URL of the website. 
 * A new JavaScript tracker method `getNumTrackedPageViews` has been added to retrieve the number of tracked page views within the currently loaded page or web application. 
 * New JavaScript tracker methods `setSessionCookie`, `getCookie`, `hasCookies`, `getCookieDomain`, `getCookiePath`, and `getSessionCookieTimeout` have been added for better cookie support in plugins. 
+* `email` and `url` form fields can now be used in settings.
 
 ## Piwik 3.0.3
 
diff --git a/core/Settings/FieldConfig.php b/core/Settings/FieldConfig.php
index ef8a6155e2..7b2ce1df03 100644
--- a/core/Settings/FieldConfig.php
+++ b/core/Settings/FieldConfig.php
@@ -26,6 +26,16 @@ class FieldConfig
      */
     const UI_CONTROL_TEXT = 'text';
 
+    /**
+     * Shows an email text field. To use this field assign it to the `$uiControl` property.
+     */
+    const UI_CONTROL_EMAIL = 'email';
+
+    /**
+     * Shows a URL text field. To use this field assign it to the `$uiControl` property.
+     */
+    const UI_CONTROL_URL = 'url';
+
     /**
      * Shows a text area. To use this field assign it to the `$uiControl` property.
      */
diff --git a/plugins/CorePluginsAdmin/angularjs/form-field/form-field.directive.js b/plugins/CorePluginsAdmin/angularjs/form-field/form-field.directive.js
index 821404e9e2..30d73fee7c 100644
--- a/plugins/CorePluginsAdmin/angularjs/form-field/form-field.directive.js
+++ b/plugins/CorePluginsAdmin/angularjs/form-field/form-field.directive.js
@@ -148,7 +148,7 @@
 
         function getTemplate(field) {
             var control = field.uiControl;
-            if (control === 'password') {
+            if (control === 'password' || control === 'url' || control === 'search' || control === 'email') {
                 control = 'text'; // we use same template for text and password both
             }
 
diff --git a/plugins/Morpheus/templates/demo.twig b/plugins/Morpheus/templates/demo.twig
index e1bb02ee60..84d6a2fec4 100644
--- a/plugins/Morpheus/templates/demo.twig
+++ b/plugins/Morpheus/templates/demo.twig
@@ -274,7 +274,7 @@
                      placeholder="Some text here">
                 </div>
 
-                <div piwik-field uicontrol="text" name="email"
+                <div piwik-field uicontrol="email" name="email"
                      title="Email"
                      inline-help="This is the inline help which provides more information.">
                 </div>
@@ -314,6 +314,9 @@
                      placeholder="Some text here...">
                 </div>
 
+                <div piwik-field uicontrol="url" name="urlText" title="URL" inline-help="URL field">
+                </div>
+
                 <div piwik-field uicontrol="textarea" name="description"
                      title="Description"
                      inline-help="This is a textarea. It automatically gets larger the more text is entered.">
@@ -375,7 +378,7 @@
           placeholder=&quot;Some text here&quot;&gt;
     &lt;/div&gt;
 
-    &lt;div piwik-field uicontrol=&quot;text&quot; name=&quot;email&quot;
+    &lt;div piwik-field uicontrol=&quot;email&quot; name=&quot;email&quot;
          title=&quot;Email&quot;
          inline-help=&quot;This is the inline help which provides more information.&quot;&gt;
     &lt;/div&gt;
@@ -415,6 +418,9 @@
          placeholder=&quot;Some text here...&quot;&gt;
     &lt;/div&gt;
 
+    &lt;div piwik-field uicontrol=&quot;url&quot; name=&quot;urlText&quot; title=&quot;URL&quot; inline-help=&quot;URL field&quot;&gt;
+    &lt;/div&gt;
+
     &lt;div piwik-field uicontrol=&quot;textarea&quot; name=&quot;description&quot;
          title=&quot;Description&quot;
          inline-help=&quot;This is a textarea. It automatically gets larger the more text is entered.&quot;&gt;
diff --git a/tests/UI/expected-screenshots/Morpheus_load.png b/tests/UI/expected-screenshots/Morpheus_load.png
index b124217687e591384596e086478ad1d5391dcac6..aa8dde73146e3630888aa9d17f4121497ab84516 100644
GIT binary patch
delta 85
zcmV~$yAgmO3;@uhWeP_iA40N(JD5Q3tnI8Bz>$4#mt8(N9nk~>C<o0er%9sBuG-O<
f`wFxk<TM&IN6w|N*hi=|6AP=){jLMRghlHQ-t87&

delta 85
zcmV~$yAgmO3;@uxWeP_i2_&$DJLE&|tnI8Bz>$4#AN%<D67nW86E%6QtPxIP8g30N
f+h{QtrPa>r>SiW`Kmtkn1mG;s{jL*Wa78RXJ}?*=

-- 
GitLab