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

Feature/map fields accept function and map entire objects #95

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

guilemos
Copy link
Contributor

  1. Support to map only one row that lives at a array/object when we are out of a loop and map all object properties

This is useful when working with "active row".

const state = {
  byId: {
    "/rooms/1": {
        name: "Nice room"
    },
    "/rooms/2": {
        name: "Nice room 2"
    },
  },
  allIds: ["/rooms/1", "/rooms/2"],
};
...mapFields('rooms', { item: 'byId[/rooms/2]' }),
<template>
    <v-input v-model="item.name" />
</template>
  1. Support to accept functions as path for mapFields and mapMultiRowFields
    This is useful to make map dynamic.
const state = {
  byId: {
    "/rooms/1": {
        name: "Nice room"
    },
    "/rooms/2": {
        name: "Nice room 2"
    },
  },
  allIds: ["/rooms/1", "/rooms/2"],
};
data() {
  return {
    ative_room: '0'
  };
},
computed: {
  ...mapFields({name: (c) => `users[${c.ative_room}].name` }),
}
<div>
   <input v-model="name">
</div>

Thank you

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 50e3c03 on guilemos:feature/mapFields-accept-function-and-map-entire-objects into ae30a03 on maoberlehner:master.

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