Cdentinger has submitted this change and it was merged.
Change subject: Use common operators in text filter
..
Use common operators in text filter
Also, set querystring on initial load, but don't flip '' to null.
Push some code around. Assumption that operators without a pipe
symbol had to be 'eq' looked like an error.
Change-Id: If27482d55d5ffec3ab96277635a14545c654fedf
---
M src/components/filters/text-filter/text-filter.js
1 file changed, 15 insertions(+), 23 deletions(-)
Approvals:
Cdentinger: Looks good to me, approved
jenkins-bot: Verified
diff --git a/src/components/filters/text-filter/text-filter.js
b/src/components/filters/text-filter/text-filter.js
index a977951..bf9adf7 100644
--- a/src/components/filters/text-filter/text-filter.js
+++ b/src/components/filters/text-filter/text-filter.js
@@ -1,54 +1,46 @@
define( [
'knockout',
- 'text!components/filters/text-filter/text-filter.html'
+ 'text!components/filters/text-filter/text-filter.html',
+ 'operators'
],
-function( ko, template ){
+function( ko, template, ops ){
function TextFilterViewModel( params ){
var self = this;
this.operators = [
- {
- value: 'eq',
- text: 'Exactly'
- },
- {
- value: 'fn|startswith',
- text: 'Starts with'
- },
- {
- value: 'fn|endswith',
- text: 'Ends with'
- },
- {
- value: 'fn|substringof',
- text: 'Contains'
- }
+ ops.eq,
+ ops.startswith,
+ ops.endswith,
+ ops.substringof
];
this.selectedOperator = ko.observable(
params.userChoices().operator || 'eq' );
this.value = ko.observable( params.userChoices().value || '' );
this.changed = function() {
+ var value = self.value();
+
params.userChoices( {
operator: self.selectedOperator(),
- value: self.value()
+ value: value
} );
- if ( self.value() === '' ) {
- params.queryString( null );
+ if ( value === '' ) {
+ params.queryString( '' );
return;
}
var parts = self.selectedOperator().split( '|' );
if ( parts.length === 1 ) {
- params.queryString( params.name + ' eq \'' +
self.value() + '\'' );
+ params.queryString( params.name + ' ' +
parts[0] + ' \'' + value + '\'' );
return;
}
- params.queryString( parts[1] + '(\'' + self.value() +
'\',' + params.name + ')' );
+ params.queryString( parts[1] + '(\'' + value + '\',' +
params.name + ')' );
};
this.selectedOperator.subscribe( this.changed );
this.value.subscribe( this.changed );
+ this.changed();
}
return { viewModel: TextFilterViewModel, template: template };
--
To view, visit https://gerrit.wikimedia.org/r/257205
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: If27482d55d5ffec3ab96277635a14545c654fedf
Gerrit-PatchSet: 4
Gerrit-Project: wikimedia/fundraising/dash
Gerrit-Branch: master
Gerrit-Owner: Ejegg
Gerrit-Reviewer: Cdentinger
Gerrit-Reviewer: jenkins-bot <>
___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits