mpcjanssen / simpletask-android

GNU General Public License v3.0
549 stars 128 forks source link

Project filter wildcards #986

Open pabgan opened 5 years ago

pabgan commented 5 years ago

The official application supports (incidentally?) nested projects because filter seems to always add a wildcard at the end.

For example, I have a general project called +hogar (home in spanish) and inside it I create other smaller projects for everything I want to fix by adding . and some more text. Then I can list all tasks in that general project:

pablo@fieVel ~
  % t ls +hogar
17 (B) 2019-03-18 +hogar.arreglos.etiquetar_nevera @casa
33 (B) 2019-06-04 comprar veneno para hormigas para +hogar.arreglos.cocina_hormigas @ferretería
03 2018-11-01 @comprar tacos del 6 y del 8 para +hogar @ferretería
05 2018-12-02 hacer plugin de kodi que youtube-dlee un vídeo y lo reproduzca @ordenador +hogar.informática.luMiere
08 2019-01-27 @comprar organizador de cubiertos para +hogar
10 2019-01-28 @comprar edredón nórdico +hogar @el_corte_inglés
13 2019-02-13 actualizar emby +hogar.informática @ordenador
18 2019-03-20 arreglar armario que rasca otra vez @casa +hogar
24 2019-04-21 @comprar cafetera italiana +hogar
28 2019-05-29 @comprar mandos consola +hogar
31 2019-06-02 acabar con +hogar.arreglos.cocina_hormigas @casa
32 2019-06-04 @comprar cubos de reciclaje +hogar @ordenador
35 2019-06-12 +hogar.finanzas automatizar actualización diaria de fichero de transacciones @ordenador
34 2019-06-12 +hogar.finanzas automatizar descarga diaria de los movimientos de ING @ordenador
37 2019-06-12 +hogar.finanzas aviso por correo para transacciones inesperadas @ordenador
36 2019-06-12 +hogar.finanzas hacer que +ing2ledger haga la clasificación en función del concepto de la operación @ordenador
38 2019-06-12 poner tope a +hogar.arreglos.puerta_pasillo @casa
42 2019-06-18 arreglar +hogar.enchufe_zuni +zuni @casa
43 2019-06-19 atornillar bien la +hogar.arreglos.banqueta @casa
50 2019-06-22 +hogar.cambiar_tendedero de terraza @casa
48 2019-06-22 bombona paella @comprar @ferretería +hogar due:2019-07-12
49 2019-06-22 colgar +hogar.hamaca @casa
57 2019-06-24 @comprar cuerda para +hogar.hamaca @ferretería
--
PERSONAL-TODO: 23 of 56 tasks shown

Or only those inside a subproject:

pablo@fieVel ~
  % t ls +hogar.informática
05 2018-12-02 hacer plugin de kodi que youtube-dlee un vídeo y lo reproduzca @ordenador +hogar.informática.luMiere
13 2019-02-13 actualizar emby +hogar.informática @ordenador
--
PERSONAL-TODO: 2 of 56 tasks shown

When I try to do the same with this great Android application, filtering by +hogar will only list those tasks that have that project with no subproject assigned, like task 8 in the example above.

Would it be possible/desirable to have that behavior replicated here?

mpcjanssen commented 5 years ago

You can make pretty much any type of filter using Lua. This case is no exception. When I have some time I will add an example script.

mpcjanssen commented 5 years ago

The following Lua script should show all tasks in the Hogar project:

function onFilter(t,f)
 for k,v in pairs(f.tags) do
  if string.find(k,"hogar") == 1 then
  return true
 end
end
return false
end

See https://github.com/mpcjanssen/simpletask-android/blob/master/app/src/main/assets/script.en.md for details.

mpcjanssen commented 5 years ago

Supporting custom filtering requests like this was the main reason for including a Lua scripting option.

pabgan commented 5 years ago

Thank you very much for the code, @mpcjanssen , and sorry for the delay in my response.

I see your point, but that would mean creating a custom filter for every project to replicate the behaviour in the original application. I know this is not an official application, but it is the closest, and I thought that it may make more sense to make this the default behaviour and leave the custom LUA script for those who want what it is not default in the offical application (the current behaviour), that by the way you can get with todo.sh ls +hogar$ (just in case somebody wonders).

mpcjanssen commented 5 years ago

@pabgan I see the point, but I don't know how I can make this work in the UI. I am open for suggestions. BTW you can save all these project specific filters in the right drawer.

pabgan commented 5 years ago

Thanks for your openness.

I do not know what you mean. The way I see it the UI would remain the same but when any project is selected then the tasks that are shown are all that contain that project with or without subprojects, maybe running that script that you pasted above. I have not digged into the code and there might be a better solution, though. I will take a look into it when I have time.

Pablo Ganuza Vidal

mpcjanssen commented 5 years ago

@pabgan, that might work as a standard filter setting (show sub projects). Because the cli supports this, i might add this.

pabgan commented 5 years ago

Thank you very much.