98_todoist: added section handling
git-svn-id: https://svn.fhem.de/fhem/trunk@20946 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
@@ -17,7 +17,7 @@ eval "use Date::Parse;1" or $missingModule .= "Date::Parse ";
|
|||||||
|
|
||||||
#######################
|
#######################
|
||||||
# Global variables
|
# Global variables
|
||||||
my $version = "1.2.12";
|
my $version = "1.2.13";
|
||||||
|
|
||||||
my $srandUsed;
|
my $srandUsed;
|
||||||
|
|
||||||
@@ -82,6 +82,7 @@ sub todoist_Initialize($) {
|
|||||||
"showAssignedBy:1,0 ".
|
"showAssignedBy:1,0 ".
|
||||||
"showResponsible:1,0 ".
|
"showResponsible:1,0 ".
|
||||||
"showParent:1,0 ".
|
"showParent:1,0 ".
|
||||||
|
"showSection:1,0 ".
|
||||||
"showChecked:1,0 ".
|
"showChecked:1,0 ".
|
||||||
"showDeleted:1,0 ".
|
"showDeleted:1,0 ".
|
||||||
"showOrder:1,0 ".
|
"showOrder:1,0 ".
|
||||||
@@ -370,6 +371,11 @@ sub todoist_UpdateTask($$$) {
|
|||||||
$args{'project_id'} = $h->{"projectID"} if ($h->{"projectID"});
|
$args{'project_id'} = $h->{"projectID"} if ($h->{"projectID"});
|
||||||
$args{'project_id'} = $h->{"projectId"} if ($h->{"projectId"});
|
$args{'project_id'} = $h->{"projectId"} if ($h->{"projectId"});
|
||||||
|
|
||||||
|
## section_id
|
||||||
|
$args{'section_id'} = $h->{"section_id"} if ($h->{"section_id"});
|
||||||
|
$args{'section_id'} = $h->{"sectionID"} if ($h->{"sectionID"});
|
||||||
|
$args{'section_id'} = $h->{"sectionId"} if ($h->{"sectionId"});
|
||||||
|
|
||||||
if ($args{'parent_id'}) {
|
if ($args{'parent_id'}) {
|
||||||
my $pid=$args{'parent_id'};
|
my $pid=$args{'parent_id'};
|
||||||
}
|
}
|
||||||
@@ -919,6 +925,7 @@ sub todoist_GetTasksCallback($$$){
|
|||||||
$hash->{helper}{"TITLES"}{$title}=$taskID; # Task title (content)
|
$hash->{helper}{"TITLES"}{$title}=$taskID; # Task title (content)
|
||||||
$hash->{helper}{"WID"}{$taskID}=$i; # FHEM Task-ID
|
$hash->{helper}{"WID"}{$taskID}=$i; # FHEM Task-ID
|
||||||
$hash->{helper}{"parent_id"}{$taskID}=$task->{parent_id}; # parent_id of item
|
$hash->{helper}{"parent_id"}{$taskID}=$task->{parent_id}; # parent_id of item
|
||||||
|
$hash->{helper}{"section_id"}{$taskID}=$task->{section_id}; # section_id of item
|
||||||
$hash->{helper}{"child_order"}{$taskID}=$task->{child_order}; # order of task under parent
|
$hash->{helper}{"child_order"}{$taskID}=$task->{child_order}; # order of task under parent
|
||||||
$hash->{helper}{"PRIORITY"}{$taskID}=$task->{priority}; # todoist Task priority
|
$hash->{helper}{"PRIORITY"}{$taskID}=$task->{priority}; # todoist Task priority
|
||||||
#push @{$hash->{helper}{"PARENTS"}{$task->{parent_id}}},$taskID; # ident for better widget
|
#push @{$hash->{helper}{"PARENTS"}{$task->{parent_id}}},$taskID; # ident for better widget
|
||||||
@@ -934,10 +941,17 @@ sub todoist_GetTasksCallback($$$){
|
|||||||
## set parent_id if not null
|
## set parent_id if not null
|
||||||
if (defined($task->{parent_id}) && $task->{parent_id} ne 'null') {
|
if (defined($task->{parent_id}) && $task->{parent_id} ne 'null') {
|
||||||
## if this task has a parent_id we set the reading
|
## if this task has a parent_id we set the reading
|
||||||
readingsBulkUpdate($hash, $prefix.$t."_parentID",$task->{parent_id});
|
readingsBulkUpdate($hash, $prefix.$t."_parentID",$task->{parent_id}) if (AttrVal($name,"showParent",1)==1);
|
||||||
$hash->{helper}{"PARENT_ID"}{$taskID}=$task->{parent_id};
|
$hash->{helper}{"PARENT_ID"}{$taskID}=$task->{parent_id};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
## set section_id if not null
|
||||||
|
if (defined($task->{section_id}) && $task->{section_id} ne 'null') {
|
||||||
|
## if this task has a parent_id we set the reading
|
||||||
|
readingsBulkUpdate($hash, $prefix.$t."_sectionID",$task->{section_id}) if (AttrVal($name,"showSection",1)==1);
|
||||||
|
$hash->{helper}{"SECTION_ID"}{$taskID}=$task->{section_id};
|
||||||
|
}
|
||||||
|
|
||||||
## set completed_date if present
|
## set completed_date if present
|
||||||
if (defined($task->{checked}) && $task->{checked}!=0) {
|
if (defined($task->{checked}) && $task->{checked}!=0) {
|
||||||
readingsBulkUpdate($hash, $prefix.$t."_checked",$task->{checked}) if (AttrVal($name,"showChecked",1)==1);
|
readingsBulkUpdate($hash, $prefix.$t."_checked",$task->{checked}) if (AttrVal($name,"showChecked",1)==1);
|
||||||
@@ -960,7 +974,7 @@ sub todoist_GetTasksCallback($$$){
|
|||||||
}
|
}
|
||||||
|
|
||||||
## set due_date if present
|
## set due_date if present
|
||||||
if (defined($task->{due}) && $task->{due_date_utc} ne 'null') {
|
if (defined($task->{due}) && $task->{due}{date} ne 'null') {
|
||||||
## if there is a task with due date, we create a new reading
|
## if there is a task with due date, we create a new reading
|
||||||
readingsBulkUpdate($hash, $prefix.$t."_dueDate",FmtDateTime(str2time($task->{due}{date})));
|
readingsBulkUpdate($hash, $prefix.$t."_dueDate",FmtDateTime(str2time($task->{due}{date})));
|
||||||
$hash->{helper}{"DUE_DATE"}{$taskID}=FmtDateTime(str2time($task->{due}{date}));
|
$hash->{helper}{"DUE_DATE"}{$taskID}=FmtDateTime(str2time($task->{due}{date}));
|
||||||
@@ -1391,6 +1405,7 @@ sub todoist_sort($) {
|
|||||||
readingsBulkUpdate($hash,"Task_".sprintf("%03s",$i)."_completedById",$hash->{helper}{"COMPLETED_BY_ID"}{$data->{ID}}) if ($hash->{helper}{"COMPLETED_BY_ID"}{$data->{ID}});
|
readingsBulkUpdate($hash,"Task_".sprintf("%03s",$i)."_completedById",$hash->{helper}{"COMPLETED_BY_ID"}{$data->{ID}}) if ($hash->{helper}{"COMPLETED_BY_ID"}{$data->{ID}});
|
||||||
readingsBulkUpdate($hash,"Task_".sprintf("%03s",$i)."_order",$hash->{helper}{"ORDER"}{$data->{ID}}) if ($hash->{helper}{"ORDER"}{$data->{ID}} && AttrVal($name,"showOrder",0)==1);
|
readingsBulkUpdate($hash,"Task_".sprintf("%03s",$i)."_order",$hash->{helper}{"ORDER"}{$data->{ID}}) if ($hash->{helper}{"ORDER"}{$data->{ID}} && AttrVal($name,"showOrder",0)==1);
|
||||||
readingsBulkUpdate($hash,"Task_".sprintf("%03s",$i)."_parentID",$hash->{helper}{"PARENT_ID"}{$data->{ID}}) if ($hash->{helper}{"PARENT_ID"}{$data->{ID}});
|
readingsBulkUpdate($hash,"Task_".sprintf("%03s",$i)."_parentID",$hash->{helper}{"PARENT_ID"}{$data->{ID}}) if ($hash->{helper}{"PARENT_ID"}{$data->{ID}});
|
||||||
|
readingsBulkUpdate($hash,"Task_".sprintf("%03s",$i)."_sectionID",$hash->{helper}{"SECTION_ID"}{$data->{ID}}) if ($hash->{helper}{"SECTION_ID"}{$data->{ID}});
|
||||||
readingsBulkUpdate($hash,"Task_".sprintf("%03s",$i)."_checked",$hash->{helper}{"CHECKED"}{$data->{ID}}) if ($hash->{helper}{"CHECKED"}{$data->{ID}} && AttrVal($name,"showChecked",1)==1);
|
readingsBulkUpdate($hash,"Task_".sprintf("%03s",$i)."_checked",$hash->{helper}{"CHECKED"}{$data->{ID}}) if ($hash->{helper}{"CHECKED"}{$data->{ID}} && AttrVal($name,"showChecked",1)==1);
|
||||||
readingsBulkUpdate($hash,"Task_".sprintf("%03s",$i)."_isDeleted",$hash->{helper}{"ISDELETED"}{$data->{ID}}) if ($hash->{helper}{"ISDELETED"}{$data->{ID}} && AttrVal($name,"showDeleted",1)==1);
|
readingsBulkUpdate($hash,"Task_".sprintf("%03s",$i)."_isDeleted",$hash->{helper}{"ISDELETED"}{$data->{ID}}) if ($hash->{helper}{"ISDELETED"}{$data->{ID}} && AttrVal($name,"showDeleted",1)==1);
|
||||||
readingsBulkUpdate($hash,"Task_".sprintf("%03s",$i)."_ID",$data->{ID}) if (AttrVal($name,"hideId",0)!=1);
|
readingsBulkUpdate($hash,"Task_".sprintf("%03s",$i)."_ID",$data->{ID}) if (AttrVal($name,"hideId",0)!=1);
|
||||||
@@ -1631,7 +1646,7 @@ sub todoist_Attr($@) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $attrName eq "sortTasks" || $attrName =~ /(show(Priority|AssignedBy|Responsible|Order|DetailWidget)|getCompleted|hide(Id|ListIfEmpty)|autoGetUsers|avoidDuplicates|delDeletedLists)/) {
|
if ( $attrName eq "sortTasks" || $attrName =~ /(show(Priority|AssignedBy|Responsible|Order|DetailWidget|Section|Parent)|getCompleted|hide(Id|ListIfEmpty)|autoGetUsers|avoidDuplicates|delDeletedLists)/) {
|
||||||
if ( $cmd eq "set" ) {
|
if ( $cmd eq "set" ) {
|
||||||
return "$name: $attrName has to be 0 or 1" if ($attrVal !~ /^(0|1)$/);
|
return "$name: $attrName has to be 0 or 1" if ($attrVal !~ /^(0|1)$/);
|
||||||
Log3 $name, 4, "todoist ($name): set attribut $attrName to $attrVal";
|
Log3 $name, 4, "todoist ($name): set attribut $attrName to $attrVal";
|
||||||
@@ -2255,6 +2270,7 @@ sub todoist_genUUID() {
|
|||||||
<li>assignedByUid=the todoist-ID of the user who assigned the current task</li>
|
<li>assignedByUid=the todoist-ID of the user who assigned the current task</li>
|
||||||
<li>order=the order of the task inside a project (the smallest value would place the task at the top)</li>
|
<li>order=the order of the task inside a project (the smallest value would place the task at the top)</li>
|
||||||
<li>parentID=parent_id of the parent task.</li>
|
<li>parentID=parent_id of the parent task.</li>
|
||||||
|
<li>sectionID=section_id of the parent task.</li>
|
||||||
|
|
||||||
</ul><br />
|
</ul><br />
|
||||||
Examples: <br /><br />
|
Examples: <br /><br />
|
||||||
@@ -2410,6 +2426,8 @@ sub todoist_genUUID() {
|
|||||||
the tasks are listet as Task_000, Task_001 [...].</li>
|
the tasks are listet as Task_000, Task_001 [...].</li>
|
||||||
<li>Task_XXX_parentID<br />
|
<li>Task_XXX_parentID<br />
|
||||||
parent ID of task XXX if not null</li>
|
parent ID of task XXX if not null</li>
|
||||||
|
<li>Task_XXX_sectionID<br />
|
||||||
|
section ID of task XXX if not null</li>
|
||||||
<li>Task_XXX_checked<br />
|
<li>Task_XXX_checked<br />
|
||||||
1 when a task with parent_id is checked</li>
|
1 when a task with parent_id is checked</li>
|
||||||
<li>Task_XXX_isDeleted<br />
|
<li>Task_XXX_isDeleted<br />
|
||||||
|
|||||||
Reference in New Issue
Block a user