jenkins-bot has submitted this change and it was merged.

Change subject: Add support for select widget
......................................................................


Add support for select widget

This allows the administrator of the campaign to show the user
certain options to select and the values for each option.

Change-Id: Ia47b66534d54b4c2f66aba4f0a0e935bd7109605
---
M UploadWizard.config.php
M includes/CampaignSchema.php
M resources/mw.UploadWizardDetails.js
3 files changed, 52 insertions(+), 10 deletions(-)

Approvals:
  Yuvipanda: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/UploadWizard.config.php b/UploadWizard.config.php
index 61e9d16..860cf99 100644
--- a/UploadWizard.config.php
+++ b/UploadWizard.config.php
@@ -141,7 +141,15 @@
                        'initialValue' => '',
 
                        // Set to true if this field is required
-                       'required' => false
+                       'required' => false,
+
+                       // Define the type of widget that will be rendered,
+                       // pick between text and select
+                       'type' => "text",
+
+                       // If the type above is select, provide a dictionary of
+                       // value -> label associations to display as options
+                       'options' => array(/* 'value' => 'label' */)
                )
        ),
 
diff --git a/includes/CampaignSchema.php b/includes/CampaignSchema.php
index 42c18d6..bce41a0 100644
--- a/includes/CampaignSchema.php
+++ b/includes/CampaignSchema.php
@@ -44,7 +44,17 @@
                                                ),
                                                "required" => array(
                                                        "type" => "boolean"
-                                               )
+                                               ),
+                                               "type" => array(
+                                                       "type" => "string"
+                                               ),
+                                               // Commented out because this 
is currently not
+                                               // supported in JsonSchema.php
+                                               /* "options" => array( */
+                                               /*      "type" => "object", */
+                                               /*      "properties" => 
array(), */
+                                               /*      "additionalProperties" 
=> true */
+                                               /* ) */
                                        )
                                )
                        )
diff --git a/resources/mw.UploadWizardDetails.js 
b/resources/mw.UploadWizardDetails.js
index ca407b0..2da3791 100644
--- a/resources/mw.UploadWizardDetails.js
+++ b/resources/mw.UploadWizardDetails.js
@@ -203,14 +203,38 @@
                if( field.wikitext ) {
                        var fieldInputId = "field_" + i + '_' + ( 
_this.upload.index ).toString();
 
-                       var $fieldInput = $( '<input type="text" />' ).attr( {
-                                       'id': fieldInputId,
-                                       'name': fieldInputId,
-                                       'class': 'mwe-idfield',
-                                       'maxlength': field.maxLength
-                               } )
-                               .val( field.initialValue )
-                               .data( 'field', field );
+                       if ( !( 'type' in field ) ) {
+                         field.type = 'text';
+                       }
+
+                       switch ( field.type ) {
+                               case 'select':
+                                       $fieldInput = $( '<select>' ).attr( {
+                                               'id': fieldInputId,
+                                               'name': fieldInputId,
+                                               'class': 'mwe-idfield'
+                                       } ).data( 'field', field );
+
+                                       if ( 'options' in field ) {
+                                               $.each( field.options, function 
( val, label ) {
+                                                       $fieldInput.append( $( 
'<option>' )
+                                                       .val( val )
+                                                       .text( label ) );
+                                               } );
+                                       }
+
+                               break;
+                               default:
+                                       var $fieldInput = $( '<input 
type="text">' ).attr( {
+                                               'id': fieldInputId,
+                                               'name': fieldInputId,
+                                               'class': 'mwe-idfield',
+                                               'maxlength': field.maxLength
+                                       } )
+                                       .val( field.initialValue )
+                                       .data( 'field', field );
+                               break;
+                       }
 
                        _this.$form.append(
                                $( '<div>' ).attr( 'class', 
'mwe-upwiz-details-input-error' )

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ia47b66534d54b4c2f66aba4f0a0e935bd7109605
Gerrit-PatchSet: 7
Gerrit-Project: mediawiki/extensions/UploadWizard
Gerrit-Branch: master
Gerrit-Owner: DMaggot <[email protected]>
Gerrit-Reviewer: Alex Monk <[email protected]>
Gerrit-Reviewer: DMaggot <[email protected]>
Gerrit-Reviewer: Platonides <[email protected]>
Gerrit-Reviewer: Yuvipanda <[email protected]>
Gerrit-Reviewer: jenkins-bot

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

Reply via email to