Skip to content

Fix fields exposition (temporary solution) #476

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

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/formGenerator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,24 @@ import { get as objGet, forEach, isFunction, isNil, isArray } from "lodash";
import formMixin from "./formMixin.js";
import formGroup from "./formGroup.vue";

let fieldComponents = { formGroup };

let coreFields = require.context("./fields/core", false, /^\.\/field([\w-_]+)\.vue$/);

forEach(coreFields.keys(), key => {
let compName = key.replace(/^\.\//, "").replace(/\.vue/, "");
fieldComponents[compName] = coreFields(key).default;
});

if (process.env.FULL_BUNDLE) {
let Fields = require.context("./fields/optional", false, /^\.\/field([\w-_]+)\.vue$/);

forEach(Fields.keys(), key => {
let compName = key.replace(/^\.\//, "").replace(/\.vue/, "");
fieldComponents[compName] = Fields(key).default;
});
}

export default {
name: "formGenerator",
components: { formGroup },
Copy link
Member

Choose a reason for hiding this comment

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

you're not actually exposing them in the FormGenerator.components property. Shouldn't components: { formGroup } be components: { fieldComponents }?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yikes sorry !

Copy link
Member Author

Choose a reason for hiding this comment

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

Well, this break a lot of things :(

Copy link
Member Author

Choose a reason for hiding this comment

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

@zoul0813 I tried an alternative way to provide the same functionality.
It export fieldComponents, so you should be able to do that :

import { fieldComponents as VueFormGenerator } from 'vue-form-generator'; 
/* ... */
mixins: [ VueFormGenerator['fieldInput'] ],

or either

import { fieldComponents as coreFields} from 'vue-form-generator'; 
/* ... */
mixins: [ coreFields['fieldInput'] ],

Copy link
Member

Choose a reason for hiding this comment

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

"I" don't need this fix ... but if anyone did the same thing :)

Copy link
Member Author

Choose a reason for hiding this comment

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

This should work, have you tried it ?

Copy link
Member

Choose a reason for hiding this comment

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

haven't checked it, no ... but it looks like it will work just fine.

Should formGroup import the fieldComponents from index ... rather than repeating the same logic?

Copy link
Member Author

@lionel-bijaoui lionel-bijaoui Jul 3, 2018

Choose a reason for hiding this comment

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

I have refactored the code, they share a module which load the components

Expand Down