[deepamehta-devel] Enabling label for association

Jörg Richter jri at deepamehta.de
Thu Oct 20 23:47:49 CEST 2016


Hi Robert,

the detail panel's info/form renderer never uses the custom association type names for rendering title labels.

The Contacts and Events modules achieve the rendering solely trough CSS rules, using pseudo elements:

contacts.css:

	div.dm4\.contacts\.person > div.dm4\.datetime\.date::before {
		content: "Date of Birth";
		display: block;
		margin-bottom: 0.6em;
		font-size: 0.75em;	/* must match .field-label style in webclient.css */
		color: gray;		/* must match .field-label style in webclient.css */
	}

events.css:

	div.dm4\.events\.event > div.dm4\.datetime\#dm4\.events\.from::before {
		content: "From";
		... same as above
	}

	div.dm4\.events\.event > div.dm4\.datetime\#dm4\.events\.to::before {
		content: "To";
		... same as above
	}

These rules are based on the semantic markup generated by the detail panel renderer. It annotates each <div> with the DM type URIs as CSS class names.

The backslash is the escape character in CSS. It is needed in CSS rules if a class name contains characters that have special meaning in CSS.

In your plugin you have to add corresponding rules for each of your types.

Note: css files located in your plugin's /resources/web/style directory are picked up automatically by the Webclient.

Be aware: the Person rule doesn't use the "#dm4.contacts.date_of_birth" qualifier. Basically it says all kinds of Person dates are "Date of Birth". This hinders extensibility. You could write a ticket about fixing that Contacts CSS. In the meantime your plugin should override that Person rule.

Tell me if you need more help.

BTW: of course the CSS approach is not very comfortable for rendering title labels. It was just a pragmatic approach as it works immediately without extending DM. This way the plugin author can control what labels to render. Usually some Custom Association Type names need to be rendered, but some are not (e.g. the Contacts module's "Address Entry" and "Phone Entry"). Possible solutions would be a configuration option (e.g. extending DM's ViewConfig model), or a one-fits-all renderer heuristic like: if the custom association type is SIMPLE and the child type is COMPOSITE then render the association type name as title label (the detail renderer deploys such heuristics already). You could write a ticket about this as well.

Your code looks good btw :-)

Cheers,
Jörg


> On 20 Oct 2016, at 20:15, Robert Schuster <robert.schuster.rs01 at gmail.com> wrote:
> 
> Hi alltogether,
> I am adding "To" and "From" associations to a bunch of topic types like
> this:
> 
> 	return dm4.getTopicType(topicTypeUri)
> 		.addAssocDef(mf.newAssociationDefinitionModel(
> 			"dm4.core.aggregation_def", "dm4.events.from",
> 			topicTypeUri, "dm4.datetime.date",
> 			"dm4.core.many", "dm4.core.one"))
> 		.addAssocDef(mf.newAssociationDefinitionModel(
> 			"dm4.core.aggregation_def", "dm4.events.to",
> 			topicTypeUri, "dm4.datetime.date",
> 			"dm4.core.many", "dm4.core.one"));
> 
> As the custom association type "dm4.events.from" and "dm4.events.to"
> suited my need so far I used those. However there is the slight issue
> that in the webclient those associations appear with no title label in
> the edit form.
> 
> What I would like to have is that they are labeled "From" and "To"
> exactly as one can see in instances of dm4.events.event .
> 
> Any pointer on what I am missing here?
> 
> All the best,
> Robert

-------------- n�chster Teil --------------
Ein Dateianhang mit Bin�rdaten wurde abgetrennt...
Dateiname   : signature.asc
Dateityp    : application/pgp-signature
Dateigr��e  : 496 bytes
Beschreibung: Message signed with OpenPGP using GPGMail
URL         : <http://lists.deepamehta.de/pipermail/devel-lists.deepamehta.de/attachments/20161020/48958996/attachment.sig>


More information about the devel mailing list