Pwirth has submitted this change and it was merged.
Change subject: CategoryBoxSelect: Added "tree-trigger"
......................................................................
CategoryBoxSelect: Added "tree-trigger"
... that opens a window with an BS.tree.Categories panel
NEEDS MERGE TO MASTER AND REL1_27
ATTENTION: A seperate change will add the I18N key to the appropriate RL
module. Leaving it out in this commit is just to ease merging to other
branches
Change-Id: I842ccb271c41870d9e4ba658dc83fa8c5798057e
---
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
7 files changed, 105 insertions(+), 2 deletions(-)
Approvals:
Pwirth: Verified; Looks good to me, approved
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 b5be4dd..04c73f3 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 d3a4337..db174b6 100644
--- a/resources/bluespice.extjs/bluespice.extjs.fixes.css
+++ b/resources/bluespice.extjs/bluespice.extjs.fixes.css
@@ -103,4 +103,8 @@
}
.bs-extjs-cssisready {
display: inline;
+}
+
+.bs-form-tree-trigger {
+ background-image: url(images/tree-trigger.png);
}
\ No newline at end of file
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/322859
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I842ccb271c41870d9e4ba658dc83fa8c5798057e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/BlueSpiceFoundation
Gerrit-Branch: REL1_23
Gerrit-Owner: Robert Vogel <[email protected]>
Gerrit-Reviewer: Dvogel hallowelt <[email protected]>
Gerrit-Reviewer: Ljonka <[email protected]>
Gerrit-Reviewer: Mglaser <[email protected]>
Gerrit-Reviewer: Pwirth <[email protected]>
Gerrit-Reviewer: Robert Vogel <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits