@@ -3,7 +3,7 @@ import Component, { ComponentAttrs } from '../../common/Component';
3
3
import SubtreeRetainer from '../../common/utils/SubtreeRetainer' ;
4
4
import Dropdown from '../../common/components/Dropdown' ;
5
5
import PostControls from '../utils/PostControls' ;
6
- import listItems from '../../common/helpers/listItems' ;
6
+ import listItems , { ModdedChildrenWithItemName } from '../../common/helpers/listItems' ;
7
7
import ItemList from '../../common/utils/ItemList' ;
8
8
import type PostModel from '../../common/models/Post' ;
9
9
import LoadingIndicator from '../../common/components/LoadingIndicator' ;
@@ -55,34 +55,46 @@ export default abstract class Post<CustomAttrs extends IPostAttrs = IPostAttrs>
55
55
56
56
return (
57
57
< article { ...attrs } >
58
- < div >
59
- { this . loading ? < LoadingIndicator /> : this . content ( ) }
60
- < aside className = "Post-actions" >
61
- < ul >
62
- { listItems ( this . actionItems ( ) . toArray ( ) ) }
63
- { ! ! controls . length && (
64
- < li >
65
- < Dropdown
66
- className = "Post-controls"
67
- buttonClassName = "Button Button--icon Button--flat"
68
- menuClassName = "Dropdown-menu--right"
69
- icon = "fas fa-ellipsis-h"
70
- onshow = { ( ) => this . $ ( '.Post-controls' ) . addClass ( 'open' ) }
71
- onhide = { ( ) => this . $ ( '.Post-controls' ) . removeClass ( 'open' ) }
72
- accessibleToggleLabel = { app . translator . trans ( 'core.forum.post_controls.toggle_dropdown_accessible_label' ) }
73
- >
74
- { controls }
75
- </ Dropdown >
76
- </ li >
77
- ) }
78
- </ ul >
79
- </ aside >
80
- < footer className = "Post-footer" > { footerItems . length ? < ul > { listItems ( footerItems ) } </ ul > : null } </ footer >
81
- </ div >
58
+ < div > { this . viewItems ( controls , footerItems ) . toArray ( ) } </ div >
82
59
</ article >
83
60
) ;
84
61
}
85
62
63
+ viewItems ( controls : Mithril . Children [ ] , footerItems : ModdedChildrenWithItemName [ ] ) : ItemList < Mithril . Children > {
64
+ const items = new ItemList < Mithril . Children > ( ) ;
65
+
66
+ items . add ( 'content' , this . loading ? < LoadingIndicator /> : this . content ( ) , 100 ) ;
67
+
68
+ items . add (
69
+ 'actions' ,
70
+ < aside className = "Post-actions" >
71
+ < ul >
72
+ { listItems ( this . actionItems ( ) . toArray ( ) ) }
73
+ { ! ! controls . length && (
74
+ < li >
75
+ < Dropdown
76
+ className = "Post-controls"
77
+ buttonClassName = "Button Button--icon Button--flat"
78
+ menuClassName = "Dropdown-menu--right"
79
+ icon = "fas fa-ellipsis-h"
80
+ onshow = { ( ) => this . $ ( '.Post-controls' ) . addClass ( 'open' ) }
81
+ onhide = { ( ) => this . $ ( '.Post-controls' ) . removeClass ( 'open' ) }
82
+ accessibleToggleLabel = { app . translator . trans ( 'core.forum.post_controls.toggle_dropdown_accessible_label' ) }
83
+ >
84
+ { controls }
85
+ </ Dropdown >
86
+ </ li >
87
+ ) }
88
+ </ ul >
89
+ </ aside > ,
90
+ 90
91
+ ) ;
92
+
93
+ items . add ( 'footer' , < footer className = "Post-footer" > { footerItems . length > 0 ? < ul > { listItems ( footerItems ) } </ ul > : < ul > </ ul > } </ footer > , 80 ) ;
94
+
95
+ return items ;
96
+ }
97
+
86
98
onbeforeupdate ( vnode : Mithril . VnodeDOM < CustomAttrs , this> ) {
87
99
super . onbeforeupdate ( vnode ) ;
88
100
@@ -147,7 +159,7 @@ export default abstract class Post<CustomAttrs extends IPostAttrs = IPostAttrs>
147
159
/**
148
160
* Build an item list for the post's footer.
149
161
*/
150
- footerItems ( ) : ItemList < Mithril . Children > {
151
- return new ItemList ( ) ;
162
+ footerItems ( ) : ItemList < ModdedChildrenWithItemName > {
163
+ return new ItemList < ModdedChildrenWithItemName > ( ) ;
152
164
}
153
165
}
0 commit comments