jenkins-bot has submitted this change and it was merged.
Change subject: BSApiFileBackendStore: Changes due to extendability and param
handling
......................................................................
BSApiFileBackendStore: Changes due to extendability and param handling
* Requires I357ff620b318c6057a2339cd9f824d557877ea01
* Moved getLicense method to IsertFile class and removed old
InsertFileAJAXBackend class
Patch-Set2:
* Added BSInsertFileInsertBaseDialogAfterInit trigger to InsertFile base dialog
Patch-Set3:
* Moved upload field to top in upload dlg
Patch-Set4:
* Now using BS.model.File
* Now using grid filter feature and default filtering
Patch-Set5:
* Implemented filter reset
* Changed icon rendering
Change-Id: If4a90e9f65924c86ac77d9fa9b62219982f91683
---
M InsertFile/InsertFile.class.php
M InsertFile/InsertFile.setup.php
D InsertFile/includes/InsertFileAJAXBackend.php
M InsertFile/resources/BS.InsertFile/BaseDialog.js
M InsertFile/resources/BS.InsertFile/FileDialog.js
M InsertFile/resources/BS.InsertFile/ImageDialog.js
M InsertFile/resources/BS.InsertFile/UploadPanel.js
M InsertFile/resources/bluespice.insertFile.css
8 files changed, 96 insertions(+), 61 deletions(-)
Approvals:
Robert Vogel: Looks good to me, approved
jenkins-bot: Verified
diff --git a/InsertFile/InsertFile.class.php b/InsertFile/InsertFile.class.php
index 90dcdd9..d269b53 100644
--- a/InsertFile/InsertFile.class.php
+++ b/InsertFile/InsertFile.class.php
@@ -117,4 +117,10 @@
return true;
}
+ //There is an api action "licences" in mw 2.24, but it is described as
+ //"Get media license dropdown HTML."
+ public static function getLicenses() {
+ $oLicenses = new JsonLicenses();
+ return $oLicenses->getJsonOutput();
+ }
}
\ No newline at end of file
diff --git a/InsertFile/InsertFile.setup.php b/InsertFile/InsertFile.setup.php
index c7340c5..2520031 100644
--- a/InsertFile/InsertFile.setup.php
+++ b/InsertFile/InsertFile.setup.php
@@ -8,9 +8,8 @@
$GLOBALS['wgAutoloadClasses']['InsertFile'] = __DIR__ .
'/InsertFile.class.php';
$wgAutoloadClasses['JsonLicenses'] = __DIR__ .
'/includes/JsonLicenses.php';
-$wgAutoloadClasses['InsertFileAJAXBackend'] = __DIR__ .
'/includes/InsertFileAJAXBackend.php';
-$wgAjaxExportList[] = 'InsertFileAJAXBackend::getLicenses';
+$wgAjaxExportList[] = 'InsertFile::getLicenses';
$aResourceModuleTemplate = array(
'localBasePath' => __DIR__ . '/resources',
diff --git a/InsertFile/includes/InsertFileAJAXBackend.php
b/InsertFile/includes/InsertFileAJAXBackend.php
deleted file mode 100644
index 2302a47..0000000
--- a/InsertFile/includes/InsertFileAJAXBackend.php
+++ /dev/null
@@ -1,11 +0,0 @@
-<?php
-
-class InsertFileAJAXBackend {
-
- //There is an api action "licences" in mw 2.24, but it is described as
- //"Get media license dropdown HTML."
- public static function getLicenses() {
- $oLicenses = new JsonLicenses();
- return $oLicenses->getJsonOutput();
- }
-}
\ No newline at end of file
diff --git a/InsertFile/resources/BS.InsertFile/BaseDialog.js
b/InsertFile/resources/BS.InsertFile/BaseDialog.js
index 280ad85..6dab624 100644
--- a/InsertFile/resources/BS.InsertFile/BaseDialog.js
+++ b/InsertFile/resources/BS.InsertFile/BaseDialog.js
@@ -2,8 +2,14 @@
extend: 'BS.Window',
requires: [
'Ext.data.Store', 'Ext.form.TextField',
'Ext.ux.form.SearchField',
- 'BS.InsertFile.UploadDialog', 'Ext.Button',
'Ext.toolbar.Toolbar',
- 'Ext.grid.Panel', 'Ext.form.Panel'
+ 'Ext.Button', 'Ext.toolbar.Toolbar', 'Ext.grid.Panel',
'Ext.form.Panel',
+ 'Ext.ux.grid.FiltersFeature',
+ //Unfortunately 'Ext.ux.grid.FiltersFeature' only 'uses' those
classes, but not 'requires' them...
+ 'Ext.ux.grid.menu.ListMenu', 'Ext.ux.grid.menu.RangeMenu',
+ 'Ext.ux.grid.filter.BooleanFilter',
'Ext.ux.grid.filter.DateFilter',
+ 'Ext.ux.grid.filter.DateTimeFilter',
'Ext.ux.grid.filter.ListFilter',
+ 'Ext.ux.grid.filter.NumericFilter',
'Ext.ux.grid.filter.StringFilter',
+ 'BS.InsertFile.UploadDialog', 'BS.model.File'
],
modal: true,
bodyPadding: 0,
@@ -33,28 +39,33 @@
afterInitComponent: function() {
this.conf = {
columns: {
- items: [{
- dataIndex: 'img_thumbnail',
+ items: [
+ {
+ dataIndex: 'file_thumbnail_url',
renderer: this.renderThumb,
width: 56,
- sortable: false
+ sortable: false,
+ filterable: false
},{
text:
mw.message('bs-insertfile-filename').plain(),
- dataIndex: 'img_name',
+ dataIndex: 'file_display_text',
flex: 1
},{
text:
mw.message('bs-insertfile-filesize').plain(),
- dataIndex: 'img_size',
+ dataIndex: 'file_size',
renderer:this.renderSize,
width: 100
},{
text:
mw.message('bs-insertfile-lastmodified').plain(),
- dataIndex: 'page_touched',
+ dataIndex: 'file_timestamp',
renderer:this.renderLastModified,
- width: 150
- }],
+ width: 150,
+ filterable: false //TODO: Use
DateTimeFilter (needs to be supported by BSF)
+ }
+ ],
defaults: {
- tdCls: 'bs-if-cell'
+ tdCls: 'bs-if-cell',
+ filterable: true
}
}
};
@@ -63,37 +74,30 @@
height: 200,
buffered: true, // allow the grid to interact with the
paging scroller by buffering
pageSize: 20,
- leadingBufferZone: 60,
+ leadingBufferZone: 20,
proxy: {
type: 'ajax',
url: mw.util.wikiScript('api'),
reader: {
type: 'json',
root: 'results',
- idProperty: 'img_name',
+ idProperty: 'file_name',
totalProperty: 'total'
},
extraParams: {
format: 'json',
- action: 'bs-filebackend-store',
- filter: Ext.encode([{
- type: 'string',
- comparison: 'eq',
- field: 'img_major_mime',
- value: this.storeFileType
- }])
+ action: 'bs-filebackend-store'
}
},
remoteFilter: true,
autoLoad: true,
- fields: ['img_name', 'page_touched', 'img_thumbnail',
'img_size', 'img_width', 'img_height' ],
+ model: 'BS.model.File',
sortInfo: {
- field: 'page_touched',
+ field: 'file_timestamp',
direction: 'ASC'
}
});
this.stImageGrid.on( 'load', this.onStImageGridLoad, this );
-
this.sfFilter = Ext.create( 'Ext.ux.form.SearchField', {
fieldLabel:
mw.message('bs-insertfile-labelfilter').plain(),
@@ -138,12 +142,15 @@
items: toolBarItems
});
+ var filterFeature = this.makeGridFilterFeatureConfig();
+
this.gdImages = Ext.create('Ext.grid.Panel', {
region: 'center',
collapsible: false,
store: this.stImageGrid,
loadMask: true,
dockedItems: this.tbGridTools,
+ features: [ new
Ext.ux.grid.FiltersFeature(filterFeature) ],
selModel: {
pruneRemoved: false
},
@@ -155,6 +162,9 @@
});
this.gdImages.on( 'select', this.onGdImagesSelect, this );
+ this.gdImages.on( 'afterrender', function(){
+ this.gdImages.filters.createFilters(); //This is
required to have out default filters be applied on load!
+ }, this );
this.tfFileName = Ext.create('Ext.form.TextField', {
readOnly: true,
@@ -177,6 +187,7 @@
this.pnlConfig
];
+ $(document).trigger("BSInsertFileInsertBaseDialogAfterInit",
[this, this.items]);
this.callParent(arguments);
},
@@ -201,6 +212,7 @@
dlgUploadOKClick: function( dialog, upload ){
this.stImageGrid.reload();
+ this.resetFilters();
this.sfFilter.setValue( upload.filename );
},
@@ -219,6 +231,7 @@
this.tfLinkText.reset();
if( obj.title ) {
+ this.resetFilters();
this.tfFileName.setValue( obj.title );
this.sfFilter.setValue( obj.title );
this.sfFilter.onTrigger2Click();
@@ -235,8 +248,13 @@
this.callParent( arguments );
},
- renderThumb: function( url ) {
- return '<img src="'+url+'" height="48" width="48" />';
+ renderThumb: function( url, meta, record ) {
+ var attribs = {
+ class: 'bs-insertfile-icon',
+ style: 'background-image:url('+url+')'
+ };
+
+ return mw.html.element( 'div', attribs );
},
renderSize: function( size ){
@@ -244,16 +262,11 @@
},
renderLastModified: function( lastmod ){
- //mw timestamp to date params
- var aDate = lastmod.match(new RegExp('.{1,2}', 'g'));
- return Ext.Date.format(
- new Date(aDate[0] + aDate[1], aDate[2], aDate[3],
aDate[4], aDate[5], aDate[6] ),
- 'd.m.Y G:i'
- );
+ return Ext.Date.format( lastmod, 'd.m.Y G:i' );
},
onGdImagesSelect: function( grid, record, index, eOpts ){
- this.tfFileName.setValue( record.get('img_name') );
+ this.tfFileName.setValue( record.get('file_name') );
this.pnlConfig.expand();
},
@@ -263,5 +276,26 @@
return selectedRecords[0];
}
return null;
+ },
+
+ makeGridFilterFeatureConfig: function() {
+ return {
+ ftype: 'filters',
+ encode: true,
+ autoReload: true,
+ filters: [
+ {
+ active: true,
+ dataIndex: 'file_mimetype',
+ type: 'string',
+ value: { 'nct': 'image/' }
//unfortunately there is no "not starts with"
+ }
+ ]
+ };
+ },
+
+ resetFilters: function () {
+ this.gdImages.filters.clearFilters(); //We disable all
filters...
+
this.gdImages.filters.getFilter('file_mimetype').setActive(true);//... and
reenable the mime_type filter to have normal behavior
}
});
diff --git a/InsertFile/resources/BS.InsertFile/FileDialog.js
b/InsertFile/resources/BS.InsertFile/FileDialog.js
index 2e2ccd6..2a4c579 100644
--- a/InsertFile/resources/BS.InsertFile/FileDialog.js
+++ b/InsertFile/resources/BS.InsertFile/FileDialog.js
@@ -16,12 +16,6 @@
},
afterInitComponent: function() {
this.callParent(arguments);
- this.stImageGrid.proxy.extraParams.filter = Ext.encode([{
- type: 'string',
- comparison: 'neq',
- field: 'img_major_mime',
- value: 'image'
- }]);
},
onPnlConfigExpand: function(panel, eOpts){
this.callParent(arguments);
diff --git a/InsertFile/resources/BS.InsertFile/ImageDialog.js
b/InsertFile/resources/BS.InsertFile/ImageDialog.js
index 2f70661..76cd16e 100644
--- a/InsertFile/resources/BS.InsertFile/ImageDialog.js
+++ b/InsertFile/resources/BS.InsertFile/ImageDialog.js
@@ -170,8 +170,8 @@
if( this.nbWidth.getValue() === null &&
this.nbHeight.getValue() === null ) {
var record = records[0];
this.isSetData = true;
- this.nbWidth.setValue(+record.get('img_width'));
-
this.nbHeight.setValue(+record.get('img_height'));
+
this.nbWidth.setValue(+record.get('file_width'));
+
this.nbHeight.setValue(+record.get('file_height'));
this.isSetData = false;
}
}
@@ -195,8 +195,8 @@
if ((w === 0 && h === 0) || record === null ) {
return 0;
}
- var orgW = record.get('img_width');
- var orgH = record.get('img_height');
+ var orgW = record.get('file_width');
+ var orgH = record.get('file_height');
if (w === 0) {
return Math.round(orgW / (orgH / h));
@@ -271,7 +271,7 @@
var height = this.nbHeight.getValue();
var width = this.nbWidth.getValue();
- if( height != record.get('img_height') || width !=
record.get('img_width') ) {
+ if( height != record.get('file_height') || width !=
record.get('file_width') ) {
cfg.sizeheight = height;
cfg.sizewidth = width;
}
@@ -352,12 +352,12 @@
onGdImagesSelect: function( grid, record, index, eOpts ){
this.callParent(arguments);
- this.hdnUrl.setValue( record.get('img_thumbnail') );
+ this.hdnUrl.setValue( record.get('file_thumbnail_url') );
//This is to avoid an overriding of the dimension that may have
been
//set by this.setData()
if( grid.getStore().filters.items.length === 0 ||
grid.getStore().getCount() !== 1 ) {
- this.nbWidth.setValue( record.get('img_width') );
- this.nbHeight.setValue( record.get('img_height') );
+ this.nbWidth.setValue( record.get('file_width') );
+ this.nbHeight.setValue( record.get('file_height') );
}
$(document).trigger("BSInsertFileInsertImageDialogAfterImageSelect", [this,
grid, record, index]);
},
@@ -381,5 +381,11 @@
else {
this.tfLinkText.disable();
}
+ },
+
+ makeGridFilterFeatureConfig: function() {
+ var filtersCfg = this.callParent( arguments );
+ filtersCfg.filters[0].value = { 'sw': 'image/' }; //Set to
"starts with"; value is 'image/' defined by base class
+ return filtersCfg;
}
});
\ No newline at end of file
diff --git a/InsertFile/resources/BS.InsertFile/UploadPanel.js
b/InsertFile/resources/BS.InsertFile/UploadPanel.js
index 6064f9e..6589008 100644
--- a/InsertFile/resources/BS.InsertFile/UploadPanel.js
+++ b/InsertFile/resources/BS.InsertFile/UploadPanel.js
@@ -60,7 +60,7 @@
this.storeLicenses = Ext.create( 'Ext.data.Store', {
proxy: {
type: 'ajax',
- url:
bs.util.getAjaxDispatcherUrl('InsertFileAJAXBackend::getLicenses'),
+ url:
bs.util.getAjaxDispatcherUrl('InsertFile::getLicenses'),
reader: {
type: 'json',
root: 'items',
@@ -140,8 +140,8 @@
});
this.panelItems = [
- this.tfFileName,
this.fuFile,
+ this.tfFileName,
this.fsDetails
];
var detailsItems = [
diff --git a/InsertFile/resources/bluespice.insertFile.css
b/InsertFile/resources/bluespice.insertFile.css
index d13deb3..3bf1757 100644
--- a/InsertFile/resources/bluespice.insertFile.css
+++ b/InsertFile/resources/bluespice.insertFile.css
@@ -32,4 +32,11 @@
.bs-ve-image.thumb.center {
width: auto;
+}
+
+.bs-insertfile-icon {
+ width: 48px;
+ height: 48px;
+ background-position: center center;
+ background-repeat: no-repeat;
}
\ No newline at end of file
--
To view, visit https://gerrit.wikimedia.org/r/208967
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: If4a90e9f65924c86ac77d9fa9b62219982f91683
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/extensions/BlueSpiceExtensions
Gerrit-Branch: master
Gerrit-Owner: Pwirth <[email protected]>
Gerrit-Reviewer: Mglaser <[email protected]>
Gerrit-Reviewer: Robert Vogel <[email protected]>
Gerrit-Reviewer: Tweichart <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits