Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions app/application.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2141,6 +2141,10 @@ let render_source state =
Reference_sources.find_opt id state.reference_sources)
;;

let render_title state =
Journal_model.Title.render ~lookup:(fun id -> Reference_sources.find_opt id state.reference_sources)
;;

let favorites_view
~render_source
~render_media
Expand Down Expand Up @@ -2466,6 +2470,7 @@ let timeline_page
~timeline_store
~on_region
~render_source
~render_title
~render_media
~render_row_media
~platform
Expand Down Expand Up @@ -2523,6 +2528,7 @@ let timeline_page
?store:timeline_store
~on_region
~render_source
~render_title
~render_media:render_row_media
~state:timeline_state
~day_presentation
Expand Down Expand Up @@ -3057,11 +3063,13 @@ let detail_page
let field ~key name value =
V.column ~spacing:4. ~alignment:Leading
[ V.of_lui (Lui_elements.text ~value:name ~style_class:"caption" ~foreground:"secondary" [])
; Journal_header.detail_text ~id:key ~depth:2 (render_source state value) ]
; Journal_header.detail_text ~title:(render_title state value)
~on_reference:(fun id -> local.send (Detail_open id)) ~id:key ~depth:2 value ]
in
let text =
if property_value then field ~key:id (Option.value property_name ~default:"Property") source
else Journal_header.detail_text ~id ~depth (render_source state source)
else Journal_header.detail_text ~title:(render_title state source)
~on_reference:(fun id -> local.send (Detail_open id)) ~id ~depth source
in
let fields = List.map (fun (name, value) ->
field ~key:("detail-property:" ^ Journal_model.id block ^ ":" ^ name) name value) named_sources in
Expand Down Expand Up @@ -6685,6 +6693,7 @@ let start
~timeline_store:(Some timeline_store)
~on_region:on_view_region
~render_source:(render_source state)
~render_title:(render_title state)
~render_media:
(media_label ~store:media_store ~on_region:on_view_region state dispatch)
~render_row_media:(fun ~title ~root ~image_children child ->
Expand Down Expand Up @@ -7388,6 +7397,7 @@ module For_testing = struct
~timeline_store:None
~on_region:(fun _ -> ())
~render_source:(render_source initial_state)
~render_title:(render_title initial_state)
~render_media:
(media_label
~store:(Journal_media_view.Store.create ())
Expand Down
1 change: 1 addition & 0 deletions app/dune
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
rrbvec
base
core
mldoc
lui
ocaml-signal
datascript-ocaml-native
Expand Down
38 changes: 30 additions & 8 deletions app/journal_header.ml
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,36 @@ let bottom_controls ~key ~controls body =
|> V.Body.static
;;

let detail_text ~id ~depth text =
Ui.Native_widget.widget
chrome
~key:(Ui.Key.string ("detail-label:" ^ id))
~props:(props ~mode:"detail-text" ~id ~level:(min 2 depth) ~text ())
~on_event:(fun _ -> ())
~children:[]
()
(* The same wire representation drives bounded previews and unbounded Detail. *)
let title_text ?on_reference ~mode ?id ~level ?max_lines title =
let fields = ["mode", `String mode; "text", `String (Journal_model.Title.plain title);
"runs", Journal_model.Title.to_yojson title; "level", `Int level]
@ Option.to_list (Option.map (fun id -> "id", `String id) id)
@ Option.to_list (Option.map (fun n -> "maxLines", `Int n) max_lines) in
let on_event (event : Journal_lui_native.event) =
match on_reference with
| None -> ()
| Some open_reference ->
(try match Yojson.Safe.from_string event.payload with
| `Assoc [("reference", `String id)]
when Journal_validation.is_uuid id
&& List.exists (fun (run : Journal_model.Title.run) -> run.reference = Some id) title ->
open_reference id
| _ -> () with _ -> ())
in
V.of_lui (Journal_lui_native.mount ?key:(Option.map (fun id -> "detail-label:" ^ id) id)
~payload:(Yojson.Safe.to_string (`Assoc fields)) ~children:[] ~on_event
Journal_lui_native.chrome_identifier)
;;

let detail_text ?title ?on_reference ~id ~depth text =
title_text ?on_reference ~mode:"detail-text" ~id ~level:(min 2 depth)
(match title with Some title -> title | None -> Journal_model.Title.render text)
;;

let bounded_text ?on_reference ~child title =
title_text ?on_reference ~mode:"bounded-text" ~level:(if child then 1 else 0)
~max_lines:(if child then 2 else 4) title
;;

let detail_row ~depth body =
Expand Down
3 changes: 2 additions & 1 deletion app/journal_header.mli
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ val feedback

val date_header : ?relative_label:string -> title:string -> unit -> Journal_view.View.t

val detail_text : id:string -> depth:int -> string -> Journal_view.View.t
val detail_text : ?title:Journal_model.Title.t -> ?on_reference:(string -> unit) -> id:string -> depth:int -> string -> Journal_view.View.t
val bounded_text : ?on_reference:(string -> unit) -> child:bool -> Journal_model.Title.t -> Journal_view.View.t
val detail_row : depth:int -> Journal_view.View.t -> Journal_view.View.t

val detail
Expand Down
2 changes: 1 addition & 1 deletion app/journal_lui_native.ml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ let registry =
in
register_component
registry
(component chrome_identifier apple_profiles true children [ payload_property ] []);
(component chrome_identifier apple_profiles true children [ payload_property ] [ event_schema ]);
register_component
registry
(component
Expand Down
Loading
Loading