diff --git a/fhem/FHEM/98_todoist.pm b/fhem/FHEM/98_todoist.pm index f2efb17c4..e360014e9 100644 --- a/fhem/FHEM/98_todoist.pm +++ b/fhem/FHEM/98_todoist.pm @@ -17,7 +17,7 @@ eval "use Date::Parse;1" or $missingModule .= "Date::Parse "; ####################### # Global variables -my $version = "1.2.9"; +my $version = "1.2.12"; my $srandUsed; @@ -354,6 +354,26 @@ sub todoist_UpdateTask($$$) { Log3 $name,5, "$name: Args: ".Dumper(%args); $method="POST"; } + ## move a task + elsif ($type eq "move") { + $tType = "item_move"; + %args = ( + id => $taskId, + ); + ## parent_id + $args{'parent_id'} = $h->{"parent_id"} if ($h->{"parent_id"}); + $args{'parent_id'} = $h->{"parentID"} if ($h->{"parentID"}); + $args{'parent_id'} = $h->{"parentId"} if ($h->{"parentId"}); + + ## project_id + $args{'project_id'} = $h->{"project_id"} if ($h->{"project_id"}); + $args{'project_id'} = $h->{"projectID"} if ($h->{"projectID"}); + $args{'project_id'} = $h->{"projectId"} if ($h->{"projectId"}); + + if ($args{'parent_id'}) { + my $pid=$args{'parent_id'}; + } + } ## update a task elsif ($type eq "update") { $tType = "item_update"; @@ -379,21 +399,9 @@ sub todoist_UpdateTask($$$) { $args{'assigned_by_uid'} = $h->{"assignedBy"} if ($h->{"assignedByUid"}); ## order of the task $args{'child_order'} = $h->{"order"} if ($h->{"order"}); - ## indent of the task + ## child order of the task $args{'child_order'} = $h->{"child_order"} if ($h->{"child_order"}); - ## parent_id - $args{'parent_id'} = $h->{"parent_id"} if ($h->{"parent_id"}); - $args{'parent_id'} = $h->{"parentID"} if ($h->{"parentID"}); - $args{'parent_id'} = $h->{"parentId"} if ($h->{"parentId"}); - if ($args{'parent_id'}) { - my $pid=$args{'parent_id'}; - if ($hash->{helper}{"INDENT"}{$pid}) { - $args{'indent'} = int($hash->{helper}{"INDENT"}{$pid})+1; - } - } - - $args{'parent_id'} = "" if ($h->{"indent"}==1); ## remove attribute if ($h->{"remove"}) { @@ -559,7 +567,7 @@ sub todoist_CreateTask($$) { ## order of the task $data->{'item_order'} = $h->{"order"} if ($h->{"order"}); - ## indent of the task + ## child order of the task $data->{'child_order'} = $h->{"child_order"} if ($h->{"child_order"}); @@ -912,9 +920,7 @@ sub todoist_GetTasksCallback($$$){ $hash->{helper}{"WID"}{$taskID}=$i; # FHEM Task-ID $hash->{helper}{"parent_id"}{$taskID}=$task->{parent_id}; # parent_id of item $hash->{helper}{"child_order"}{$taskID}=$task->{child_order}; # order of task under parent - #$hash->{helper}{"INDENT"}{$taskID}=$task->{indent}; # todoist Task indent $hash->{helper}{"PRIORITY"}{$taskID}=$task->{priority}; # todoist Task priority - #push @{$hash->{helper}{"INDENTS"}{$task->{indent}}},$taskID; # ident for better widget #push @{$hash->{helper}{"PARENTS"}{$task->{parent_id}}},$taskID; # ident for better widget $hash->{helper}{"ORDER"}{$taskID}=$task->{item_order}; # todoist Task order if ($param->{completed} != 1) { @@ -1383,7 +1389,6 @@ sub todoist_sort($) { readingsBulkUpdate($hash,"Task_".sprintf("%03s",$i)."_recurrenceType",$hash->{helper}{"RECURRENCE_TYPE"}{$data->{ID}}) if ($hash->{helper}{"RECURRENCE_TYPE"}{$data->{ID}}); readingsBulkUpdate($hash,"Task_".sprintf("%03s",$i)."_completedAt",$hash->{helper}{"COMPLETED_AT"}{$data->{ID}}) if ($hash->{helper}{"COMPLETED_AT"}{$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)."_indent",$hash->{helper}{"INDENT"}{$data->{ID}}) if ($hash->{helper}{"INDENT"}{$data->{ID}} && AttrVal($name,"showIndent",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)."_checked",$hash->{helper}{"CHECKED"}{$data->{ID}}) if ($hash->{helper}{"CHECKED"}{$data->{ID}} && AttrVal($name,"showChecked",1)==1); @@ -1626,7 +1631,7 @@ sub todoist_Attr($@) { } } - if ( $attrName eq "sortTasks" || $attrName =~ /(show(Priority|AssignedBy|Responsible|Indent|Order|DetailWidget)|getCompleted|hide(Id|ListIfEmpty)|autoGetUsers|avoidDuplicates|delDeletedLists)/) { + if ( $attrName eq "sortTasks" || $attrName =~ /(show(Priority|AssignedBy|Responsible|Order|DetailWidget)|getCompleted|hide(Id|ListIfEmpty)|autoGetUsers|avoidDuplicates|delDeletedLists)/) { if ( $cmd eq "set" ) { return "$name: $attrName has to be 0 or 1" if ($attrVal !~ /^(0|1)$/); Log3 $name, 4, "todoist ($name): set attribut $attrName to $attrVal"; @@ -1654,6 +1659,7 @@ sub todoist_Set ($@) { push @sets, "uncompleteTask"; push @sets, "deleteTask"; push @sets, "updateTask"; + push @sets, "moveTask"; push @sets, "clearList:noArg"; push @sets, "getTasks:noArg"; push @sets, "cChildProjects:noArg"; @@ -1723,11 +1729,12 @@ sub todoist_Set ($@) { } return "in order to complete a task, we need it's ID" if ($count==0); } - elsif ($cmd eq "updateTask") { + elsif ($cmd eq "updateTask" || $cmd eq "moveTask") { + my $term=$cmd eq "updateTask"?"update":"move"; my $count=@args; if ($count!=0) { my $exp=decode_utf8(join(" ",@args)); - todoist_UpdateTask ($hash,$exp,"update"); + todoist_UpdateTask ($hash,$exp,$term); } return "in order to complete a task, we need it's ID" if ($count==0); } @@ -2017,15 +2024,7 @@ sub todoist_Html(;$$$) { tr.ui-sortable-helper { background-color:#111111; } - .todoist_indent_2 { - padding-left:20px!important; - } - .todoist_indent_3 { - padding-left:40px!important; - } - .todoist_indent_4 { - padding-left:60px!important; - } + .todoist_ph td { padding: 4px 8px; } @@ -2109,14 +2108,13 @@ sub todoist_Html(;$$$) { - my $indent=$hash->{helper}{INDENT}{$_}?$hash->{helper}{INDENT}{$_}:"0"; $ret .= "
set <DEVICE> addTask <TASK_TITLE> dueDate=2017-01-15 priority=2set <DEVICE> updateTask ID:12345678 dueDate=2017-01-15 priority=1set <DEVICE> updateTask 1 dueDate=übermorgenset <DEVICE> updateTask TITLE:Brot dueDate=übermorgenset <DEVICE> completeTask <TASK-ID> - completes a task by number