Skip to content

Alternate Descriptions (Experimental)

Sean DeNigris edited this page Nov 25, 2017 · 2 revisions

What if our object has a field that can be thought of in different ways?

For example, a messages field that can be filtered into #read, #unread, and #all. #descriptionMessages would be the actual description, and then there could be a #descriptionUnreadMessages and #descriptionReadMessages which are dcescriptions of the filtered collections. By annotating these alternate descriptions with <magritteAltFor: #descriptionMessages order: aNumber>, these could be e.g. displayed as tabs in a Magritte form.

There are currently two hooks to retrieve this information:

  • Alternates only: myObject magritteAlternatesFor: #descriptionMessages
  • All descriptions in the group: myObject magritteAllDescriptionsFor: #descriptionMessages

At the moment, there is no higher level support, so you would have to decide what you wanted to do with that information. For example, you could show them in a Glamour browser like this:

projectPresentationsIn: container for: messages
	(projectList magritteAllDescriptionsFor: #descriptionMessages)
		do: [ :d | 
			container fastTree
				display: [ :l | d read: messages ];
				title: d label;
				children: #children ]
Clone this wiki locally