diff --git a/modules/oe_webtools_analytics/oe_webtools_analytics.permissions.yml b/modules/oe_webtools_analytics/oe_webtools_analytics.permissions.yml new file mode 100644 index 00000000..3be57b9f --- /dev/null +++ b/modules/oe_webtools_analytics/oe_webtools_analytics.permissions.yml @@ -0,0 +1,3 @@ +administer webtools analytics: + title: 'Administer Webtools Analytics' + restrict access: false \ No newline at end of file diff --git a/modules/oe_webtools_analytics/oe_webtools_analytics.routing.yml b/modules/oe_webtools_analytics/oe_webtools_analytics.routing.yml index 681925e3..8381e090 100644 --- a/modules/oe_webtools_analytics/oe_webtools_analytics.routing.yml +++ b/modules/oe_webtools_analytics/oe_webtools_analytics.routing.yml @@ -4,4 +4,4 @@ oe_webtools_analytics.settings: _form: 'Drupal\oe_webtools_analytics\Form\WebtoolsAnalyticsSettingsForm' _title: 'Webtools Analytics settings' requirements: - _permission: 'administer site configuration' + _permission: 'administer webtools analytics' diff --git a/modules/oe_webtools_analytics/src/Form/WebtoolsAnalyticsSettingsForm.php b/modules/oe_webtools_analytics/src/Form/WebtoolsAnalyticsSettingsForm.php index 6bd6ac06..02214d9e 100644 --- a/modules/oe_webtools_analytics/src/Form/WebtoolsAnalyticsSettingsForm.php +++ b/modules/oe_webtools_analytics/src/Form/WebtoolsAnalyticsSettingsForm.php @@ -36,7 +36,7 @@ protected function getEditableConfigNames() { */ public function buildForm(array $form, FormStateInterface $form_state) { $form['siteID'] = [ - '#type' => 'textfield', + '#type' => 'number', '#title' => $this->t('Site ID'), '#default_value' => $this->config(static::CONFIGNAME)->get('siteID'), '#description' => $this->t('The site unique numeric identifier.'), @@ -56,18 +56,6 @@ public function buildForm(array $form, FormStateInterface $form_state) { return parent::buildForm($form, $form_state); } - /** - * {@inheritdoc} - */ - public function validateForm(array &$form, FormStateInterface $form_state) { - parent::validateForm($form, $form_state); - - $site_id = $form_state->getValue('siteID'); - if (!is_numeric($site_id)) { - $form_state->setErrorByName('siteID', $this->t('The value must be numeric.')); - } - } - /** * {@inheritdoc} */ diff --git a/tests/features/analytics.feature b/tests/features/analytics.feature index 783300ba..42d5f47c 100644 --- a/tests/features/analytics.feature +++ b/tests/features/analytics.feature @@ -10,11 +10,6 @@ Feature: Webtools Analytics Scenario: Create Webtools Analytics settings Given I am on "admin/config/system/oe_webtools_analytics" Then I should see "Webtools Analytics settings" - When I fill in "Site ID" with "INFO" - And I fill in "Site path" with "ec.europa.eu/info" - And I fill in "Instance" with "ec.europa.eu" - And I press "Save configuration" - Then I should see the message "The value must be numeric." When I fill in "Site ID" with "123456" And I fill in "Site path" with "ec.europa.eu/info" And I fill in "Instance" with "ec.europa.eu"