jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/349315 )

Change subject: Add default value for datatype selector in SpecialNewProperty
......................................................................


Add default value for datatype selector in SpecialNewProperty

Bug: T138295
Change-Id: Ia91e96a6d9ebf88ae3df35944433412f5a2d2e65
---
M repo/i18n/en.json
M repo/i18n/qqq.json
M repo/includes/Specials/SpecialNewProperty.php
M repo/tests/phpunit/includes/Specials/SpecialNewPropertyTest.php
4 files changed, 20 insertions(+), 2 deletions(-)

Approvals:
  Daniel Kinzler: Looks good to me, but someone else must approve
  jenkins-bot: Verified
  Thiemo Mättig (WMDE): Looks good to me, approved



diff --git a/repo/i18n/en.json b/repo/i18n/en.json
index 900a426..6333786 100644
--- a/repo/i18n/en.json
+++ b/repo/i18n/en.json
@@ -186,6 +186,7 @@
        "wikibase-newproperty-datatype": "Data type:",
        "wikibase-newproperty-invalid-datatype": "Invalid data type specified.",
        "wikibase-newproperty-insufficient-data": "You need to fill at least 
either label, description or aliases.",
+       "wikibase-newproperty-pick-data-type": "(pick a data type)",
        "wikibase-description-helppage": "Help:Description",
        "wikibase-label-helppage": "Help:Label",
        "special-newitem": "Create a new item",
diff --git a/repo/i18n/qqq.json b/repo/i18n/qqq.json
index aee69df..aa77477 100644
--- a/repo/i18n/qqq.json
+++ b/repo/i18n/qqq.json
@@ -218,6 +218,7 @@
        "wikibase-newproperty-datatype": "Label for the data-type-dropdown 
holding the data type of the new property.\n{{Identical|Data type}}",
        "wikibase-newproperty-invalid-datatype": "Error message shown when the 
page gets an invalid datatype",
        "wikibase-newproperty-insufficient-data": "Error message shown when a 
user tries to create a property and didn't fill in enough data",
+       "wikibase-newproperty-pick-data-type": "Label for default value of data 
type selector asking user to pick a data type",
        "wikibase-description-helppage": "{{doc-important|Do not change the 
<code>Help:</code> part.}}\nThe name of the local help page about using and 
editing labels.",
        "wikibase-label-helppage": "{{doc-important|Do not change the 
<code>Help:</code> part.}}\nThe name of the local help page about using and 
editing descriptions.",
        "special-newitem": "{{doc-special|NewItem}}\nThe special page is for 
creating new items.\n{{Identical|Create new item}}",
diff --git a/repo/includes/Specials/SpecialNewProperty.php 
b/repo/includes/Specials/SpecialNewProperty.php
index 8a2ca47..66deef5 100644
--- a/repo/includes/Specials/SpecialNewProperty.php
+++ b/repo/includes/Specials/SpecialNewProperty.php
@@ -115,13 +115,19 @@
                        $this->getLanguage()->getCode()
                );
 
+               $options = [
+                       $this->msg( 'wikibase-newproperty-pick-data-type' 
)->text() => ''
+               ];
                $formFields[ self::FIELD_DATATYPE ] = [
                        'name' => self::FIELD_DATATYPE,
                        'type' => 'select',
-                       'default' => isset( $this->parts[2] ) ? $this->parts[2] 
: 'string',
-                       'options' => $selector->getOptionsArray(),
+                       'default' => isset( $this->parts[2] ) ? $this->parts[2] 
: '',
+                       'options' => array_merge( $options, 
$selector->getOptionsArray() ),
                        'id' => 'wb-newproperty-datatype',
                        'validation-callback' => function ( $dataType, 
$formData, $form ) {
+                               if ( $dataType === '' ) {
+                                       return false;
+                               }
                                if ( !$this->dataTypeExists( $dataType ) ) {
                                        return [ $this->msg( 
'wikibase-newproperty-invalid-datatype' )->text() ];
                                }
diff --git a/repo/tests/phpunit/includes/Specials/SpecialNewPropertyTest.php 
b/repo/tests/phpunit/includes/Specials/SpecialNewPropertyTest.php
index b41beef..327bdf5 100644
--- a/repo/tests/phpunit/includes/Specials/SpecialNewPropertyTest.php
+++ b/repo/tests/phpunit/includes/Specials/SpecialNewPropertyTest.php
@@ -208,6 +208,16 @@
                                ],
                                'you need to fill',
                        ],
+                       'empty datatype' => [
+                               [
+                                       SpecialNewProperty::FIELD_LANG => 'en',
+                                       SpecialNewProperty::FIELD_LABEL => 
'empty datatype label',
+                                       SpecialNewProperty::FIELD_DESCRIPTION 
=> 'desc',
+                                       SpecialNewProperty::FIELD_ALIASES => 
'a1|a2',
+                                       SpecialNewProperty::FIELD_DATATYPE => ' 
',
+                               ],
+                               'Invalid data type specified',
+                       ],
                ];
        }
 

-- 
To view, visit https://gerrit.wikimedia.org/r/349315
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ia91e96a6d9ebf88ae3df35944433412f5a2d2e65
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Ladsgroup <[email protected]>
Gerrit-Reviewer: Aude <[email protected]>
Gerrit-Reviewer: Bartosz Dziewoński <[email protected]>
Gerrit-Reviewer: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: Jonas Kress (WMDE) <[email protected]>
Gerrit-Reviewer: Ladsgroup <[email protected]>
Gerrit-Reviewer: Thiemo Mättig (WMDE) <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to