simpletask-android icon indicating copy to clipboard operation
simpletask-android copied to clipboard

A task with 2 lists will only be shown in one list

Open nielsk opened this issue 10 years ago • 13 comments

When I have a task like: foo bar @list1 @list2

Then it will only appear in @list1 but not in @list2

nielsk avatar Nov 03 '14 13:11 nielsk

This is the intended behavior assuming you mean it will not be shown under the @list2 header. If you select only list2 in the filter it will be shown. The reason for this is that currently there is no easy way to have a single task be shown in multiple spots in the listview. There is not deep reason why this could not change so I will leave this open for now. But to fix this I need to have a better handle on task identity in the code (the line number in the todo.txt file will probably be required there)

mpcjanssen avatar Nov 03 '14 13:11 mpcjanssen

This requires rewriting of the Task adapter and of the storage backend to allow quick answers to the questions such as: show me all tasks on list @B at the moment this is not possible.

mpcjanssen avatar Nov 05 '14 09:11 mpcjanssen

Whilst not a high priority request I think this would be a desirable option to add. Thanks.

barbuduccle avatar Nov 20 '14 01:11 barbuduccle

I would appreciate that! For me there is no sense in having the ability to select multiple lists whilst the entry is shown only in one of them, which as far as I could figure out is always the first in alphabetical order. Thanks :)

karlsebal avatar Feb 18 '15 13:02 karlsebal

Would love to have this feature! Most of my tasks have at least two lists. Currently I cannot be sure that if I check one list it contains all tasks with that list.

fluxens avatar Oct 13 '16 11:10 fluxens

The backend work that would make this possible is underway (although a ways off) in #617, on the standalone branch.

smichel17 avatar Oct 13 '16 13:10 smichel17

Nice to hear! o) I'd also like to see tasks appear in multiple contexts/projects at the same time. I tend to apply a "2finish" context to the things I started and which got very "hot". Because "2finish" is early in the alphabet, ongoing tasks appear right at the top in that section. They do not show up in the other sections anymore, but it still would be nice to see them right next to where they actually belong.

I might abuse the idea behind a bit by doing what I described, but it works quite well for me and serves as a priority layer ontop of the priority support there already is. Thanks for keeping me busy with this tool! o)

tbone2k-git avatar Oct 25 '16 04:10 tbone2k-git

Lua script and a few bugs:

I have a workaround for this using Lua. My initial attempts were directed at trying to get the onGroup function to return multiple values, but I was unable to implement it properly. In retrospect, I realised that it would not have been a very good solution because each task would have to appear in multiple lists if there is no filtering, and if, say, you had 10 such tasks with 10 lists each, it would mean collectively, a 100 entries for just 10 tasks, and this could, in a worstcase scenario, just balloon the number of entries being displayed.

As a workaround, what I do is the following: If the task has multiple lists, the list names are sorted, and concatenated into a multiline string, where each line is a list name. This string is returned as the group name by the onGroup function.

So, for a task list as below:

2016-11-20 A  t:2016-11-21 due:2016-11-27
2016-11-22 test 2 @X @Z @Y +R +S
2016-11-23 test @X +R
2016-11-23 test 3 @Y +S
2016-11-23 C @test_listB @test_listA
2016-11-23 B @M
2016-11-23 Test 4 @X @y @UY
2016-11-23 Mxjd @y
2016-11-23 Test 4 @X @Y @UY
2016-11-23 Ndjd @X @Y
2016-11-23 Try @X @y @Z
2016-11-23 Try @x

When filtered according to my script to group by lists, the following is displayed: 2016-11-23-15-35-05

(As an aside, only once was I shown list x labeled as "x" and not "X". This seems to be a cosmetic error, because tasks of list x are shown separately from X, the list group X, y, Z is correctly sorted as X, Z, y (because lowercase y comes after Z in ASCII), but the group name display is all caps. Is this a bug? I was shown the lists with the proper lowercase once when writing the code, but that behaviour disappeared when I restarted Simpletask.)

The same program can also be used to group according to tags, which, when done, results in the following: 2016-11-23-15-44-58

(Again, no idea why Unsorted appears twice here. When I select the no-tag option from the left drawer, all 9 tasks are grouped as one, but if I select no-tag, and either R or S or both, the unsorted tasks are again split as above.)

Finally, the script also addresses #308 after a fashion. If you chose to display just tag R from the app drawer, when the script is configured to group by tags, the following happens: 2016-11-23-15-57-11

Atleast, the app no longer mislabels the group with R and S as R. A similar thing happens with lists as well.


The set of functions that achieves this:

-- Group tasks by list or tag, and separately classify tasks with multiple lists/tags.

function tablelength (T)
		--[[Returns the number of keys in the table.
			 Source: http://stackoverflow.com/questions/2705793/how-to-get-number-of-entries-in-a-lua-table/2705804#2705804]]
	local count = 0
	for _ in pairs (T) do count = count + 1 end
	return count
end

function sort_and_concatenate_keys (T)
		--[[Sort keys and convert to a multiline string.
		   Sorting keys in table - Source: https://www.lua.org/pil/19.3.html]]
	a = {}	-- New table
	key_string = ""	-- Empty string
	for n in pairs (T) do table.insert (a, n) end	-- Fill new table "a" with keys from "T" as values in "a"
	table.sort (a)	-- Sort keys
	for _, n in ipairs (a) do key_string = key_string..n..'\n' end
		-- Append sorted keys in empty string, separated by a newline
	key_string = key_string:sub(1, -2)	-- Delete extra newline character
	return key_string
end

function onGroup (t,f,e)
	tbl = f.lists	-- Use f.tags here to group by tags instead of lists
	L = tablelength (tbl)

	if L==0 then
		return "Unsorted"	-- No list/tag. Custom label. Adapted from built-in example code.
	elseif L==1then
		return next(tbl)	-- One list/tag. Return that value. Adapted from built-in example code.
	else
		return sort_and_concatenate_keys (tbl)	-- Multiple lists/tags. Group under multiline label.
	end
end

PS: This is my first Lua program that is not a minor tweak of the example code provided along with the app. Still getting my bearings with the language concepts. So if there is a better and more efficient way to implement this, kindly let me know how.

Follow up question: Can I define the two functions tablelength and sort_and_concatenate_keys in the Lua configuration window and have them visible to scripts in widgets? Or do they need to be defined everytime?

Vijayanth-Reddy-K avatar Nov 23 '16 10:11 Vijayanth-Reddy-K

If, say, you had 10 such tasks with 10 lists each, it would mean collectively, a 100 entries for just 10 tasks

I don't think this would be a bad thing. Regardless, displaying tasks multiple times is really not possible without #617.

(As an aside, only once was I shown list x labeled as "x" and not "X". This seems to be a cosmetic error, because tasks of list x are shown separately from X, the list group X, y, Z is correctly sorted as X, Z, y (because lowercase y comes after Z in ASCII), but the group name display is all caps. Is this a bug? I was shown the lists with the proper lowercase once when writing the code, but that behaviour disappeared when I restarted Simpletask.)

As far as I remember, headers are converted to upper case when they are displayed. So technically this is working as intended. However, from a UX perspective it's pretty clearly not the right thing to do, so I'd call it a UX bug. I think it should obey your "Sort case sensitive" setting (showing them under separate headers if the settings is enabled and the same header if it is not).

It's pretty odd that you got it to display with lowercase once.

no idea why Unsorted appears twice here

The onGroup function doesn't affect the order in which tasks are displayed, only the header they're displayed under. So, the order is still whatever you have in your sort tab.

Finally, the script also addresses #308 after a fashion. If you chose to display just tag R from the app drawer, when the script is configured to group by tags, the following happens:

This is nice.

PS: This is my first Lua program that is not a minor tweak of the example code provided along with the app. Still getting my bearings with the language concepts. So if there is a better and more efficient way to implement this, kindly let me know how.

I'm no lua expert, but upon cursory review I don't see any glaring inefficiencies.

Follow up question: Can I define the two functions tablelength and sort_and_concatenate_keys in the Lua configuration window and have them visible to scripts in widgets? Or do they need to be defined everytime?

You can; the lua config is global.

smichel17 avatar Nov 23 '16 17:11 smichel17

The onGroup function doesn't affect the order in which tasks are displayed, only the header they're displayed under. So, the order is still whatever you have in your sort tab.

I was confused about this at first, until I realised that the entries were listed in the same order as the default window. Asking Simpletask to sort by tags first grouped everything properly. Thanks!

Following @smichel17's suggestion here, this is my final global Lua configuration file:

toast('Hello')    -- Welcome Message. Pops up every time Simpletask is restarted.

---------------------------------- ---------------------------------- ---------------------------------- ----------------------------------

function tablelength(T)
		--[[Returns the number of keys in the table.
			 Source: http://stackoverflow.com/questions/2705793/how-to-get-number-of-entries-in-a-lua-table/2705804#2705804]]
	local count = 0
	for _ in pairs(T) do count = count + 1 end
	return count
end

---------------------------------- ---------------------------------- ---------------------------------- ----------------------------------

function sort_and_concatenate_keys(T)
    --[[Sort keys and convert to a multiline string.
        Sorting keys in table - Source: https://www.lua.org/pil/19.3.html]]

    a = {}            -- New table
    key_string = ""   -- Empty string

    for n in pairs(T) do table.insert(a, n) end
        -- Fill new table "a" with keys from "T" as values in "a"

    table.sort(a)    -- Sort keys

    for _, n in ipairs(a) do key_string = key_string..n..'\n' end
        -- Append sorted keys in empty string, separated by a newline
        
    key_string = key_string:sub(1, -2)	-- Delete extra newline character

    return key_string
end

---------------------------------- ---------------------------------- ---------------------------------- ----------------------------------

-- Group tasks by list or tag, and separately classify tasks with multiple lists/tags.

function multigroup_by_list_or_tag(t, f, e, parameter)

    if parameter == 'tags' then
        tbl = f.tags
        
    else tbl = f.lists
    end
    
    L = tablelength(tbl)
    
    if L == 0 then
        return "Unsorted"	-- No list/tag. Custom label. Adapted from built-in example code.
    
    elseif L == 1 then
        return next(tbl)	-- One list/tag. Return that value. Adapted from built-in example code.
    
    else return sort_and_concatenate_keys(tbl)	-- Multiple lists/tags. Group under multiline label.
    end
end

---------------------------------- ---------------------------------- ---------------------------------- ----------------------------------

The above functionality of grouping by lists or tags is now implemented in a filter script (in the main window or widget) by using one of the two functions as needed:

-- Group by lists

function onGroup(t, f, e)
    return multigroup_by_list_or_tag(t, f, e)
end


-- Group by tags

function onGroup(t, f, e)
    return multigroup_by_list_or_tag(t, f, e, "tags")
end

A further discussion on the behaviour of implementing the above two functions in scripts vs. the main configuration window can be found here.

Vijayanth-Reddy-K avatar Dec 04 '16 06:12 Vijayanth-Reddy-K

I see, it is a long time and often requested feature. I love many-to-many relationships and use them very often in my analytical database models.

What I do not understand from this issue here: should I use some Lua script to get the desired result?

aisbergde avatar May 26 '20 16:05 aisbergde

It is not currently possible. Needs someone with time to implement it.

smichel17 avatar May 26 '20 17:05 smichel17

I also use multiple @lists for context which works well with the Quick filter option (Dropbox version). This way I can add a mental context (work, home, hobby, etc.) together with the traditional gtd contexts (waiting_for, discuss_with, etc.).

However I noticed an inconsistency in the way Simpletask handles the display of overviews generated by the Quick filter.

When I do a Quick filter on my @ese context (for all my work related tasks) Simpletask only groups tasks with a 2nd context if the context is lexicographically before the context used for the Quick filter.

For example: 3 tasks

next action 1 @ese next action 2 @ese @waiting_for next action 3 @ese @archive

Creating a Quick filter on @ese yields the following list:

ARCHIVE next action 3 @ese @archive

ESE next action 1 @ese next action 2 @ese @waiting_for

A solution for this problem would either be:

  • Ignore multiple contexts when creating a Quick filtered list (my preference and possibly simple to implement))
  • Using all additional contexts for grouping purposes (possibly more complex when a tasks has >2 contexts).

As a side note: thanks for the awesome app. I have just bought the donate key to support further development.

Regards,

Pieter Vreeburg The Netherlands

pietervreeburg avatar Jun 10 '20 12:06 pietervreeburg