Skip to content

Commit 3f9be8e

Browse files
committed
GtPagerPageNavigationContext uses GtPhlowToolCommonViewModel [feenkcom/gtoolkit#3422]
1 parent 4024536 commit 3f9be8e

File tree

5 files changed

+96
-11
lines changed

5 files changed

+96
-11
lines changed

src/GToolkit-Pager/GtPagerPageNavigationContext.class.st

Lines changed: 72 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ Class {
22
#name : #GtPagerPageNavigationContext,
33
#superclass : #Object,
44
#instVars : [
5-
'pageSelectionContext',
65
'pagerPageModel',
76
'previousContext',
87
'pager',
@@ -17,9 +16,57 @@ GtPagerPageNavigationContext >> allPreviousContextsDo: aBlock [
1716
aContext withAllNavigationContextsDo: aBlock ]
1817
]
1918

19+
{ #category : #'gt - extensions' }
20+
GtPagerPageNavigationContext >> gtNavigationContextsFor: aView [
21+
<gtView>
22+
^ aView columnedList
23+
title: 'Navigations';
24+
items: [ self withAllNavigationContexts ];
25+
column: 'Index'
26+
text: [ :_ :anIndex | anIndex ]
27+
width: 40;
28+
column: 'Type' text: #toolType weight: 0.5;
29+
column: 'Tool' text: #toolElement;
30+
column: 'Object' text: #object
31+
]
32+
33+
{ #category : #'gt - extensions' }
34+
GtPagerPageNavigationContext >> gtOverview [
35+
^ {
36+
GtPhlowOverviewItem new
37+
name: 'Phlow view model';
38+
value: self phlowViewModel.
39+
GtPhlowOverviewItem new
40+
name: 'Tool type';
41+
value: self toolType.
42+
GtPhlowOverviewItem new
43+
name: 'Tool element';
44+
value: self toolElement.
45+
GtPhlowOverviewItem new
46+
name: 'Tool view model';
47+
value: self toolViewModel.
48+
GtPhlowOverviewItem new
49+
name: 'Tool model object';
50+
value: self object}
51+
]
52+
53+
{ #category : #'gt - extensions' }
54+
GtPagerPageNavigationContext >> gtOverviewFor: aView [
55+
<gtView>
56+
^ aView columnedList
57+
title: 'Overview';
58+
priority: 0;
59+
items: [ self gtOverview ];
60+
column: 'Name'
61+
text: #name
62+
weight: 0.3;
63+
column: 'Value' text: #description;
64+
send: #value
65+
]
66+
2067
{ #category : #accessing }
2168
GtPagerPageNavigationContext >> object [
22-
^ object
69+
^ self phlowViewModel ifNotNil: #object
2370
]
2471

2572
{ #category : #accessing }
@@ -49,6 +96,14 @@ GtPagerPageNavigationContext >> pagerPageModel: anObject [
4996
pagerPageModel := anObject
5097
]
5198

99+
{ #category : #accessing }
100+
GtPagerPageNavigationContext >> phlowViewModel [
101+
<return: #TGtPhlowToolViewModel>
102+
self pagerPageModel widgetDo: [ :aWidget |
103+
^ aWidget toolViewModel ].
104+
^ nil
105+
]
106+
52107
{ #category : #accessing }
53108
GtPagerPageNavigationContext >> previousContext [
54109
<return: #GtPagerPageNavigationContext or: nil>
@@ -68,6 +123,21 @@ GtPagerPageNavigationContext >> previousObjectDo: aDoBlock ifAbsent: anAbsentBlo
68123
^ anAbsentBlock value
69124
]
70125

126+
{ #category : #accessing }
127+
GtPagerPageNavigationContext >> toolElement [
128+
^ self phlowViewModel ifNotNil: #element
129+
]
130+
131+
{ #category : #accessing }
132+
GtPagerPageNavigationContext >> toolType [
133+
^ self phlowViewModel ifNotNil: #type
134+
]
135+
136+
{ #category : #accessing }
137+
GtPagerPageNavigationContext >> toolViewModel [
138+
^ self phlowViewModel ifNotNil: #viewModel
139+
]
140+
71141
{ #category : #'api - navigation' }
72142
GtPagerPageNavigationContext >> withAllNavigationContexts [
73143
^ Array streamContents: [ :aStream |

src/GToolkit-Pager/GtPagerPageSelectionContext.class.st

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ GtPagerPageSelectionContext >> afterPage: anElement [
3939
GtPagerPageSelectionContext >> asElementDo: aOneArgBlock [
4040
"Create a tool element and execute the block"
4141

42-
self tool context: self phlowContext.
42+
self tool contextWithNavigationContext: self navigationContext.
4343
self tool
4444
asToolElementDo: [ :anElement |
4545
| aWrapper |
@@ -55,7 +55,6 @@ GtPagerPageSelectionContext >> createNavigationContextWithPager: aGtPager [
5555
aFollowingContext := GtPagerPageNavigationContext new.
5656
aFollowingContext previousContext: aPreviousContext.
5757
aFollowingContext pager: aGtPager.
58-
aFollowingContext object: self object.
5958
self navigationContext: aFollowingContext
6059
]
6160

@@ -81,13 +80,6 @@ GtPagerPageSelectionContext >> navigationContext: anObject [
8180
navigationContext := anObject
8281
]
8382

84-
{ #category : #accessing }
85-
GtPagerPageSelectionContext >> phlowContext [
86-
<return: #GtPhlowContext>
87-
^ GtPhlowContext new
88-
navigationContext: self navigationContext
89-
]
90-
9183
{ #category : #accessing }
9284
GtPagerPageSelectionContext >> prepareForReusedNavigation [
9385
self tool ifNotNil: [ :aTool |

src/GToolkit-Pager/GtPagerWrapperElement.class.st

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,9 @@ GtPagerWrapperElement >> toolAreaIdentifier [
109109
GtPagerWrapperElement >> toolIdentificator [
110110
^ #tool
111111
]
112+
113+
{ #category : #'api - accessing' }
114+
GtPagerWrapperElement >> toolViewModel [
115+
<return: #TGtPhlowToolViewModel>
116+
^ self tool phlow toolViewModel
117+
]
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Extension { #name : #GtPhlowAbstractTool }
2+
3+
{ #category : #'*GToolkit-Pager' }
4+
GtPhlowAbstractTool >> contextWithNavigationContext: aNavigationContext [
5+
"Tools may use phlow context with the given navigation context"
6+
7+
8+
]
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Extension { #name : #GtPhlowCompositeTool }
2+
3+
{ #category : #'*GToolkit-Pager' }
4+
GtPhlowCompositeTool >> contextWithNavigationContext: aNavigationContext [
5+
"Tools may use phlow context with the given navigation context"
6+
7+
self tools
8+
do: [ :eachTool | eachTool contextWithNavigationContext: aNavigationContext ]
9+
]

0 commit comments

Comments
 (0)