Skip to content

[RFR] Clarify Map logic, allow nested fields#549

Merged
jeromemacias merged 19 commits intomasterfrom
map_transform
Jul 10, 2015
Merged

[RFR] Clarify Map logic, allow nested fields#549
jeromemacias merged 19 commits intomasterfrom
map_transform

Conversation

@fzaninotto
Copy link
Copy Markdown
Member

Currently, callbacks registered on fields with map() are applied to the REST response to turn it into an Entry (when fetching results) AND to the entries to turn them into a response (when pushing modifications). It doesn't make sense, and prevents some new features, such as deeply nested fields (refs. #525).

This PR fixes that. Now you can do things like:

listView.fields([
    nga.field('title'),
    nga.field('author.name')
]);

to map REST responses looking like:

[
  {
    "title": "War and Peace",
    "author": {
      "name": "Leo Tolstoi"
    }
  },
  {
    "title": "Anna Karenina",
    "author": {
      "name": "Leo Tolstoi"
    }
  }
]

Depends on marmelab/admin-config#20

@fzaninotto fzaninotto changed the title [WIP] Clarify Map logic, allow nested fields [RFR] Clarify Map logic, allow nested fields Jul 9, 2015
@fzaninotto
Copy link
Copy Markdown
Member Author

Switching to RFR!

package.json Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

admin-config 0.2.5 version had been published.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switched dependency to fixed version

jeromemacias added a commit that referenced this pull request Jul 10, 2015
[RFR] Clarify Map logic, allow nested fields
@jeromemacias jeromemacias merged commit d404831 into master Jul 10, 2015
@jeromemacias jeromemacias deleted the map_transform branch July 10, 2015 07:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants