mirror of
https://github.com/home-assistant/core.git
synced 2026-04-21 01:05:11 +00:00
Add collapse checklist field to Habitica create/update task actions (#150988)
This commit is contained in:
@@ -39,6 +39,7 @@ ATTR_ADD_CHECKLIST_ITEM = "add_checklist_item"
|
||||
ATTR_REMOVE_CHECKLIST_ITEM = "remove_checklist_item"
|
||||
ATTR_SCORE_CHECKLIST_ITEM = "score_checklist_item"
|
||||
ATTR_UNSCORE_CHECKLIST_ITEM = "unscore_checklist_item"
|
||||
ATTR_COLLAPSE_CHECKLIST = "collapse_checklist"
|
||||
ATTR_REMINDER = "reminder"
|
||||
ATTR_REMOVE_REMINDER = "remove_reminder"
|
||||
ATTR_CLEAR_REMINDER = "clear_reminder"
|
||||
|
||||
@@ -47,6 +47,7 @@ from .const import (
|
||||
ATTR_ALIAS,
|
||||
ATTR_CLEAR_DATE,
|
||||
ATTR_CLEAR_REMINDER,
|
||||
ATTR_COLLAPSE_CHECKLIST,
|
||||
ATTR_CONFIG_ENTRY,
|
||||
ATTR_COST,
|
||||
ATTR_COUNTER_DOWN,
|
||||
@@ -130,6 +131,11 @@ SERVICE_TRANSFORMATION_SCHEMA = vol.Schema(
|
||||
}
|
||||
)
|
||||
|
||||
COLLAPSE_CHECKLIST_MAP = {
|
||||
"collapsed": True,
|
||||
"expanded": False,
|
||||
}
|
||||
|
||||
BASE_TASK_SCHEMA = vol.Schema(
|
||||
{
|
||||
vol.Required(ATTR_CONFIG_ENTRY): ConfigEntrySelector(),
|
||||
@@ -160,6 +166,7 @@ BASE_TASK_SCHEMA = vol.Schema(
|
||||
vol.Optional(ATTR_REMOVE_CHECKLIST_ITEM): vol.All(cv.ensure_list, [str]),
|
||||
vol.Optional(ATTR_SCORE_CHECKLIST_ITEM): vol.All(cv.ensure_list, [str]),
|
||||
vol.Optional(ATTR_UNSCORE_CHECKLIST_ITEM): vol.All(cv.ensure_list, [str]),
|
||||
vol.Optional(ATTR_COLLAPSE_CHECKLIST): vol.In(COLLAPSE_CHECKLIST_MAP),
|
||||
vol.Optional(ATTR_START_DATE): cv.date,
|
||||
vol.Optional(ATTR_INTERVAL): vol.All(int, vol.Range(0)),
|
||||
vol.Optional(ATTR_REPEAT): vol.All(cv.ensure_list, [vol.In(WEEK_DAYS)]),
|
||||
@@ -223,6 +230,7 @@ ITEMID_MAP = {
|
||||
"shiny_seed": Skill.SHINY_SEED,
|
||||
}
|
||||
|
||||
|
||||
SERVICE_TASK_TYPE_MAP = {
|
||||
SERVICE_UPDATE_REWARD: TaskType.REWARD,
|
||||
SERVICE_CREATE_REWARD: TaskType.REWARD,
|
||||
@@ -714,6 +722,9 @@ async def _create_or_update_task(call: ServiceCall) -> ServiceResponse: # noqa:
|
||||
):
|
||||
data["checklist"] = checklist
|
||||
|
||||
if collapse_checklist := call.data.get(ATTR_COLLAPSE_CHECKLIST):
|
||||
data["collapseChecklist"] = COLLAPSE_CHECKLIST_MAP[collapse_checklist]
|
||||
|
||||
reminders = current_task.reminders if current_task else []
|
||||
|
||||
if add_reminders := call.data.get(ATTR_REMINDER):
|
||||
|
||||
@@ -275,6 +275,15 @@ update_todo:
|
||||
selector:
|
||||
text:
|
||||
multiple: true
|
||||
collapse_checklist: &collapse_checklist
|
||||
required: false
|
||||
selector:
|
||||
select:
|
||||
options:
|
||||
- collapsed
|
||||
- expanded
|
||||
mode: list
|
||||
translation_key: collapse_checklist
|
||||
priority: *priority
|
||||
duedate_options:
|
||||
collapsed: true
|
||||
@@ -318,6 +327,7 @@ create_todo:
|
||||
name: *name
|
||||
notes: *notes
|
||||
add_checklist_item: *add_checklist_item
|
||||
collapse_checklist: *collapse_checklist
|
||||
priority: *priority
|
||||
date: *due_date
|
||||
reminder: *reminder
|
||||
@@ -419,6 +429,7 @@ create_daily:
|
||||
name: *name
|
||||
notes: *notes
|
||||
add_checklist_item: *add_checklist_item
|
||||
collapse_checklist: *collapse_checklist
|
||||
priority: *priority
|
||||
start_date: *start_date
|
||||
frequency: *frequency_daily
|
||||
|
||||
@@ -66,7 +66,9 @@
|
||||
"repeat_weekly_options_description": "Options related to weekly repetition, applicable when the repetition interval is set to weekly.",
|
||||
"repeat_monthly_options_name": "Monthly repeat day",
|
||||
"repeat_monthly_options_description": "Options related to monthly repetition, applicable when the repetition interval is set to monthly.",
|
||||
"quest_name": "Quest"
|
||||
"quest_name": "Quest",
|
||||
"collapse_checklist_name": "Collapse/expand checklist",
|
||||
"collapse_checklist_description": "Whether the checklist of a task is displayed as collapsed or expanded in Habitica."
|
||||
},
|
||||
"config": {
|
||||
"abort": {
|
||||
@@ -1006,6 +1008,10 @@
|
||||
"unscore_checklist_item": {
|
||||
"name": "[%key:component::habitica::common::unscore_checklist_item_name%]",
|
||||
"description": "[%key:component::habitica::common::unscore_checklist_item_description%]"
|
||||
},
|
||||
"collapse_checklist": {
|
||||
"name": "[%key:component::habitica::common::collapse_checklist_name%]",
|
||||
"description": "[%key:component::habitica::common::collapse_checklist_description%]"
|
||||
}
|
||||
},
|
||||
"sections": {
|
||||
@@ -1070,6 +1076,10 @@
|
||||
"add_checklist_item": {
|
||||
"name": "[%key:component::habitica::common::checklist_options_name%]",
|
||||
"description": "[%key:component::habitica::common::add_checklist_item_description%]"
|
||||
},
|
||||
"collapse_checklist": {
|
||||
"name": "[%key:component::habitica::common::collapse_checklist_name%]",
|
||||
"description": "[%key:component::habitica::common::collapse_checklist_description%]"
|
||||
}
|
||||
},
|
||||
"sections": {
|
||||
@@ -1151,6 +1161,10 @@
|
||||
"name": "[%key:component::habitica::common::unscore_checklist_item_name%]",
|
||||
"description": "[%key:component::habitica::common::unscore_checklist_item_description%]"
|
||||
},
|
||||
"collapse_checklist": {
|
||||
"name": "[%key:component::habitica::common::collapse_checklist_name%]",
|
||||
"description": "[%key:component::habitica::common::collapse_checklist_description%]"
|
||||
},
|
||||
"streak": {
|
||||
"name": "Adjust streak",
|
||||
"description": "Adjust or reset the streak counter of the daily."
|
||||
@@ -1247,6 +1261,10 @@
|
||||
"name": "[%key:component::habitica::common::checklist_options_name%]",
|
||||
"description": "[%key:component::habitica::common::add_checklist_item_description%]"
|
||||
},
|
||||
"collapse_checklist": {
|
||||
"name": "[%key:component::habitica::common::collapse_checklist_name%]",
|
||||
"description": "[%key:component::habitica::common::collapse_checklist_description%]"
|
||||
},
|
||||
"reminder": {
|
||||
"name": "[%key:component::habitica::common::reminder_options_name%]",
|
||||
"description": "[%key:component::habitica::common::reminder_description%]"
|
||||
@@ -1325,6 +1343,12 @@
|
||||
"day_of_month": "Day of the month",
|
||||
"day_of_week": "Day of the week"
|
||||
}
|
||||
},
|
||||
"collapse_checklist": {
|
||||
"options": {
|
||||
"collapsed": "Collapsed",
|
||||
"expanded": "Expanded"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ from homeassistant.components.habitica.const import (
|
||||
ATTR_ALIAS,
|
||||
ATTR_CLEAR_DATE,
|
||||
ATTR_CLEAR_REMINDER,
|
||||
ATTR_COLLAPSE_CHECKLIST,
|
||||
ATTR_CONFIG_ENTRY,
|
||||
ATTR_COST,
|
||||
ATTR_COUNTER_DOWN,
|
||||
@@ -1498,6 +1499,18 @@ async def test_create_habit(
|
||||
},
|
||||
Task(alias="ALIAS"),
|
||||
),
|
||||
(
|
||||
{
|
||||
ATTR_COLLAPSE_CHECKLIST: "collapsed",
|
||||
},
|
||||
Task(collapseChecklist=True),
|
||||
),
|
||||
(
|
||||
{
|
||||
ATTR_COLLAPSE_CHECKLIST: "expanded",
|
||||
},
|
||||
Task(collapseChecklist=False),
|
||||
),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_uuid4")
|
||||
@@ -1596,6 +1609,20 @@ async def test_update_todo(
|
||||
},
|
||||
Task(type=TaskType.TODO, text="TITLE", alias="ALIAS"),
|
||||
),
|
||||
(
|
||||
{
|
||||
ATTR_NAME: "TITLE",
|
||||
ATTR_COLLAPSE_CHECKLIST: "collapsed",
|
||||
},
|
||||
Task(type=TaskType.TODO, text="TITLE", collapseChecklist=True),
|
||||
),
|
||||
(
|
||||
{
|
||||
ATTR_NAME: "TITLE",
|
||||
ATTR_COLLAPSE_CHECKLIST: "expanded",
|
||||
},
|
||||
Task(type=TaskType.TODO, text="TITLE", collapseChecklist=False),
|
||||
),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_uuid4")
|
||||
|
||||
Reference in New Issue
Block a user