Has-todo: user where ( )

‘Transport Arranged’: stategroup (
    'No' {
        has-todo: user .'Logistics'?'Yes' where ( ^ ^ .'Past'?'No' )
    }
    'Yes' { ... }
}

In the documentation I read ‘where’ functions as an AND function. I wish a to-do only to exist whenever transport has not been arranged AND it is not in the past. However, where ( ) in this case does not seem to be correctly implemented, as to-do’s still exist for states with ‘Past’?’No’.

Can anybody please help me with the correct syntax?

Hi Martinique,

If I’m correct you mean that you don’t expect todos for entries with the state ‘Past’?’Yes'`.

But you are correct that there still is a todo label in the entry view even when the where condition is not met. It shows as a “todo for someone else” instead of a “todo for you”.

Given the following contrived example a task is only a todo when it is assigned to someone and the task is not closed.

users
	anonymous
	dynamic: .'users'

interfaces

root {
	'users': collection ['user'] {
		'user': text
		'role': stategroup (
			'manager' { }
			'production' { }
		)
	}
	'tasks': collection ['task'] {
		'task': text
		'assigned': stategroup (
			'yes' {
				has-todo: user .'role'?'production' where ( ^ .'closed'?'no' )

				'assignee': text -> ^ ^ .'users'[]
			}
			'no' { }
		)
		'closed': stategroup (
			'yes' { }
			'no' { }
		)
	}
}

numerical-types

In my example location a user Theo has one todo.

The task shows as a todo for you:

But another close task also has the todo label but then for someone else. Even though this can never be assigned to someone.

Is this the issue that you ran into?

Kind regards,

Paul

1 Like

Thank you Paul. Your explanation helped me to clearly understand how where is used in this case. It also helped me to understand I was using it incorrectly.

‘Past’: stategroup = switch ^ ^ .‘Past’ (
|‘No’ => ‘No’ ( )
|‘Yes’ => ‘Yes’ ( )
) @hidden (
‘No’ {
has-todo: user .‘Logistics’?‘Yes’
}
‘Yes’ { }
)

1 Like