z_mirror/TaskList
git clone https://git.raiguard.me/z_mirror/TaskList
fa77a7d
task-details-gui
1local constants =require ( "constants" ) 2 3local templates ={} 4 5--- @param name string 6--- @param visible boolean|nil 7function templates . checkboxes_flow ( name , visible ) 8return { 9type ="flow" , 10direction ="vertical" , 11ref ={ name .. "_flow" } , 12{ type ="flow" , name ="incompleted" , direction ="vertical" , visible =false } , 13{ type ="flow" , name ="completed" , direction ="vertical" , visible =false } , 14visible =visible , 15} 16end 17 18--- @param sprite string 19--- @param tooltip LocalisedString|nil 20--- @param action table|nil 21--- @param ref table|nil 22function templates . frame_action_button ( sprite , tooltip , action , ref ) 23return { 24type ="sprite-button" , 25style ="frame_action_button" , 26sprite =sprite .. "_white" , 27hovered_sprite =sprite .. "_black" , 28clicked_sprite =sprite .. "_black" , 29tooltip =tooltip , 30ref =ref , 31actions ={ 32on_click =action , 33} , 34} 35end 36 37--- @param Task Task 38--- @param gui_ident string|GuiIdent 39--- @param index number|nil 40--- @param completed boolean 41function templates . task_item ( Task , gui_ident , index , completed ) 42return { 43type ="flow" , 44name =Task . id , 45direction ="vertical" , 46index =index or nil , 47{ 48type ="flow" , 49style_mods ={ vertical_align ="center" } , 50{ 51type ="checkbox" , 52style_mods ={ horizontally_stretchable =true , horizontally_squashable =true } , 53caption =Task . title , 54state =completed , 55actions ={ 56on_checked_state_changed ={ gui =gui_ident , action ="toggle_task_completed" , task_id =Task . id } , 57} , 58} , 59{ 60type ="label" , 61style ="info_label" , 62caption =Task . assignee and Task . assignee . name or nil , 63visible =Task . assignee and true or false , 64} , 65{ 66type ="sprite" , 67style ="flib_indicator" , 68sprite ="flib_indicator_" .. constants . task_status [ Task . status ]. color , 69tooltip =constants . task_status [ Task . status ]. label , 70actions ={ 71on_click ={ gui =gui_ident , action ="cycle_task_status" , task_id =Task . id } , 72} , 73} , 74{ 75type ="sprite-button" , 76style ="mini_button_aligned_to_text_vertically_when_centered" , 77sprite ="utility/rename_icon_small_black" , 78tooltip ={ "gui.tlst-edit-task" } , 79mouse_button_filter ={ "left" , "middle" } , 80actions ={ 81on_click ={ 82gui =gui_ident , 83action ="edit_task" , 84task_id =Task . id , 85parent_task_id =Task . owner . object_name == "Task" and Task . owner . id or nil , 86} , 87} , 88} , 89{ 90type ="sprite-button" , 91style ="mini_button_aligned_to_text_vertically_when_centered" , 92sprite ="tlst_arrow_right" , 93tooltip ={ "gui.tlst-expand-tooltip" } , 94mouse_button_filter ={ "left" , "middle" } , 95actions ={ 96on_click ={ gui =gui_ident , transform ="handle_expand_click" , task_id =Task . id } , 97} , 98} , 99} , 100{ 101type ="flow" , 102name ="details_flow" , 103style_mods ={ left_margin =22 } , 104direction ="vertical" , 105visible =false , 106{ 107type ="label" , 108style_mods ={ font_color =constants . description_color , single_line =false } , 109caption =Task . description , 110visible =# Task . description > 0 , 111} , 112{ 113type ="flow" , 114name ="subtasks_flow" , 115direction ="vertical" , 116{ type ="flow" , name ="incompleted" , direction ="vertical" , visible =false } , 117{ type ="flow" , name ="completed" , direction ="vertical" , visible =false } , 118{ 119type ="flow" , 120style_mods ={ padding =0 , margin =0 , horizontal_spacing =8 } , 121{ 122type ="sprite-button" , 123style ="mini_button_aligned_to_text_vertically" , 124sprite ="utility/add" , 125tooltip ={ "gui.tlst-add-subtask" } , 126actions ={ 127on_click ={ gui =gui_ident , action ="edit_task" , parent_task_id =Task . id } , 128} , 129} , 130{ type ="label" , caption ={ "gui.tlst-add-subtask" } } , 131} , 132} , 133} , 134} 135end 136 137return templates