Dynamic classes based on microflow

2
I would like to use a badge widget to show a specific project status. The thing is that these statuses can be very many. I would like the administrator to be able to add new statuses and delete existing ones, but at the same time to be able to specify the background colour. Of course, such a value is in the entity.    My question is how to use dynamic classes so that the colour is taken from this entity and shown on the badge in the data grid depending on the status of the project (there is a link between the project (entity A) and the stage (entity B)).   Unfortunately I do not manage to use dynamic classes what they expect enumeration type. I understand that microflow should be used but I don't know how to call it from the class level so that it returns the appropriate values, e.g. in the form of the text "bacground-color = red".    Or perhaps there is an alternative way to retrieve these values using an association between two entities? Xpath does not allow me to retrieve values from entity B.
asked
2 answers
5

HI Marc,

What you can do is, you can write some Css Classes in customStyle.scss lets say

.class1{

background-color: red

}
.class2{
background-color: blue
}

 

then, in the dynamic classes section, you can write if else condition based on the attribute value, and set the classes,

eg.

if $object/attribute='xyz' then 'class1'
else 'class2'

 

Let me know, if you face any issues,

Hope it helps!

answered
1

Having a status, which is maintained in runtime give some challenges in using it for dynamic classes

  1. The fact that you cannot access referenced objects > can be solved, see my example
  2. You can create the dynamic status, but the available classes will be statics, as these are part of your coded CSS > cannot be solved as far as my knowledge goes. and it the limitation

 

You could create this domain model, where the Status is captured in an entity, which also contains the desired class.

 

The class set on the status, can be plotted on the DynamicClass attribute using a calculated attribute, with this microflow as source

Still, the class can be defined by an administrator, if this doesn't exist in your CSS, it won't work.

Since your classes are static, I would opt for a enum on your project and NOT provide the admin to maintain the statusses. My experience is that requirements regarding dynamic statussess “so we can maintain them ourselves”……. in real they will add the statusses once and forget that they can change them. 

TLDR: go for an enum, dynamic statussess aren't dynamic ;-)

answered