@@ -113,10 +113,10 @@ func (b *RootContainer) OnMount(ctx app.Context) {
113
113
ctx .Dispatch (func (ctx app.Context ) {
114
114
if ! more {
115
115
log .Println ("*** Hiding update button..." )
116
- Hide ( "update-button" )
116
+ b . buttonUpdate . Visible = false
117
117
} else {
118
118
log .Println ("*** Showing update button..." )
119
- app . Window (). GetElementByID ( "update-button" ). Set ( "className" , LoadFlushesButtonCss )
119
+ b . buttonUpdate . Visible = true
120
120
}
121
121
if err != nil {
122
122
ShowErrorDiv (ctx , err , 2 )
@@ -184,12 +184,17 @@ func (b *RootContainer) GetList() app.UI {
184
184
185
185
type buttonUpdate struct {
186
186
app.Compo
187
- parent * RootContainer
187
+ parent * RootContainer
188
+ Visible bool
188
189
}
189
190
190
191
func (b * buttonUpdate ) Render () app.UI {
192
+ cls := InviCss
193
+ if b .Visible {
194
+ cls = LoadFlushesButtonCss
195
+ }
191
196
return app .Button ().Text ("Load More" ).OnClick (b .onClick ).Class (
192
- LoadFlushesButtonCss ).ID ("update-button" )
197
+ cls ).ID ("update-button" )
193
198
}
194
199
func (b * buttonUpdate ) onClick (ctx app.Context , e app.Event ) {
195
200
ShowLoading ("flushes-loading-update" )
@@ -199,10 +204,10 @@ func (b *buttonUpdate) onClick(ctx app.Context, e app.Event) {
199
204
ctx .Dispatch (func (ctx app.Context ) {
200
205
if ! more {
201
206
log .Println ("*** Hiding update button..." )
202
- Hide ( "update-button" )
207
+ b . Visible = false
203
208
} else {
204
209
log .Println ("*** Showing update button..." )
205
- app . Window (). GetElementByID ( "update-button" ). Set ( "className" , LoadFlushesButtonCss )
210
+ b . Visible = true
206
211
}
207
212
defer Hide ("flushes-loading-update" )
208
213
if result == nil {
@@ -553,19 +558,19 @@ func FlushTable(flushes []Flush) app.UI {
553
558
divs = append (divs ,
554
559
app .Div ().Body (
555
560
timeDiv (flush ),
556
- app .P ().Text ("Rating: " + strconv .Itoa (flush .Rating )),
561
+ app .P ().Text (strconv .Itoa (flush .Rating )+ " ⭐" ),
562
+ app .If (flush .PhoneUsed , func () app.UI {
563
+ return app .P ().Text ("📱 used" )
564
+ }),
565
+ app .If (flush .Note != "" , func () app.UI {
566
+ return app .P ().Text ("Note: " + flush .Note ).Class ("break-all italic" )
567
+ }),
557
568
app .Div ().Body (
558
569
& EditFlushButton {ID : flush .ID },
559
570
& RemoveFlushButton {ID : flush .ID },
560
571
& ConfirmRemoveFlushButton {ID : flush .ID },
561
572
& CancelRemoveFlushButton {ID : flush .ID },
562
573
).Class ("max-w-1/6 remove-flush-buttonz-div" ),
563
- app .If (flush .PhoneUsed , func () app.UI {
564
- return app .P ().Text ("Phone used" )
565
- }),
566
- app .If (flush .Note != "" , func () app.UI {
567
- return app .P ().Text ("Note: " + flush .Note ).Class ("break-all italic" )
568
- }),
569
574
).Class ("flex flex-col p-4 border-1 shadow-lg rounded-lg shadow-amber-800" ).ID ("div-" + flush .ID ),
570
575
)
571
576
}
@@ -579,19 +584,16 @@ func timeDiv(flush Flush) app.UI {
579
584
0 ,
580
585
64 ,
581
586
)
582
- if flush .TimeStart .Day () == flush .TimeEnd .Day () {
583
- return app .Div ().Body (
584
- app .P ().Text ("🧻 " ).Class ("font-bold inline" ),
585
- app .P ().Text (flushDuration + " minutes, " + flush .TimeStart .Format (
586
- "2006-01-02 15:04" )+ "-" + flush .TimeEnd .Format ("15:04" )).Class ("inline" ),
587
- )
588
- } else {
589
- return app .Div ().Body (
590
- app .P ().Text ("Time: " ).Class ("font-bold inline" ),
591
- app .P ().Text (flushDuration + " minutes, " + flush .TimeStart .Format (
592
- "2006-01-02 15:04" )+ " - " + flush .TimeEnd .Format ("2006-01-02 15:04" )).Class ("inline" ),
593
- )
587
+ timeFmt := "15:04"
588
+ if flush .TimeStart .Day () != flush .TimeEnd .Day () {
589
+ timeFmt = "2006-01-02 15:04"
594
590
}
591
+ return app .Div ().Body (
592
+ app .P ().Text ("🧻 " ).Class ("font-bold inline" ),
593
+ app .P ().
594
+ Text (flushDuration + " min, 📅 " + flush .TimeStart .Format ("2006-01-02 15:04" )+ " - " + flush .TimeEnd .Format (timeFmt )).
595
+ Class ("inline" ),
596
+ )
595
597
}
596
598
597
599
type RemoveFlushButton struct {
@@ -989,13 +991,14 @@ func StatsDiv(ctx app.Context) (app.UI, error) {
989
991
return nil , err
990
992
}
991
993
return app .Div ().Body (
992
- app .P ().Text ("Total flushes: " + strconv .Itoa (stats .FlushCount )),
993
- app .P ().Text ("Total time: " + strconv .Itoa (stats .TotalTime )+ " minutes" ),
994
- app .P ().Text ("Mean time: " + strconv .Itoa (stats .MeanTime )+ " minutes" ),
995
- app .P ().Text ("Mean rating: " + strconv .Itoa (stats .MeanRating )),
996
- app .P ().Text ("Times with phone used: " + strconv .Itoa (stats .PhoneUsedCount )),
997
- app .P ().Text ("Percent with phone used: " + strconv .Itoa (stats .PercentPhoneUsed )+ "%" ),
998
- ).Class ("flex flex-col p-4 border-1 shadow-lg rounded-lg font-bold shadow-amber-800" ),
994
+ app .P ().Text ("Total 🧻 -> " + strconv .Itoa (stats .FlushCount )),
995
+ app .P ().
996
+ Text ("Total ⏱️ -> " + strconv .Itoa (stats .TotalTime )+ " min (" + strconv .Itoa (stats .MeanTime )+ " min average)" ),
997
+ app .P ().Text ("Average ⭐ -> " + strconv .Itoa (stats .MeanRating )),
998
+ app .P ().
999
+ Text ("Times with 📱 -> " + strconv .Itoa (stats .PhoneUsedCount )+ " (" + strconv .Itoa (stats .PercentPhoneUsed )+ "%)" ),
1000
+ ).
1001
+ Class ("flex flex-col p-4 border-1 shadow-lg rounded-lg font-bold shadow-amber-800" ),
999
1002
nil
1000
1003
}
1001
1004
@@ -1020,7 +1023,7 @@ func (c *GiveFeedbackContainer) Render() app.UI {
1020
1023
app .P ().Text ("Feedback" ).Class ("font-bold" ),
1021
1024
app .Br (),
1022
1025
app .Textarea ().Placeholder ("your feedback" ).ID (
1023
- "feedback-text" ).MaxLength (300 ).Class ("p-2 rounded-lg" ).Rows (12 ).Cols (30 ),
1026
+ "feedback-text" ).MaxLength (300 ).Class ("p-2 rounded-lg" ).Rows (10 ).Cols (25 ),
1024
1027
app .Br (),
1025
1028
& SubmitFeedbackButton {},
1026
1029
& LoadingWidget {id : "new-feedback-loading" },
0 commit comments