Skip to content

Commit

Permalink
Lepiter card: add Spotter button [feenkcom/gtoolkit#3847]
Browse files Browse the repository at this point in the history
  • Loading branch information
JurajKubelka committed Jun 27, 2024
1 parent 075a95a commit aa8d09f
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 1 deletion.
52 changes: 52 additions & 0 deletions src/GToolkit-World/GtHomeLepiterKnowledgeBaseSpotterStart.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
Class {
#name : #GtHomeLepiterKnowledgeBaseSpotterStart,
#superclass : #Object,
#instVars : [
'databaseProvider'
],
#category : #'GToolkit-World-Helpers'
}

{ #category : #accessing }
GtHomeLepiterKnowledgeBaseSpotterStart >> database [
<return: #LeDatabase>
^ self databaseProvider database
]

{ #category : #accessing }
GtHomeLepiterKnowledgeBaseSpotterStart >> databaseProvider [
^ databaseProvider
]

{ #category : #accessing }
GtHomeLepiterKnowledgeBaseSpotterStart >> databaseProvider: anObject [
"Database provider is an object that understand #database"

databaseProvider := anObject
]

{ #category : #searching }
GtHomeLepiterKnowledgeBaseSpotterStart >> gtSpotterForPagesByContentFor: aSearch [
<gtSearch>
^ aSearch explicit
priority: 23;
title: 'Page contents';
search: [ :aContext | self database asyncPagesContainingText: aContext searchQuery ];
itemName: #spotterItemName
]

{ #category : #searching }
GtHomeLepiterKnowledgeBaseSpotterStart >> gtSpotterForPagesFor: aSearch [
<gtSearch>
^ aSearch explicit
title: 'Named pages';
priority: 1;
search: [ :aContext | self database asyncPagesForWord: aContext searchQuery ];
itemName: #title;
wantsToDisplayOnEmptyQuery: false
]

{ #category : #printing }
GtHomeLepiterKnowledgeBaseSpotterStart >> printOn: aStream [
aStream nextPutAll: 'Spotter'
]
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,12 @@ GtHomeLepiterKnowledgeBaseTabGroupElement >> initialize [

{ #category : #initialization }
GtHomeLepiterKnowledgeBaseTabGroupElement >> initializeTabGroupElement [
tabGroupElement := BrTabGroup new aptitude: BrGlamorousTabGroupAptitude new
tabGroupElement := BrTabGroup new
aptitude: BrGlamorousTabGroupAptitude new;
actionbarStencil: [ BrToolbar new
aptitude: BrGlamorousToolbarAptitude new;
addItem: self searchButton;
yourself ]
]

{ #category : #'api - ui model' }
Expand Down Expand Up @@ -105,6 +110,34 @@ GtHomeLepiterKnowledgeBaseTabGroupElement >> removeTableOfContentsTab [
tocTab := nil
]

{ #category : #'private - updating' }
GtHomeLepiterKnowledgeBaseTabGroupElement >> searchButton [
^ GtSpotterDropdownButtonStencil new
beMiniSize;
valuable: (GtHomeLepiterKnowledgeBaseSpotterStart new databaseProvider: self);
tooltip: 'Search Pages';
objectActOn: [ :anActOnEvent :anItem :theButton |
self spawnPage: anItem from: theButton.
anActOnEvent beActed.
theButton fireEvent: BrDropdownHideWish new ];
asElement
]

{ #category : #'event handling' }
GtHomeLepiterKnowledgeBaseTabGroupElement >> spawnPage: aPage from: aButton [
"If we are in a pager, spawn the page in the current phlow, else create a new pager."

^ aButton
allParentsDetect: [ :aParent | aParent isKindOf: GtPager ]
ifFound: [ :aParent | aButton phlow spawnTool: aPage asPhlowTool ]
ifNone: [
GtWorldUtility
showSpaceWithTitle: aPage title
inPagerWith: [ aPage asLepiterPagePhlowTool asElementDo: [ :e | e ] ]
asStencil
from: aButton ]
]

{ #category : #'private - subscriptions' }
GtHomeLepiterKnowledgeBaseTabGroupElement >> subscribeToContent [
"Subclasses can subscribe to what they are interested in.
Expand Down

0 comments on commit aa8d09f

Please sign in to comment.