Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

Goal

Make it easier to implement dialogs in Admincentral where the fields can be dynamically changed, based on other fields.

For example make these easy, fast, clear, powerful to implement:

...

Maybe expressions are indicated by parenthesis.

Code Block
( isWizard & ( hasSpellSlots | hasWand)))

For example, these properties could use expressions: enabled, visible, required, label, buttonLabel, optionsExpressions would also have access to some context such as the current user group and role, so that some fields would only be visible or enabled to certain user roles. (TODO add an example of that.)


2. Provide ways to augment fields, potentially with Java, that do not require creating brand new fieldTypes. Creating fieldTypes is harder, slower & less transparent then augmenting a fieldType with some custom behaviour.

...

Is there a nice way that, for any thing that can take an inline expression, it could also take an external javascript function, or a java class?

ie enabled, visible, label, buttonLabel, options

Would we need to add additional properties like enabledClass, visibleClass....?

Features

User, Group and Role aware

Expressions would also have access to some context such as the current user group and role, so that some fields would only be visible or enabled to certain user roles. 

Code Block
fields:
	html:
		fieldType: code
		visible: ( context.hasRole('developer'))  #or something like that!

Dynamically Enabled

The enabled property can take a logical expression as well as a simple boolean value.

Code Block
fields:
	isBarbarian:
		fieldType: checkbox
		type: Boolean
	isElf
		fieldType: checkbox
		type: Boolean
    barbarianElfHatType:
		fieldType: text
		enabled: ( isBarbarian & isElf )
        description: What type of hat is your elven barbarian wearing?

Image Added

Dynamically Visible

A field is only visible on a form, if the  "visible" expression evaluates to true.

...

Code Block
fields:
	clericSpells:
		fieldType: text
		validators:
            onlyClericOrWizard:
              class: info....ExpressionValidator
              expression: (!(clericSpells!="" & wizardSpells!=""))
			  errorMessage: Only Cleric OR Wizard spells allowed, not both.


Image Added

Dynamic Label & Dynamic Button Labels

...

We provide some out-of-the-box modes where no custom coding is required, but also make it easier for developers to fulfil this use case with a minimum of coding for more custom use cases.


Dynamic Select

dynamicSelect

...

:

A select field which populates based on an optionModel and parametes which can come from other fields

optionModel:

Developer provides a Java class or a Javascript function which takes the values of the fields specifed in "optionModelArguments" as arguments, and returns an array of label & value pairs to populate the options field with.

Options list is empty until the "optionModelArguments" fields have values.

...

.

...

Another example:


Code Block
fields:
	country:
		fieldType: select
		path: /
		repository: countries

    state:
		fieldType: dynamicSelect
		optionModelArguments
			- country										#references 'country' field.
		optionModel: org.dandelion......StatesPerCountry

    postalCode:
		fieldType: dynamicSelect
		optionModelArguments
			- state											#references 'state' field.
		optionModel: org.dandelion......PostalCodesPerState

Image Added

Node Chooser

Out-of-the-box fields based on a heirarchy of nodes. (Probably JCR bound.)

...

Code Block
fields:
	ecommerceSystem:
		fieldType: select
		options:
			- elasticPath
			- shopify

	category:
		fieldType: dynamicRESTSelect
		datasource: 
            $type: jsonDatasource
            restClient: (ecommerceSystem) #dynamic based on value in 'ecommerceSystem' field.
            restCall: categories

    assets:
		fieldType: dynamicRESTLink
		datasource: 
            $type: jsonDatasource
            restClient: (ecommerceSystem) #dynamic based on value in 'ecommerceSystem' field.
            restCall: products
			restCallParameters:
				- category: (category) #dynamic based on value in 'category' field.

Image Added

Java Improvements

In addition to the above improvements, we want to make it easier to implement sophisticated use cases in Java.

  • Make fields available to each other in Java - so that customers are not forced to make a composite field anytime they want to program fields that interact with one another.

Notes

Take a look at linked tickets on: 

Jira
serverMagnolia - Issue tracker
serverId500b06a6-e204-3125-b989-2d75b973d05f
keyMGNLUI-2542

...