diff --git a/src/Material-Design-Lite-Widgets/Collection.extension.st b/src/Material-Design-Lite-Widgets/Collection.extension.st new file mode 100644 index 00000000..b0e10b2f --- /dev/null +++ b/src/Material-Design-Lite-Widgets/Collection.extension.st @@ -0,0 +1,10 @@ +Extension { #name : #Collection } + +{ #category : #'*Material-Design-Lite-Widgets' } +Collection >> selectMatchingFromMDLFilter: mdlFilter format: aFormatBlock with: aPattern [ + ^ self + select: [ :each | + mdlFilter + formatedElement: (aFormatBlock value: each) + matches: aPattern ] +] diff --git a/src/Material-Design-Lite-Widgets/MDLAbstractFilter.class.st b/src/Material-Design-Lite-Widgets/MDLAbstractFilter.class.st index 8cc0bb48..ef56df41 100644 --- a/src/Material-Design-Lite-Widgets/MDLAbstractFilter.class.st +++ b/src/Material-Design-Lite-Widgets/MDLAbstractFilter.class.st @@ -27,5 +27,13 @@ MDLAbstractFilter class >> isAbstract [ MDLAbstractFilter class >> selectMatchingFrom: aCollection format: aFormatBlock with: aPattern [ "I take as parameter a collection of elements to match, a block to get the readable format of the element and a pattern and I should return a collection of elements matching the pattern in their readable format." - ^ aCollection select: [ :each | self formatedElement: (aFormatBlock value: each) matches: aPattern ] + ^ aCollection selectMatchingFromMDLFilter: self format: aFormatBlock with: aPattern +] + +{ #category : #accessing } +MDLAbstractFilter class >> selectMatchingOnQueryCollection: aQueryCollection with: aFormatBlock like: aPattern [ + |newQuery| + newQuery := aQueryCollection copy. + self applySelectMatchingOnQueryCollection: newQuery with: aFormatBlock like: aPattern. + ^ newQuery ] diff --git a/src/Material-Design-Lite-Widgets/MDLBeginsWithFilter.class.st b/src/Material-Design-Lite-Widgets/MDLBeginsWithFilter.class.st index e53ee53e..0fa8ce04 100644 --- a/src/Material-Design-Lite-Widgets/MDLBeginsWithFilter.class.st +++ b/src/Material-Design-Lite-Widgets/MDLBeginsWithFilter.class.st @@ -4,9 +4,17 @@ I am a nested list filter keeping only elements whose name begins with the patte Class { #name : #MDLBeginsWithFilter, #superclass : #MDLAbstractFilter, - #category : 'Material-Design-Lite-Widgets-List' + #category : #'Material-Design-Lite-Widgets-List' } +{ #category : #accessing } +MDLBeginsWithFilter class >> applySelectMatchingOnQueryCollection: aQueryCollection with: aFormatBlock like: aPattern [ + + ^ aQueryCollection wrappedQuery + with: aFormatBlock + like: aPattern , '%' +] + { #category : #accessing } MDLBeginsWithFilter class >> formatedElement: aString matches: aPattern [ ^ aString beginsWith: aPattern diff --git a/src/Material-Design-Lite-Widgets/MDLInsensitiveBeginsWithFilter.class.st b/src/Material-Design-Lite-Widgets/MDLInsensitiveBeginsWithFilter.class.st index 4721f978..4ed9749b 100644 --- a/src/Material-Design-Lite-Widgets/MDLInsensitiveBeginsWithFilter.class.st +++ b/src/Material-Design-Lite-Widgets/MDLInsensitiveBeginsWithFilter.class.st @@ -4,9 +4,16 @@ I am a nested list filter keeping only elements whose name begins with the patte Class { #name : #MDLInsensitiveBeginsWithFilter, #superclass : #MDLAbstractFilter, - #category : 'Material-Design-Lite-Widgets-List' + #category : #'Material-Design-Lite-Widgets-List' } +{ #category : #accessing } +MDLInsensitiveBeginsWithFilter class >> applySelectMatchingOnQueryCollection: aQueryCollection with: aFormatBlock like: aPattern [ + ^ aQueryCollection wrappedQuery + with: aFormatBlock + ilike: aPattern , '%' +] + { #category : #accessing } MDLInsensitiveBeginsWithFilter class >> formatedElement: aString matches: aPattern [ ^ aString asLowercase beginsWith: aPattern asLowercase diff --git a/src/Material-Design-Lite-Widgets/MDLInsensitiveSubstringFilter.class.st b/src/Material-Design-Lite-Widgets/MDLInsensitiveSubstringFilter.class.st index 1f2ed870..8058767b 100644 --- a/src/Material-Design-Lite-Widgets/MDLInsensitiveSubstringFilter.class.st +++ b/src/Material-Design-Lite-Widgets/MDLInsensitiveSubstringFilter.class.st @@ -4,9 +4,16 @@ I am a nested list filter keeping only elements whose name includes the pattern Class { #name : #MDLInsensitiveSubstringFilter, #superclass : #MDLAbstractFilter, - #category : 'Material-Design-Lite-Widgets-List' + #category : #'Material-Design-Lite-Widgets-List' } +{ #category : #accessing } +MDLInsensitiveSubstringFilter class >> applySelectMatchingOnQueryCollection: aQueryCollection with: aFormatBlock like: aPattern [ + ^ aQueryCollection wrappedQuery + with: aFormatBlock + iLike: '%' , aPattern asLowercase , '%' +] + { #category : #accessing } MDLInsensitiveSubstringFilter class >> formatedElement: aString matches: aPattern [ ^ aString asLowercase includesSubstring: aPattern asLowercase diff --git a/src/Material-Design-Lite-Widgets/MDLNestedListItemRenderAbstractStrategy.class.st b/src/Material-Design-Lite-Widgets/MDLNestedListItemRenderAbstractStrategy.class.st index 7d7fb49b..94d5c398 100644 --- a/src/Material-Design-Lite-Widgets/MDLNestedListItemRenderAbstractStrategy.class.st +++ b/src/Material-Design-Lite-Widgets/MDLNestedListItemRenderAbstractStrategy.class.st @@ -133,12 +133,17 @@ MDLNestedListItemRenderAbstractStrategy >> renderIcon: aBlock Of: anItem on: htm { #category : #rendering } MDLNestedListItemRenderAbstractStrategy >> renderItem: aNode index: anIndex inDiv: div indentedBy: anInteger on: html [ | htmlElement | - htmlElement := self getHtmlElementForNode: aNode inDiv: div index: anIndex indentedBy: anInteger on: html. + htmlElement := self + getHtmlElementForNode: aNode + inDiv: div + index: anIndex + indentedBy: anInteger + on: html. htmlElement with: [ html span class: #item; id: html nextId; - with: ((self format value: aNode element) ifEmpty: [ $  ]). + with: (((self format value: aNode element) ifNil: [ '' ]) ifEmpty: [ $  ]). self renderHelpOf: aNode element at: html lastId on: html ]. aNode children ifNotEmpty: [ html div diff --git a/src/Material-Design-Lite-Widgets/MDLPseudoRegexFilter.class.st b/src/Material-Design-Lite-Widgets/MDLPseudoRegexFilter.class.st index d35b35b5..57522539 100644 --- a/src/Material-Design-Lite-Widgets/MDLPseudoRegexFilter.class.st +++ b/src/Material-Design-Lite-Widgets/MDLPseudoRegexFilter.class.st @@ -4,7 +4,7 @@ I am a nested list filter keeping only elements whose name includes the pattern Class { #name : #MDLPseudoRegexFilter, #superclass : #MDLAbstractFilter, - #category : 'Material-Design-Lite-Widgets-List' + #category : #'Material-Design-Lite-Widgets-List' } { #category : #accessing } @@ -18,6 +18,11 @@ MDLPseudoRegexFilter class >> adaptPattern: aPattern [ ifFalse: [ s nextPutAll: '.*' ] ] ] +{ #category : #accessing } +MDLPseudoRegexFilter class >> applySelectMatchingOnQueryCollection: aQueryCollection with: aFormatBlock like: aPattern [ + self shouldBeImplemented. +] + { #category : #accessing } MDLPseudoRegexFilter class >> formatedElement: aString matches: aRegex [ ^ aRegex matches: aString @@ -25,7 +30,8 @@ MDLPseudoRegexFilter class >> formatedElement: aString matches: aRegex [ { #category : #accessing } MDLPseudoRegexFilter class >> selectMatchingFrom: aCollection format: aFormatBlock with: aPattern [ - | regex | - regex := (self adaptPattern: aPattern) asRegexIgnoringCase. - ^ aCollection select: [ :each | self formatedElement: (aFormatBlock value: each) matches: regex ] + ^ super + selectMatchingFrom: aCollection + format: aFormatBlock + with: (self adaptPattern: aPattern) asRegexIgnoringCase ] diff --git a/src/Material-Design-Lite-Widgets/MDLSubstringFilter.class.st b/src/Material-Design-Lite-Widgets/MDLSubstringFilter.class.st index ae38a5f9..bdd1f760 100644 --- a/src/Material-Design-Lite-Widgets/MDLSubstringFilter.class.st +++ b/src/Material-Design-Lite-Widgets/MDLSubstringFilter.class.st @@ -4,9 +4,16 @@ I am a nested list filter keeping only elements whose name includes the pattern Class { #name : #MDLSubstringFilter, #superclass : #MDLAbstractFilter, - #category : 'Material-Design-Lite-Widgets-List' + #category : #'Material-Design-Lite-Widgets-List' } +{ #category : #accessing } +MDLSubstringFilter class >> applySelectMatchingOnQueryCollection: aQueryCollection with: aFormatBlock like: aPattern [ + ^ aQueryCollection wrappedQuery + with: aFormatBlock + like: '%', aPattern , '%' +] + { #category : #accessing } MDLSubstringFilter class >> formatedElement: aString matches: aPattern [ ^ aString includesSubstring: aPattern