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

Content lib - Modify-method changes values to strings in the site config #7255

Closed
arneroen opened this issue Jul 24, 2019 · 2 comments
Closed
Assignees
Labels
Milestone

Comments

@arneroen
Copy link

arneroen commented Jul 24, 2019

Hi,

I think I've found a bug where contentLib.modify will change booleans in the siteConfig to strings (eg true -> "true").
(Enonic XP version 7.0.1)
To reproduce it:

<?xml version="1.0" encoding="UTF-8"?>
<site>
  <form>
    <input type="CheckBox" name="someConfigValue">
      <label>label</label>
      <occurrences minimum="0" maximum="1"/>
      <default>checked</default>
    </input>
  </form>
</site>

And the function that modifies it is just

  contentLib.modify({
    key: '/path',
    branch: 'draft',
    requireValid: false, //to see the changes in the data structures. 
    editor: site => {
      return site
    }
  })

Using data toolbox we can inspect the config values before and after
Before:

"data": {
  "siteConfig": {
    "applicationKey": "com.example",
    "config": {
      "someConfigValue": true
    }
  }
}

After:

"data": {
  "siteConfig": {
    "applicationKey": "com.example",
    "config": {
      "someConfigValue": "true"
    }
  }
}
@GlennRicaud
Copy link
Contributor

@arneroen Thank you for reporting this bug. We will fix it in 7.0.3

@GlennRicaud
Copy link
Contributor

GlennRicaud commented Jul 30, 2019

@vbradnitski

The current fix is good and should be included in the final version.

But it does not solve the wider problem: SiteConfig forms are not used when modifying contents.

  • One solution would be to inline the site forms similar to mixins when calling FormJsonToPropertyTreeTranslator
    • The inline of site forms to be done before the mixins inlining)

To test the solution try the same thing but with the following site config

<?xml version="1.0" encoding="UTF-8"?>
<site>
  <form>
    <input name="myDate" type="Date">
      <label>Date</label>
      <occurrences minimum="0" maximum="0"/>
    </input>
  </form>
</site>

@GlennRicaud GlennRicaud added this to the 7.0.3 milestone Jul 30, 2019
vbradnitski added a commit that referenced this issue Aug 27, 2019
@GlennRicaud GlennRicaud changed the title content lib - Modify-method changes booleans to strings in the siteConfig Content lib - Modify-method changes values to strings in the site config Aug 29, 2019
@GlennRicaud GlennRicaud modified the milestones: 7.0.3, 7.1.0 Aug 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants