Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display Tag does not render 'id', 'dateCreated' and 'lastUpdated' fields. #311

Open
codeconsole opened this issue Sep 21, 2020 · 0 comments
Labels
enhancement help wanted Please submit pull-request

Comments

@codeconsole
Copy link
Contributor

codeconsole commented Sep 21, 2020

Following the work done on #257

You would except to be able to do something like this:
<f:display bean="challenge" except="[]" />

and see id, dateCreated, and dateUpdated

Furthermore, I believe you would expect FormFieldsTagLib.resolvePersistentProperties to call domainModelService.geOutputProperties(domainClass)`

as it is defined as The list of {@link DomainProperty} instances that are to be visible

I realize that there should be some synergy between the edit and the view page and such a change could be followed by requiring attrs.except like was done for #257 However, it is a feature I am constantly looking for because I have no way of knowing the dateCreated and dateUpdated as well as the id (unless I look at the url).

Since the display tag already calls FormFieldsTagLib.resolvePersistentProperties implementing this fix is as simple as

  1. Creating an enum FormFieldsTagLib.PropertiesType = { LIST, OUTPUT, INPUT }
  2. Changing
    private List<PersistentProperty> resolvePersistentProperties(PersistentEntity domainClass, Map attrs, boolean list = false) {
    to
    private List<PersistentProperty> resolvePersistentProperties(PersistentEntity domainClass, Map attrs, PropertiesType propertiesType = PropertiesType.INPUT ) {

and modifying the method
properties = propertiesType == PropertiesType.LIST ? domainModelService.getListOutputProperties(domainClass) : propertiesType == PropertiesType.INPUT ? domainModelService.getInputProperties(domainClass) : domainModelService.getOutputProperties(domainClass) // If 'except' is not set, but 'list' is, exclude 'id', 'dateCreated' and 'lastUpdated' by default List<String> blacklist = attrs.containsKey('except') ? getList(attrs.except) : (propertiesType == PropertiesType.LIST ? ['id', 'dateCreated', 'lastUpdated'] : [])

Then changing the existing calls to FormFieldsTagLib.resolvePersistentProperties
in 2 locations

def display = { attrs, body ->

resolvePersistentProperties(domainClass, attrs, PropertiesType.OUTPUT)

and
private List<String> resolvePropertyNames(PersistentEntity domainClass, Map attrs) {

List<String> properties = resolvePersistentProperties(domainClass, attrs, PropertiesType.INPUT)*.name

@sbglasius sbglasius added enhancement help wanted Please submit pull-request labels Jul 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement help wanted Please submit pull-request
Projects
None yet
Development

No branches or pull requests

2 participants