Subject: Magritte: adding a condition on the whole
object in
its description
Hello,
I want to add a condition to a Magritte-described object that
checks the whole object for consistency (and not just a
single attribute). Is that possible?
Example: Think about creating a workgroup from some of the
users of your site. The workgroup has a manager. The
condition is that the manager must be one of the members of
the workgroup.
I've tried to do this. I have two descriptions on the
workgroup class side: one for the manager (saying that it can
be any of the site's users) and one for the users (saying
that this is a subset of all users). I can add a method
#description to modify the standard description that is
assembled from the description* methods on the class side. So
I tried:
Workgroup>>description
^super description
addCondition: [:workgroup | workgroup users includes:
workgroup manager]
labelled: 'Manager must be a member of the workgroup';
yourself
Alas, trying to edit an existing workgroup, I learned that
the argument of the condition block is a MACheckedMemento, so
I can't ask it for users.
What would be the best way to have this check everytime the
work group is edited? Or should I just write the #manager:
method such that the condition will be satisfied automatically?
Cheers
Matthias
See
http://onsmalltalk.com/programming/smalltalk/multiple-field-validation-rules
-in-magritte/ to see how to get at the values you're looking for, very
similar situation.
Ramon Leon
http://onsmalltalk.com