Robert Vogel has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/324735

Change subject: CategoryBoxSelect: Added "tree-trigger"
......................................................................

CategoryBoxSelect: Added "tree-trigger"

... that opens a window with an BS.tree.Categories panel

Manual merge of https://gerrit.wikimedia.org/r/#/c/322859/

Change-Id: I3020b5903859fabd5782a85fac12188fa304e939
---
M extension.json
M i18n/extjs/de.json
M i18n/extjs/en.json
M i18n/extjs/qqq.json
M resources/bluespice.extjs/BS/form/CategoryBoxSelect.js
A resources/bluespice.extjs/BS/tree/Categories.js
M resources/bluespice.extjs/bluespice.extjs.fixes.css
A resources/bluespice.extjs/images/tree-trigger.png
8 files changed, 108 insertions(+), 4 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/BlueSpiceFoundation 
refs/changes/35/324735/1

diff --git a/extension.json b/extension.json
index e45d1a6..93872ea 100644
--- a/extension.json
+++ b/extension.json
@@ -118,7 +118,8 @@
                 "bs-extjs-title-warning",
                 "bs-extjs-filter-bool-yes",
                 "bs-extjs-filter-bool-no",
-                "bs-extjs-categoryboxselect-emptytext"
+                "bs-extjs-categoryboxselect-emptytext",
+               "bs-extjs-categorytree-title"
             ],
             "dependencies": [
                 "ext.bluespice.extjs.theme.ux",
diff --git a/i18n/extjs/de.json b/i18n/extjs/de.json
index 7a11aee..db498de 100644
--- a/i18n/extjs/de.json
+++ b/i18n/extjs/de.json
@@ -46,5 +46,6 @@
        "bs-extjs-filter-bool-no": "nein",
        "bs-extjs-title-success": "Erfolg",
        "bs-extjs-title-warning": "Warnung",
-       "bs-extjs-categoryboxselect-emptytext": "Kategorie hinzuf├╝gen"
+       "bs-extjs-categoryboxselect-emptytext": "Kategorie hinzuf├╝gen",
+       "bs-extjs-categorytree-title": "Kategorien"
 }
diff --git a/i18n/extjs/en.json b/i18n/extjs/en.json
index bb973a3..eb8318a 100644
--- a/i18n/extjs/en.json
+++ b/i18n/extjs/en.json
@@ -46,5 +46,6 @@
        "bs-extjs-filter-bool-no": "no",
        "bs-extjs-title-success": "Success",
        "bs-extjs-title-warning": "Warning",
-       "bs-extjs-categoryboxselect-emptytext": "Add a category"
+       "bs-extjs-categoryboxselect-emptytext": "Add a category",
+       "bs-extjs-categorytree-title": "Categories"
 }
diff --git a/i18n/extjs/qqq.json b/i18n/extjs/qqq.json
index 6e32fca..7516bf9 100644
--- a/i18n/extjs/qqq.json
+++ b/i18n/extjs/qqq.json
@@ -50,4 +50,5 @@
        "bs-extjs-title-success": "Window title for 
success\n{{Identical|Success}}",
        "bs-extjs-title-warning": "Window title for 
warning\n{{Identical|Warning}}",
        "bs-extjs-categoryboxselect-emptytext": "The placeholder text of an 
input field that allows the definition of categories"
+       "bs-extjs-categorytree-title": "The title of a panel containing a tree 
view of the wiki's categories"
 }
diff --git a/resources/bluespice.extjs/BS/form/CategoryBoxSelect.js 
b/resources/bluespice.extjs/BS/form/CategoryBoxSelect.js
index 3ca91b1..88abb2a 100644
--- a/resources/bluespice.extjs/BS/form/CategoryBoxSelect.js
+++ b/resources/bluespice.extjs/BS/form/CategoryBoxSelect.js
@@ -15,7 +15,17 @@
        queryMode: 'local',
        emptyText: mw.message('bs-extjs-categoryboxselect-emptytext').plain(),
        delimiter: '|',
+
        deferredSetValueConf: false,
+       showTreeTrigger: false,
+
+       constructor: function( cfg ) {
+               if( cfg.showTreeTrigger ) {
+                       cfg.trigger2Cls = Ext.baseCSSPrefix + 
'form-search-trigger bs-form-tree-trigger';
+               }
+               this.callParent( [cfg] );
+       },
+
        initComponent: function() {
                this.store = Ext.create( 'Ext.data.JsonStore', {
                        proxy: {
@@ -74,5 +84,67 @@
                        callback: callback,
                        value: value
                };
+       },
+
+       onTrigger2Click : function( event ){
+        //lazy loading, as this trigger is optional
+        Ext.require( 'BS.tree.Categories', this.showTree, this );
+       },
+
+    wdTree: null,
+       showTree: function() {
+        if( !this.wdTree ) {
+            var categoryTree =  new BS.tree.Categories({
+                width: 250,
+                height: 300
+            });
+            categoryTree.on( 'itemclick', this.onTreeItemClick, this );
+            this.wdTree = new Ext.Window({
+                title: mw.message('bs-extjs-categorytree-title').plain(),
+                x: this.getX() + this.getWidth(),
+                y: this.getY() - 175,
+                               closeAction: 'hide',
+                items: [
+                    categoryTree
+                ]
+            });
+
+            this.wireUpWithContainerWindow();
+        }
+
+        this.wdTree.show();
+       },
+
+    onTreeItemClick: function( tree, record, item, index, e, eOpts ) {
+               if ( mw.config.get( 'BSInsertCategoryWithParents' ) ) {
+                       this.addValuesFromRecord( record );
+               }
+               else {
+                       this.addValue( [ record.data.text ] );
+               }
+       },
+
+       addValuesFromRecord: function ( record ) {
+               //parentNode is null if there is no parent, internalId "src" is 
the root of the categories
+               if ( typeof ( record.parentNode ) !== "null" && 
record.parentNode.internalId !== "src" ) {
+                       this.addValuesFromRecord( record.parentNode );
+               }
+               this.addValue( [ record.data.text ] );
+       },
+
+    /**
+        * This is a little bit tricky. If our CategoryBoxSelect field is 
within a window we need to close the tree
+        * window when the parent window closes. As the CategoryBoxSelect is 
not necessarily in a window we need some
+        * checks here
+     */
+    wireUpWithContainerWindow: function() {
+               var parentWindow = this.up( 'window' );
+               if( !parentWindow ) {
+                       return;
+               }
+
+               parentWindow.on( 'close', function() {
+                       this.wdTree.close();
+               }, this );
        }
-});
\ No newline at end of file
+});
diff --git a/resources/bluespice.extjs/BS/tree/Categories.js 
b/resources/bluespice.extjs/BS/tree/Categories.js
new file mode 100644
index 0000000..12d140f
--- /dev/null
+++ b/resources/bluespice.extjs/BS/tree/Categories.js
@@ -0,0 +1,24 @@
+Ext.define( 'BS.tree.Categories', {
+       extend: 'Ext.tree.Panel',
+       requires: [ 'BS.model.Category' ],
+       useArrows: true,
+       rootVisible: false,
+       displayField: 'text',
+
+       initComponent: function() {
+               this.store = new Ext.data.TreeStore({
+                       proxy: {
+                               type: 'ajax',
+                               url: 
bs.util.getCAIUrl('getAsyncCategoryTreeStoreData')
+                       },
+                       root: {
+                               text: 'Categories',
+                               id: 'src',
+                               expanded: true
+                       },
+                       model: 'BS.model.Category'
+               });
+
+               this.callParent( arguments );
+       }
+});
\ No newline at end of file
diff --git a/resources/bluespice.extjs/bluespice.extjs.fixes.css 
b/resources/bluespice.extjs/bluespice.extjs.fixes.css
index 40244e5..0d82373 100644
--- a/resources/bluespice.extjs/bluespice.extjs.fixes.css
+++ b/resources/bluespice.extjs/bluespice.extjs.fixes.css
@@ -101,3 +101,7 @@
 .x-boundlist-item {
        font-size: 13px;
 }
+
+.bs-form-tree-trigger {
+       background-image: url(images/tree-trigger.png);
+}
diff --git a/resources/bluespice.extjs/images/tree-trigger.png 
b/resources/bluespice.extjs/images/tree-trigger.png
new file mode 100644
index 0000000..490137d
--- /dev/null
+++ b/resources/bluespice.extjs/images/tree-trigger.png
Binary files differ

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3020b5903859fabd5782a85fac12188fa304e939
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/BlueSpiceFoundation
Gerrit-Branch: master
Gerrit-Owner: Robert Vogel <vo...@hallowelt.biz>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to