VitorCruz
VitorCruz

Reputation: 421

How to make multiple descriptions in a method on Magritte

In Magritte I can define a description method that returns one description:

MyEntity>>nameDescription
    <magritteDescription>
    ^ MAStringDescription new
                          accessor: #street;
                          label: 'Street';
                          priority: 100;
                          yourself

But can I return more than one description, in an array, for example? I thought maybe magritteContainer pragma might work, but looking at the code it seems that Magritte looks for only one method annotated like this in the object hierarchy, so I am not sure using it is the right way. Is there a recommended way (if one at all) of doing multiple descriptions in one single method?

Upvotes: 1

Views: 91

Answers (1)

Stephan Eggermont
Stephan Eggermont

Reputation: 15907

You are expected to mostly have one description for each field/property/relation. Then the standard mechanism of collecting all descriptions in the container works very well. Nothing is stopping you from adding multiple descriptions for a field, and building up components that only use a subset of these descriptions, however. In QCMagritte we chained the visitors, so an access control mechanism could remove certain descriptions, and make others read-only. Then a translation visitor would translate all labels, and only then would the html generating visitor apply itself.

Upvotes: 1

Related Questions