enonic / lib-guillotine

Apache License 2.0
3 stars 0 forks source link

Incorrect value for field in macroAsJson if max occurrences more one #145

Closed anatol-sialitski closed 3 years ago

anatol-sialitski commented 3 years ago

Current implementation does not pay attention how many values (occurrences) can have a field when build macroAsJson field, but when macro type is generated occurrences are used.

For instance,

<input name="defaultText" type="TextLine">
   <label>Text to show if no user logged in</label>
</input>

AS IS:

"macroAsJson": {
   "defaultText" : [ "value" ]
},
"macros": {
    "testmacro": [
      {
        "defaultText": "[value]"
      }
    ]
}

SHOULD BE:

"macroAsJson": {
   "defaultText" : "value" 
},
"macros": {
    "testmacro": [
      {
        "defaultText": "value"
      }
    ]
}

If occurrences are specified

<input name="defaultText" type="TextLine">
   <label>Text to show if no user logged in</label>
   <occurrences minimum="0" maximum="2"/> 
</input>

Then

"macroAsJson": {
   "defaultText" : [ "value" ]
},
"macros": {
    "testmacro": [
      {
        "defaultText": [
             "value"
         ]
      }
    ]
}