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

mapMultiRowFields does something strange with an array? #27

Closed
driekus77 opened this issue May 28, 2018 · 4 comments
Closed

mapMultiRowFields does something strange with an array? #27

driekus77 opened this issue May 28, 2018 · 4 comments
Assignees
Labels

Comments

@driekus77
Copy link

Hi All,

I liked how-to-structure-a-complex-vuex-store a lot and I'm trying to use the idea's.

Unfortunately it looks like my "vue-tables-2": "^1.4.50" is not working fine together with mapMultiRowFields from "vuex-map-fields": "^1.2.3".

It looks to come down to the code in my form:

      ...mapUsersFields({
        users: 'rows',
        selectedSeqno: 'selectedSeqno',
        currentPage: 'currentPage',
      }),

      ...mapUsersMultiRowFields(
        { multiUsers: 'rows' }
      ),

users is working fine inside the vue-tables-2 but multiUsers is not. v-for..loop on multiUsers is working perfect so it could be that it's a problem with the table.
But I don't know what to say to the vue-tables-2 team what mapUsersMultiRowFields does? Can you elaborate a little bit? In the debugger I noticed something like reactiveGetter & reactiveSetter being added. Is this all there is?

My users.js store code (partly):

export const { mapFields: mapUsersFields } = createHelpers({
	getterType: 'admin/users/getField',
	mutationType: 'admin/users/UpdateField'
});

export const { mapMultiRowFields: mapUsersMultiRowFields } = createHelpers({
	getterType: 'admin/users/GetField',
	mutationType: 'admin/users/UpdateField'
});

The captial GetField is called in the debugger and seems to be working fine.

Hopefully you can point me in the right direction for a solution.

Kind regards,
Henry

@maoberlehner maoberlehner self-assigned this May 28, 2018
@maoberlehner
Copy link
Owner

Hi @driekus77 it would be great if you could provide a reduced test case to demonstrate the problem. Ideally on https://jsfiddle.net/

Thanks!

@driekus77 driekus77 changed the title mapMultiRowFields does something strange with and array? mapMultiRowFields does something strange with an array? May 28, 2018
@driekus77
Copy link
Author

Hi @maoberlehner ,

Took me some time to figure jsfiddle out: https://jsfiddle.net/y5w72x87/33/

If you switch in the computed part:

  computed: {
        ...mapTodoFields({
        todos: 'todos',
      }),

      ...mapTodoMultiRowFields(
        { mtodos: 'todos' }
      )
  },

mapTodoFields ==> todos and mapTodoMultiRowFields ==> mtodos 👍
mapTodoFields ==>ptodos and mapTodoMultiRowFields ==> todos 👎

Thanks for any help and/or feedback!

Kind regards,
Henry

@maoberlehner
Copy link
Owner

maoberlehner commented May 30, 2018

Hey @driekus77 thank you for creating the JSFiddle. Unfortunately I couldn't figure it out why it doesn't work with vue-tables-2. I tried to take a look into the vue-tables-2 source code to dig deeper, but, puhhh, vue-tables-2 is about 300 kb of JavaScript so...

But as far as I can see, vuex-map-fields does work fine in the JSFiddle – it's the combination with vue-tables-2 that doesn't work. I'd recommend you to open an issue in the vue-tables-2 project, maybe someone has an idea why it doesn't work with vuex-map-fields. All vuex-map-fields does, is to use getters and setters, it seems really odd to me that vue-tables-2 does something special which does not work with getters and setters – but as I said, maybe someone over there has an idea what could be the problem. Also, its way easier for them to look at my 3 kb of code to see if something in vuex-map-fields breaks the way vue-tables-2 works than it is for me to look into a 300 kb of code 😁

@driekus77
Copy link
Author

Oke man thanks for looking into it!

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

2 participants