mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-30 12:31:41 +09:00
Delete button and some fixes
- Add delete task button - Fix update task item - Fix no tasks found visibility and tooltip
This commit is contained in:
@@ -80,6 +80,8 @@ confirm=Confirm
|
|||||||
confirm-tooltip=Save task
|
confirm-tooltip=Save task
|
||||||
discard=Discard
|
discard=Discard
|
||||||
discard-tooltip=Discard task/changes
|
discard-tooltip=Discard task/changes
|
||||||
|
delete=Delete
|
||||||
|
delete-tooltip=Delete task
|
||||||
close=Close
|
close=Close
|
||||||
close-tooltip=Close task details
|
close-tooltip=Close task details
|
||||||
edit=Edit task
|
edit=Edit task
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ local no_tasks_found =
|
|||||||
type = "label",
|
type = "label",
|
||||||
style = "bold_label",
|
style = "bold_label",
|
||||||
caption = {"", "[img=utility/warning_white] ", {"task-list.no-tasks"}},
|
caption = {"", "[img=utility/warning_white] ", {"task-list.no-tasks"}},
|
||||||
tooltip = "Add task"
|
tooltip = {"task-list.no-tasks-tooltip"}
|
||||||
}
|
}
|
||||||
return header
|
return header
|
||||||
end
|
end
|
||||||
@@ -250,6 +250,19 @@ local view_task_close_button =
|
|||||||
PlayerSelected:set(player, nil)
|
PlayerSelected:set(player, nil)
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
|
local view_task_delete_button =
|
||||||
|
Gui.element {
|
||||||
|
type = "button",
|
||||||
|
caption = {"", "[img=utility/trash] ", {"task-list.delete"}},
|
||||||
|
tooltip = {"task-list.delete-tooltip"},
|
||||||
|
style = "shortcut_bar_button_red"
|
||||||
|
}:style(Styles.footer_button):on_click(
|
||||||
|
function(player, _, _)
|
||||||
|
local selected = PlayerSelected:get(player)
|
||||||
|
PlayerSelected:set(player, nil)
|
||||||
|
Tasks.remove_task(selected)
|
||||||
|
end
|
||||||
|
)
|
||||||
|
|
||||||
local task_view_footer =
|
local task_view_footer =
|
||||||
Gui.element(
|
Gui.element(
|
||||||
@@ -267,7 +280,7 @@ local task_view_footer =
|
|||||||
label.style.single_line = false
|
label.style.single_line = false
|
||||||
|
|
||||||
local action_flow = subfooter_actions(footer)
|
local action_flow = subfooter_actions(footer)
|
||||||
|
view_task_delete_button(action_flow)
|
||||||
view_task_edit_button(action_flow)
|
view_task_edit_button(action_flow)
|
||||||
view_task_close_button(action_flow)
|
view_task_close_button(action_flow)
|
||||||
return footer
|
return footer
|
||||||
@@ -467,13 +480,14 @@ Gui.left_toolbar_button(
|
|||||||
local update_task = function(player, task_list_element, task_id)
|
local update_task = function(player, task_list_element, task_id)
|
||||||
local task = Tasks.get_task(task_id)
|
local task = Tasks.get_task(task_id)
|
||||||
local task_ids = Tasks.get_force_task_ids(player.force.name)
|
local task_ids = Tasks.get_force_task_ids(player.force.name)
|
||||||
|
-- Set visibility of the no_tasks_found element
|
||||||
|
task_list_element.parent.parent.no_tasks_found_element.visible = #task_ids == 0
|
||||||
|
|
||||||
-- Task no longer exists so should be removed from the list
|
-- Task no longer exists so should be removed from the list
|
||||||
if not task then
|
if not task then
|
||||||
task_list_element["task-" .. task_id] = nil
|
task_list_element["task-" .. task_id].destroy()
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
task_list_element.parent.parent.no_tasks_found_element.visible = #task_ids == 0
|
|
||||||
|
|
||||||
local element
|
local element
|
||||||
-- If task does not exist yet add it to the list
|
-- If task does not exist yet add it to the list
|
||||||
@@ -511,8 +525,10 @@ local update_task_view_footer = function(player, task_id)
|
|||||||
|
|
||||||
local message_element = view_flow.message
|
local message_element = view_flow.message
|
||||||
local edit_button_element = view_flow.actions[view_task_edit_button.name]
|
local edit_button_element = view_flow.actions[view_task_edit_button.name]
|
||||||
|
local delete_button_element = view_flow.actions[view_task_delete_button.name]
|
||||||
|
|
||||||
edit_button_element.visible = has_permission
|
edit_button_element.visible = has_permission
|
||||||
|
delete_button_element.visible = has_permission
|
||||||
message_element.caption = task.message
|
message_element.caption = task.message
|
||||||
|
|
||||||
local players_editing = table.get_keys(task.currently_editing)
|
local players_editing = table.get_keys(task.currently_editing)
|
||||||
|
|||||||
Reference in New Issue
Block a user