-
Notifications
You must be signed in to change notification settings - Fork 86
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
Shortcut for multiple object properties #43
Comments
I'll consider it, but I can't promise anything. Thank you for suggesting it. |
|
@maoberlehner please consider this modification which implements the feature: anikolaev@fd0c1ad Usage is almost the same as for multi-row (array) fields. In *.vue: <input v-model="selectedSeries.name"/>
<input v-model="selectedSeriesYAxis.name"/>
...
const mapSelectedSeriesFields = createHelpers({
getterType: 'forms/getSelectedSeriesField',
mutationType: 'forms/updateSelectedSeriesField'
}).mapObjectFields
...
export default {
computed: {
...mapSelectedSeriesFields({
selectedSeries: '*',
selectedSeriesYAxis: 'y_axis.*',
}),
} As you can see I used it to access data for selected series using specific getter and setter for that and storing selected series index in store too. That is one of the solutions for dynamic properties but it is another issue. |
@anikolaev thank you for providing a code example. I'll take a closer look at the weekend 👍 |
Nice @anikolaev, using your fork for now :). Maybe useful for somebody: you need a getter like this getNestedField: state => path => {
if (path === '')
return state.foo;
return state.foo[path];
}, returning the whole updateNestedField(state, {path, value}) {
state.foo[path] = value;
}, |
@stijnjanmaat It should work with library's getField() too: import { getField, updateField } from 'vuex-map-fields'
getNestedField(state) {
return getField(state.foo);
},
...
updateNestedField(state, field) {
updateField(state.foo, field);
}, |
Hey all! Sorry for letting you wait – I just want to let you know that I've not forgotten about this. But I shifted my priorities to different projects for the last couple of weeks. I'll work on this as soon as I can free up some time. Thank you for your patience! |
@maoberlehner I understand you. I've also shifted project and the new one unfortunately doesn't use Vue. But I hope you will find time to improve this lib as I found it very useful for complex forms. |
This is how I am using
getMapFieldsList will return a list of fields in the state object which can be passed to mapFields ...mapFields([...VuexMapFieldService('state.UserProfile.form', 'form'), 'form', 'loading', 'error']),
|
Would it not be better just to do this to get the entire object? Adding an asterisk * introduces a new thing that is not needed. |
Yes that is exactly what I am looking for. I have a formData object where all the field data gets in. Then I want to bind it via v-model to this data. It is a plain Object with no nested elements as i break array structured down to and index identifier. |
Has this been implemented, I can find anything about it, trying to have an object passed through like so (on strict mode it doesn't like it):
And in my component, I'd love to be able to do something like this:
Which would allow me to use |
@shanehoban no it has not been implemented. Are you expecting that each item in the object is mapped to the vm root? |
Thanks @geoidesic. To answer your question, I don't really understand how the internals work, but my expectation is that I will always be accessing object properties via dot notation eg.:
so |
Hey Markus,
would it make sense to allow to do the following?
Then in the form one can easily use
v-model="myObject.title"
etc. Right now, I find it a bit cumbersome/not scalable to have to add each field to that array in mapFields.The text was updated successfully, but these errors were encountered: