create-client icon indicating copy to clipboard operation
create-client copied to clipboard

Vuetify : error when entity are type entity_relatedentity

Open GRUXXKi opened this issue 4 years ago • 8 comments

API Platform version(s) affected: 1.2

Description
First, thanks a lot for the great job with this generator, the code is great to read !

I've a problem with generated entities in Vuetify wich name is with an underscore.

How to reproduce

Make an entity Article and a ArticleCategory entity with a many to one relation.

If i want to go to check all the ArticleCategory, I've got multiple erros saying the store does'nt contains this.

It's like of the automatic crud generation does'nt work with 'article_category' because it contains an underscore.

Maybe it's something else.

Possible Solution

I've tryed to look for it with no solution for the moment.

GRUXXKi avatar Mar 27 '20 14:03 GRUXXKi

@GRUXXKi can you provide the command you use for generating the code for your entities ?

alOneh avatar Jun 23 '20 20:06 alOneh

Can you also show us your store/index.js ?

ma0dubois avatar Sep 11 '20 09:09 ma0dubois

@GRUXXKi can you provide the command you use for generating the code for your entities ?

I've used the one into documentation

Can you also show us your store/index.js ?

Got that kind of generated values :

import Vue from "vue";
import Vuex from "vuex";
import makeCrudModule from "./modules/crud";
import notifications from "./modules/notifications";

import fooService from "../services/foo";
import fooBarService from "../services/foobar";
import VuexPersistence from "vuex-persist";

const vuexPersist = new VuexPersistence({
  key: 'mykey',
  storage: localStorage
})

Vue.use(Vuex);

const store = new Vuex.Store({
  modules: {
    notifications,
    userparameters,
    foo: makeCrudModule({
      service: fooService
    }),
    fooBar: makeCrudModule({
      service: fooBarService
    }),
  },
  strict: process.env.NODE_ENV !== "production",
  plugins: [vuexPersist.plugin]
});

export default store;

GRUXXKi avatar Sep 11 '20 10:09 GRUXXKi

@GRUXXKi can you provide the command you use for generating the code for your entities ?

I've used the one into documentation

Can you also show us your store/index.js ?

Got that kind of generated values :

import Vue from "vue";
import Vuex from "vuex";
import makeCrudModule from "./modules/crud";
import notifications from "./modules/notifications";

import fooService from "../services/foo";
import fooBarService from "../services/foobar";
import VuexPersistence from "vuex-persist";

const vuexPersist = new VuexPersistence({
  key: 'mykey',
  storage: localStorage
})

Vue.use(Vuex);

const store = new Vuex.Store({
  modules: {
    notifications,
    userparameters,
    foo: makeCrudModule({
      service: fooService
    }),
    fooBar: makeCrudModule({
      service: fooBarService
    }),
  },
  strict: process.env.NODE_ENV !== "production",
  plugins: [vuexPersist.plugin]
});

export default store;

Where is your service ? you need to declare your own service, like explain in the documentation.

ma0dubois avatar Sep 11 '20 11:09 ma0dubois

import fooService from "../services/foo"; import fooBarService from "../services/foobar";

Here, no ?

GRUXXKi avatar Sep 22 '20 06:09 GRUXXKi

yes, but your service articleService and articleCategoryService ?

ma0dubois avatar Sep 22 '20 06:09 ma0dubois

Sorry, I have like 30 services, so I've just made an example of the code I have.

But sure I have :

...
import animationService from "../services/animation";
import animationCategorieService from "../services/animationcategorie";
........
const store = new Vuex.Store({
  modules: {
   notifications,
    animation: makeCrudModule({
      service: animationService
    }),
    animationCategorie: makeCrudModule({
      service: animationCategorieService
    }),
   ........

GRUXXKi avatar Sep 22 '20 07:09 GRUXXKi

I also found it weird, but it's ok ^^

If I remember correctly, I also had this error at the beginning. And I believe, that I just declared the name of my module in lowercase. Exactly like the service filename. Can you try?

exemple:

...
import animationService from "../services/animation";
import animationCategorieService from "../services/animationcategorie";
........
const store = new Vuex.Store({
  modules: {
   notifications,
    animation: makeCrudModule({
      service: animationService
    }),
    animationcategorie: makeCrudModule({
      service: animationCategorieService
    }),
   ........

ma0dubois avatar Sep 22 '20 07:09 ma0dubois