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

Inconsistent treatment of field and element names in JSON Schema generated by Template Designer #923

Open
martinjoconnor opened this issue Jun 8, 2023 · 0 comments

Comments

@martinjoconnor
Copy link
Member

[Copied from cedar-user mailing list; reported by balazs.pataki@sztaki.hu]

There's a strange behviour when using Elements in Templates. This may be the intended way to work, but nevertheless confusing. I try to describe it, but if it is not fully understandable I could also explain it in a short call if you are available.

I have an Element called "person", which consists of say a "name" and "email".

Use case one: I want to add this "person" element to the template but want to call it "author".

After I add the element and rename it in "Enter Element Name" the name is only aliased in _ui.propertyLabels like this:

    "_ui": {
        "propertyLabels": {
          "person": "author"    
        }
    }

while under properties it remains with the same name, ie.

"properties": {
    "person": {
        ...
    }
}

This seems to be inconsistent with how renaming the label of a normal field works. In that case when I rename eg. "name" to "personName" both the
"propertyLabels" and the "properties" key is updated to personName. Ie.:

    "_ui": {
        "propertyLabels": {
          "personName": "personName"    
        }
    }

    "properties": {
        "personName": {
            ...
        }
    }

Use case two: I want to add this "person" element to the template once as "author" and once as "editor".

In this case renaming the first instance of the Element to "author" results in the same behaviour as above. When adding the second instance and renaming it to "editor" I get these values:

    "_ui": {
        "propertyLabels": {
          "person": "author",
          "person1": "editor"    
        }
    }

    "properties": {
        "person": {
            ...
        },    
        "person1": {
            ...
        }
    }

To avoid name clashes a new "person1" field is introduced with an "editor" alias.

The first problem I see is that while working on the template this "person1" is not known by the user, this is not displayed anywhere, the user is only aware of the "editor" label he added. In this specific case it could have been even named "editor" just as the user entered. When the user then populates metadata with this template he would be surprised that the metadata field will be "person1" and not "editor".

So, overall the problem I am facing is that renaming field labels and element instance labels is somehow not consistent and the editor of the template is not aware of new names introduced by the system (ie. person1).

Would there be any problem to use the same keys in "properties" that the user enters as a field/element name? For example, for the second use case I would expect to have this in the template:

"_ui": {
    "propertyLabels": {
      "author": "author",
      "editor": "editor"    
    }
}

"properties": {
    "author": {
        ...
    },    
    "editor": {
        ...
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant