Skip to content

Commit d8227c6

Browse files
authored
Merge pull request #318 from DuneSt/feat/allow-override-filter
feat: allow override filter to work on specific collection
2 parents 374d738 + e58f7e9 commit d8227c6

8 files changed

+69
-11
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Extension { #name : #Collection }
2+
3+
{ #category : #'*Material-Design-Lite-Widgets' }
4+
Collection >> selectMatchingFromMDLFilter: mdlFilter format: aFormatBlock with: aPattern [
5+
^ self
6+
select: [ :each |
7+
mdlFilter
8+
formatedElement: (aFormatBlock value: each)
9+
matches: aPattern ]
10+
]

src/Material-Design-Lite-Widgets/MDLAbstractFilter.class.st

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,13 @@ MDLAbstractFilter class >> isAbstract [
2727
MDLAbstractFilter class >> selectMatchingFrom: aCollection format: aFormatBlock with: aPattern [
2828
"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."
2929

30-
^ aCollection select: [ :each | self formatedElement: (aFormatBlock value: each) matches: aPattern ]
30+
^ aCollection selectMatchingFromMDLFilter: self format: aFormatBlock with: aPattern
31+
]
32+
33+
{ #category : #accessing }
34+
MDLAbstractFilter class >> selectMatchingOnQueryCollection: aQueryCollection with: aFormatBlock like: aPattern [
35+
|newQuery|
36+
newQuery := aQueryCollection copy.
37+
self applySelectMatchingOnQueryCollection: newQuery with: aFormatBlock like: aPattern.
38+
^ newQuery
3139
]

src/Material-Design-Lite-Widgets/MDLBeginsWithFilter.class.st

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,17 @@ I am a nested list filter keeping only elements whose name begins with the patte
44
Class {
55
#name : #MDLBeginsWithFilter,
66
#superclass : #MDLAbstractFilter,
7-
#category : 'Material-Design-Lite-Widgets-List'
7+
#category : #'Material-Design-Lite-Widgets-List'
88
}
99

10+
{ #category : #accessing }
11+
MDLBeginsWithFilter class >> applySelectMatchingOnQueryCollection: aQueryCollection with: aFormatBlock like: aPattern [
12+
13+
^ aQueryCollection wrappedQuery
14+
with: aFormatBlock
15+
like: aPattern , '%'
16+
]
17+
1018
{ #category : #accessing }
1119
MDLBeginsWithFilter class >> formatedElement: aString matches: aPattern [
1220
^ aString beginsWith: aPattern

src/Material-Design-Lite-Widgets/MDLInsensitiveBeginsWithFilter.class.st

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,16 @@ I am a nested list filter keeping only elements whose name begins with the patte
44
Class {
55
#name : #MDLInsensitiveBeginsWithFilter,
66
#superclass : #MDLAbstractFilter,
7-
#category : 'Material-Design-Lite-Widgets-List'
7+
#category : #'Material-Design-Lite-Widgets-List'
88
}
99

10+
{ #category : #accessing }
11+
MDLInsensitiveBeginsWithFilter class >> applySelectMatchingOnQueryCollection: aQueryCollection with: aFormatBlock like: aPattern [
12+
^ aQueryCollection wrappedQuery
13+
with: aFormatBlock
14+
ilike: aPattern , '%'
15+
]
16+
1017
{ #category : #accessing }
1118
MDLInsensitiveBeginsWithFilter class >> formatedElement: aString matches: aPattern [
1219
^ aString asLowercase beginsWith: aPattern asLowercase

src/Material-Design-Lite-Widgets/MDLInsensitiveSubstringFilter.class.st

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,16 @@ I am a nested list filter keeping only elements whose name includes the pattern
44
Class {
55
#name : #MDLInsensitiveSubstringFilter,
66
#superclass : #MDLAbstractFilter,
7-
#category : 'Material-Design-Lite-Widgets-List'
7+
#category : #'Material-Design-Lite-Widgets-List'
88
}
99

10+
{ #category : #accessing }
11+
MDLInsensitiveSubstringFilter class >> applySelectMatchingOnQueryCollection: aQueryCollection with: aFormatBlock like: aPattern [
12+
^ aQueryCollection wrappedQuery
13+
with: aFormatBlock
14+
iLike: '%' , aPattern asLowercase , '%'
15+
]
16+
1017
{ #category : #accessing }
1118
MDLInsensitiveSubstringFilter class >> formatedElement: aString matches: aPattern [
1219
^ aString asLowercase includesSubstring: aPattern asLowercase

src/Material-Design-Lite-Widgets/MDLNestedListItemRenderAbstractStrategy.class.st

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,17 @@ MDLNestedListItemRenderAbstractStrategy >> renderIcon: aBlock Of: anItem on: htm
133133
{ #category : #rendering }
134134
MDLNestedListItemRenderAbstractStrategy >> renderItem: aNode index: anIndex inDiv: div indentedBy: anInteger on: html [
135135
| htmlElement |
136-
htmlElement := self getHtmlElementForNode: aNode inDiv: div index: anIndex indentedBy: anInteger on: html.
136+
htmlElement := self
137+
getHtmlElementForNode: aNode
138+
inDiv: div
139+
index: anIndex
140+
indentedBy: anInteger
141+
on: html.
137142
htmlElement
138143
with: [ html span
139144
class: #item;
140145
id: html nextId;
141-
with: ((self format value: aNode element) ifEmpty: [ $  ]).
146+
with: (((self format value: aNode element) ifNil: [ '' ]) ifEmpty: [ $  ]).
142147
self renderHelpOf: aNode element at: html lastId on: html ].
143148
aNode children
144149
ifNotEmpty: [ html div

src/Material-Design-Lite-Widgets/MDLPseudoRegexFilter.class.st

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ I am a nested list filter keeping only elements whose name includes the pattern
44
Class {
55
#name : #MDLPseudoRegexFilter,
66
#superclass : #MDLAbstractFilter,
7-
#category : 'Material-Design-Lite-Widgets-List'
7+
#category : #'Material-Design-Lite-Widgets-List'
88
}
99

1010
{ #category : #accessing }
@@ -18,14 +18,20 @@ MDLPseudoRegexFilter class >> adaptPattern: aPattern [
1818
ifFalse: [ s nextPutAll: '.*' ] ]
1919
]
2020

21+
{ #category : #accessing }
22+
MDLPseudoRegexFilter class >> applySelectMatchingOnQueryCollection: aQueryCollection with: aFormatBlock like: aPattern [
23+
self shouldBeImplemented.
24+
]
25+
2126
{ #category : #accessing }
2227
MDLPseudoRegexFilter class >> formatedElement: aString matches: aRegex [
2328
^ aRegex matches: aString
2429
]
2530

2631
{ #category : #accessing }
2732
MDLPseudoRegexFilter class >> selectMatchingFrom: aCollection format: aFormatBlock with: aPattern [
28-
| regex |
29-
regex := (self adaptPattern: aPattern) asRegexIgnoringCase.
30-
^ aCollection select: [ :each | self formatedElement: (aFormatBlock value: each) matches: regex ]
33+
^ super
34+
selectMatchingFrom: aCollection
35+
format: aFormatBlock
36+
with: (self adaptPattern: aPattern) asRegexIgnoringCase
3137
]

src/Material-Design-Lite-Widgets/MDLSubstringFilter.class.st

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,16 @@ I am a nested list filter keeping only elements whose name includes the pattern
44
Class {
55
#name : #MDLSubstringFilter,
66
#superclass : #MDLAbstractFilter,
7-
#category : 'Material-Design-Lite-Widgets-List'
7+
#category : #'Material-Design-Lite-Widgets-List'
88
}
99

10+
{ #category : #accessing }
11+
MDLSubstringFilter class >> applySelectMatchingOnQueryCollection: aQueryCollection with: aFormatBlock like: aPattern [
12+
^ aQueryCollection wrappedQuery
13+
with: aFormatBlock
14+
like: '%', aPattern , '%'
15+
]
16+
1017
{ #category : #accessing }
1118
MDLSubstringFilter class >> formatedElement: aString matches: aPattern [
1219
^ aString includesSubstring: aPattern

0 commit comments

Comments
 (0)