On 05/08/2015 11:53, Norbert Hartl wrote:
Am 05.08.2015 um 11:42 schrieb Iwan Vosloo
<iwan(a)reahl.org
<mailto:iwan@reahl.org>>:
But it seems that visible: can only take a Boolean, which the
description then retains for the lifetime of the description. The
description in turn lives as long as the MAContainerComponent stays
alive. So, I don't really understand how one can change the contents
of the MAContainerComponent based on something like visible: on the
description. (I thought magritteDynamicObject could help here, but
magritteDynamicObject is deprecated in Magritte3.)
I'm not sure I can give a good answer to this. And I'm not sure it is
a feasible use case to have visibility fully dynamic. Usually you
create a component and the visibility of the elements should be
defined by then.
Moving stuff to the instance side opened the possibility to have more
dynamic stuff that can access the instance but there is surely a lack
of support for things like the one you describe. So not everything can
be used dynamically. We need to decide which of these things need to
be integrated into magritte.
Can you describe a more detailled use case why you would want to have
dynamic visibility of elements?
I appreciate the discussion Norbert.
The system I'm working on is big and a real example is difficult to
provide due to all the context needed, but here is a simplified example
based on something real:
Assume I have a Transaction object which a user can match to a Payment.
There's a screen on which the user can edit the Transaction. On this
screen there is a button the user can click in order to choose a Payment
to match it to.
To keep the example simple, I am ignoring the Payment and the bits about
choosing it. Instead the Transaction edit screen just has a "Match"
button that the user can click to mark the Transaction as being matched.
The expectation is that the user will stay on the same screen (thus same
component), doing other stuff after such matching.
When the user first sees the Transaction screen, it displays all sorts
of contents of the Transaction, but nothing about what it is matched to
(because it is not matched at this time). Once matched, in the
simplified example, it should include a readonly item stating when it
was matched. (In the real world, this could be an
MAToOneRelationDescription that renders as a link to the Payment that
was matched, and that displays only if there was indeed a Payment matched.)
So I'd have something like:
A class Transaction with instVar 'matchedTime' and:
Transaction>>descriptionMatchedTime
<magritteDescription>
^ MADateAndTimeDescription new
selectorAccessor: #matchedTime;
readonly: true;
visible: self isMatched;
label: 'Matched at';
yourself.
... and somewhere else I'll create the component to be displayed like this:
myComponent:= aTransaction asComponent
addValidatedForm: { [:theTransaction| theTransaction match] ->
'Match' };
yourself
With this code the matched time is never displayed, since the Boolean
passed to visible: is evaluated only when the MAContainerComponent is
created.
Regards
- Iwan
--
Reahl, the Python only web framework:
http://www.reahl.org