jenkins-bot has submitted this change and it was merged.
Change subject: BSApiExtJSStoreBase: Implemted 'date' filter
......................................................................
BSApiExtJSStoreBase: Implemted 'date' filter
Adding implementation for ExtJS filter of type 'date'
Change-Id: I795bb89016c8be2d9c57b33ed138080784d27539
---
M includes/api/BSApiExtJSStoreBase.php
1 file changed, 33 insertions(+), 1 deletion(-)
Approvals:
Mglaser: Looks good to me, approved
Pwirth: Looks good to me, but someone else must approve
jenkins-bot: Verified
diff --git a/includes/api/BSApiExtJSStoreBase.php
b/includes/api/BSApiExtJSStoreBase.php
index 46b5fe2..d9ec7a9 100644
--- a/includes/api/BSApiExtJSStoreBase.php
+++ b/includes/api/BSApiExtJSStoreBase.php
@@ -328,7 +328,14 @@
return false;
}
}
- //TODO: Implement for type 'date' and 'datetime'
+
+ if( $oFilter->type == 'date' ) {
+ $bFilterApplies = $this->filterDate( $oFilter,
$aDataSet );
+ if( !$bFilterApplies ) {
+ return false;
+ }
+ }
+ //TODO: Implement for type 'datetime'
}
return true;
@@ -427,6 +434,31 @@
}
/**
+ * Performs filtering based on given filter of type date on a dataset
+ * "Ext.ux.grid.filter.DateFilter" by default sends filter value in
format
+ * of m/d/Y
+ * @param object $oFilter
+ * @param object $aDataSet
+ */
+ public function filterDate( $oFilter, $aDataSet ) {
+ $iFilterValue = strtotime( $oFilter->value ); // Format: "m/d/Y"
+ $iFieldValue = strtotime( $aDataSet->{$oFilter->field} ); //
Format "YmdHis", or something else...
+
+ switch( $oFilter->comparison ) {
+ case 'gt':
+ return $iFieldValue > $iFilterValue;
+ case 'lt':
+ return $iFieldValue < $iFilterValue;
+ case 'eq':
+ //We need to normalise the date on day-level
+ $iFieldValue = strtotime(
+ date( 'm/d/Y', $iFieldValue )
+ );
+ return $iFieldValue === $iFilterValue;
+ }
+ }
+
+ /**
* Applies pagination on the result
* @param array $aProcessedData The filtered result
* @return array a trimmed version of the result
--
To view, visit https://gerrit.wikimedia.org/r/269678
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I795bb89016c8be2d9c57b33ed138080784d27539
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/BlueSpiceFoundation
Gerrit-Branch: master
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: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits