Santhosh has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/353215 )

Change subject: CX2: Categories: Use MenuTagMultiselectWidget widget
......................................................................

CX2: Categories: Use MenuTagMultiselectWidget widget

Use MenuTagMultiselectWidget instead of CapsuleMultiselectWidget.

Bug: T134740
Change-Id: Ia444b8b483367e7a42af94c8931a5e9c9d696ec9
---
M extension.json
M i18n/en.json
M i18n/qqq.json
M modules/ui/mw.cx.ui.Categories.js
4 files changed, 16 insertions(+), 12 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/15/353215/1

diff --git a/extension.json b/extension.json
index a451c91..a7cfde8 100644
--- a/extension.json
+++ b/extension.json
@@ -1700,6 +1700,7 @@
                                "mw.cx.ui"
                        ],
                        "messages": [
+                               "cx-tools-category-add",
                                "cx-tools-categories-count-message"
                        ]
                },
diff --git a/i18n/en.json b/i18n/en.json
index bd8d113..8854428 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -219,5 +219,6 @@
        "cx-template-not-available": "Not available in $1",
        "cx-translation-template-add-param": "+ Translate field",
        "cx-translation-template-add-more": "Add more fields",
-       "cx-translation-template-select-param": "Select target fields"
+       "cx-translation-template-select-param": "Select target fields",
+       "cx-tools-category-add": "Add category"
 }
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 5b03326..42180bf 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -227,5 +227,6 @@
        "cx-template-not-available": "Text shown when a corresponding template 
not available in target language\n* $1 - Target language name",
        "cx-translation-template-add-param": "Hover text for the template field 
placeholders. Shown in the form for translating the template fields. \"Field\" 
should be the same word as in 
{{msg-mw|visualeditor-dialog-transclusion-required-parameter-dialog-title}}.",
        "cx-translation-template-add-more": "Label for the control to add more 
template fields. Shown at the bottom of the form for translating the template 
parameters. \"Field\" should be the same word as in 
{{msg-mw|visualeditor-dialog-transclusion-required-parameter-dialog-title}}",
-       "cx-translation-template-select-param": "Label for the template field 
selector. \"Field\" should be the same word as in 
{{msg-mw|visualeditor-dialog-transclusion-required-parameter-dialog-title}}"
+       "cx-translation-template-select-param": "Label for the template field 
selector. \"Field\" should be the same word as in 
{{msg-mw|visualeditor-dialog-transclusion-required-parameter-dialog-title}}",
+       "cx-tools-category-add": "Placeholder text for adding new category to 
translation"
 }
diff --git a/modules/ui/mw.cx.ui.Categories.js 
b/modules/ui/mw.cx.ui.Categories.js
index fc96b86..c3db985 100644
--- a/modules/ui/mw.cx.ui.Categories.js
+++ b/modules/ui/mw.cx.ui.Categories.js
@@ -78,18 +78,18 @@
                        label: label
                } ) );
        }
-       this.categoryListing = new OO.ui.CapsuleMultiselectWidget( {
+       this.categoryListing = new OO.ui.MenuTagMultiselectWidget( {
                // Should we allow Arbitrary categories?
                allowArbitrary: true,
+               inputPosition: 'outline',
                icon: 'tag',
-               menu: {
-                       items: categoryItems
-               },
-               classes: [ 'cx-category-listing' ]
+               options: categoryItems,
+               selected: categoryItems.map( function ( item ) { return 
item.label; } ),
+               classes: [ 'cx-category-listing' ],
+               input: {
+                       placeholder: mw.msg( 'cx-tools-category-add' )
+               }
        } );
-
-       // Add all adapted items
-       this.categoryListing.addItemsFromData( categories );
 
        return this.categoryListing;
 };
@@ -104,9 +104,10 @@
        }.bind( this ) );
 
        if ( this.editable ) {
-               this.categoryListing.on( 'change', function () {
+               this.categoryListing.on( 'change', function ( items ) {
                        // The new set of categories. Update the page.
-                       this.page.categories = 
this.categoryListing.getItemsData();
+                       this.page.categories = items.map( function ( item ) { 
return item.data; } );
+                       // TODO: Remove the selected items from the options menu
                }.bind( this ) );
        }
 };

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia444b8b483367e7a42af94c8931a5e9c9d696ec9
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh <[email protected]>

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

Reply via email to