Skip to content

Commit

Permalink
delete filter button as a tooltip with a key combination [feenkcom/gt…
Browse files Browse the repository at this point in the history
  • Loading branch information
JurajKubelka committed Sep 26, 2024
1 parent 5463bcd commit 5eaa1f8
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
43 changes: 43 additions & 0 deletions src/GToolkit-Coder-UI/GtFilterItemsElement.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ GtFilterItemsElement >> addElementForFilterViewModel: aFilterViewModel [
c flow horizontal alignLeft ].

self addNavigationShortcutsTo: anElement.
self addRemoveButtonIconTo: anElement.

self addChild: anElement
]
Expand Down Expand Up @@ -53,6 +54,27 @@ GtFilterItemsElement >> addNewFilterElement [
self addChild: self newAddFilterButton as: #add
]

{ #category : #'private - updating' }
GtFilterItemsElement >> addRemoveButtonIconTo: anElement [
| aRemoveButton aKeyMap |
aKeyMap := 'Backspace | Delete'.
anElement clipChildren: false.
aRemoveButton := self newRemoveButton.
aRemoveButton visibility: BlVisibility gone.
aRemoveButton addAptitude: (BrGlamorousWithLabelTooltipAptitude
text: 'Remove'
keymap: aKeyMap).
aRemoveButton action: [ :aButton |
self onRemoveFilterViewModelOfElement: anElement from: aButton ].
anElement
when: BlMouseEnterEvent
do: [ :anEvent | aRemoveButton visibility: BlVisibility visible ].
anElement
when: BlMouseLeaveEvent
do: [ :anEvent | aRemoveButton visibility: BlVisibility gone ].
anElement addChild: aRemoveButton
]

{ #category : #'private - updating' }
GtFilterItemsElement >> createDropdownContent [
^ BrSimpleList new
Expand Down Expand Up @@ -97,6 +119,7 @@ GtFilterItemsElement >> initialize [
self hFitContentLimited.
self vFitContent.
self padding: (BlInsets all: 2).
self clipChildren: false.
self initializeEventHandlers.
]

Expand Down Expand Up @@ -147,6 +170,18 @@ GtFilterItemsElement >> newAddFilterHandleElement [
hExact: 20
]

{ #category : #'private - updating' }
GtFilterItemsElement >> newRemoveButton [
^ GtInspectorRoundButtonStencil mini asElement
icon: (BrPlusIconStencil close radius: 3) asElement;
zIndex: 10;
id: GtPagerClosePageButtonElementId;
constraintsDo: [ :c |
c ignoreByLayout.
c ignored horizontal alignCenterAt: 1.0.
c ignored vertical alignCenterAt: 0.0 ]
]

{ #category : #'api - filter view model' }
GtFilterItemsElement >> onFiltersViewModelChanged [
self updateItemsElement
Expand All @@ -157,6 +192,14 @@ GtFilterItemsElement >> onItemsChanged: anAnnouncement [
BlTaskAction enqueueElement: self action: [ self updateItemsElement ]
]

{ #category : #'private - updating' }
GtFilterItemsElement >> onRemoveFilterViewModelOfElement: anElement from: aButton [
anElement hasFilterViewModel ifFalse: [ ^ self ].
self hasFiltersViewModel ifFalse: [ ^ self ].

self filtersViewModel removeFilterViewModel: anElement filterViewModel
]

{ #category : #'event handling' }
GtFilterItemsElement >> onRemoveFilterViewModelWish: anEvent [
anEvent filterViewModel ifNil: [ ^ self ].
Expand Down
2 changes: 1 addition & 1 deletion src/GToolkit-Coder-UI/GtFilterNameElement.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ GtFilterNameElement >> initializeSettingsContainer [
GtFilterNameElement >> initializeShortcuts [
self
addShortcut: (BlShortcutWithAction new
combination: BlKeyCombination backspace;
combination: (BlKeyCombination backspace or: BlKeyCombination delete);
action: [ self requestRemoveFilter ])
]

Expand Down

0 comments on commit 5eaa1f8

Please sign in to comment.