Skip to content

x-schema-form should accept all formats for titleMaps #889

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

Open
donalmurtagh opened this issue Jun 2, 2017 · 5 comments
Open

x-schema-form should accept all formats for titleMaps #889

donalmurtagh opened this issue Jun 2, 2017 · 5 comments

Comments

@donalmurtagh
Copy link
Contributor

donalmurtagh commented Jun 2, 2017

Steps to reproduce

  • Open the Plunker demo
  • Notice that the "Marital status" dropdown contains 3 blank entries
  • If the x-schema-form attributes are removed from the schema and moved to the form definition, it works. In other words, you can workaround the issue by changing the schema to:
    maritalStatus: {
      title: 'Marital status',
      type: 'string',
      'enum': ['married', 'single', 'cohabitating']
    }

and changing the form definition to:

    $scope.form = [{
      key: 'person.details.maritalStatus',
      titleMap: {
        married: 'Married',
        single: 'Single / separated / divorced / widow(er)',
        cohabitating: 'Living with a partner'
      }
    }];

The Plunker demo is using the latest code from the dev branches of angular-schema-form and angular-schema-form-bootstrap.

@json-schema-form/angular-schema-form-lead

@Anthropic
Copy link
Member

Thanks @donalmurtagh I will be able to make a test out of this to avoid it happening again once fixed, there's so many scenarios that don't have tests still, good to have someone using the framework in a way I don't, I appreciate you taking the time to report them :)

@Anthropic Anthropic added this to the 1.0.0 milestone Jun 3, 2017
@Anthropic Anthropic self-assigned this Jun 3, 2017
@Anthropic
Copy link
Member

Anthropic commented Jun 4, 2017

I checked in an old version and the same behaviour exists, the only supported version of titleMap within x-schema-form is an object list like the below:

titleMap: {
  { "value": "married", "name": "Married" },
  { "value": "single", "name": "Single / separated / divorced / widow(er)" },
  { "value": "cohabitating", "name": "Living with a partner" }
}

I can certainly see why it would help if this had of been documented!

It was before my time so the best I can offer is to update the documentation to indicate the requirement for now and keep this issue as an enhancement. I would accept a PR on it, but I can't see myself having the time to fix it given how little time I have unfortunately.

@Anthropic Anthropic modified the milestones: Backlog, 1.0.0 Jun 4, 2017
@donalmurtagh
Copy link
Contributor Author

the best I can offer is to update the documentation to indicate the requirement for now and keep this issue as an enhancement

that seems like a reasonable interim measure

@donalmurtagh
Copy link
Contributor Author

donalmurtagh commented Jun 6, 2017

@Anthropic I can confirm that the following successfully works around this issue

'x-schema-form': {
  titleMap: [
    {value: 'married', name: 'Married'},
    {value: 'single', name: 'Single / separated / divorced / widow(er)'},
    {value: 'cohabitating', name: 'Living with a partner'}
  ]
}

Notice that in your code snippet, you proposed assigning an object rather than an array to titleMap, which doesn't work

@Anthropic
Copy link
Member

Oh sorry, my being lazy I just copied your one from above and altered it to objects for each option and didn't alter the parent brackets :)

@Anthropic Anthropic changed the title x-schema-form broken in latest alpha x-schema-form should accept all formats for titleMaps Jun 6, 2017
Anthropic added a commit that referenced this issue Jun 25, 2017
Explain x-schema-form titleMap restreiction
Anthropic added a commit that referenced this issue Jun 25, 2017
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

2 participants