From 23e0b1a53e2d3d89b4e9c886fbf5c47a19e826cc Mon Sep 17 00:00:00 2001 From: Jose Chirivella Date: Fri, 27 Oct 2023 15:18:19 -0500 Subject: [PATCH 1/4] FOUR-11365 Added multiple index.js files to handle the exports and refactored / improved the install of VFE --- .../FormBootstrapVueComponents/index.js | 4 + src/components/FormSelectList/index.js | 5 + src/components/common/index.js | 4 + src/components/index.js | 121 ++++++++---------- src/components/mixins/index.js | 4 + vue.config.js | 9 +- 6 files changed, 72 insertions(+), 75 deletions(-) create mode 100644 src/components/FormBootstrapVueComponents/index.js create mode 100644 src/components/FormSelectList/index.js create mode 100644 src/components/common/index.js create mode 100644 src/components/mixins/index.js diff --git a/src/components/FormBootstrapVueComponents/index.js b/src/components/FormBootstrapVueComponents/index.js new file mode 100644 index 00000000..552878d4 --- /dev/null +++ b/src/components/FormBootstrapVueComponents/index.js @@ -0,0 +1,4 @@ +import BFormComponent from "./BFormComponent.vue"; +import BWrapperComponent from "./BWrapperComponent.vue"; + +export { BFormComponent, BWrapperComponent }; diff --git a/src/components/FormSelectList/index.js b/src/components/FormSelectList/index.js new file mode 100644 index 00000000..e4cc8c9a --- /dev/null +++ b/src/components/FormSelectList/index.js @@ -0,0 +1,5 @@ +import CheckboxView from "./CheckboxView.vue"; +import MultiSelectView from "./MultiSelectView.vue"; +import OptionboxView from "./OptionboxView.vue"; + +export { CheckboxView, MultiSelectView, OptionboxView }; diff --git a/src/components/common/index.js b/src/components/common/index.js new file mode 100644 index 00000000..4060ac88 --- /dev/null +++ b/src/components/common/index.js @@ -0,0 +1,4 @@ +import DisplayErrors from "./DisplayErrors.vue"; +import RequiredAsterisk from "./RequiredAsterisk.vue"; + +export { DisplayErrors, RequiredAsterisk }; diff --git a/src/components/index.js b/src/components/index.js index aa19d606..18a6fdf9 100644 --- a/src/components/index.js +++ b/src/components/index.js @@ -1,77 +1,58 @@ -// Import our components -import FormInput from './FormInput' -import FormCheckbox from './FormCheckbox' -import FormRadioButtonGroup from './FormRadioButtonGroup' -import FormSelect from './FormSelect' -import FormSelectList from './FormSelectList' -import FormTextArea from './FormTextArea' -import FormDatePicker from './FormDatePicker' -import FormAccordion from './FormAccordion' -import FormHtmlEditor from './FormHtmlEditor' -import FormHtmlViewer from './FormHtmlViewer' -import FormDelayTimeControl from './FormDelayTimeControl' -import FormMultiSelect from './FormMultiSelect'; -import FormPlainMultiSelect from './FormPlainMultiSelect'; -import RequiredAsterisk from './common/RequiredAsterisk'; -import * as dateUtils from '../dateUtils'; +import * as dateUtils from "../dateUtils"; -import BFormComponent from './FormBootstrapVueComponents/BFormComponent' -import BWrapperComponent from './FormBootstrapVueComponents/BWrapperComponent' +export { default as FormAccordion } from "./FormAccordion.vue"; +export { default as FormCheckbox } from "./FormCheckbox.vue"; +export { default as FormDatePicker } from "./FormDatePicker.vue"; +export { default as FormDelayTimeControl } from "./FormDelayTimeControl.vue"; +export { default as FormHtmlEditor } from "./FormHtmlEditor.vue"; +export { default as FormHtmlViewer } from "./FormHtmlViewer.vue"; +export { default as FormInput } from "./FormInput.vue"; +export { default as FormMultiSelect } from "./FormMultiSelect.vue"; +export { default as FormPlainMultiSelect } from "./FormPlainMultiSelect.vue"; +export { default as FormRadioButtonGroup } from "./FormRadioButtonGroup.vue"; +export { default as FormSelect } from "./FormSelect.vue"; +export { default as FormSelectList } from "./FormSelectList.vue"; +export { default as FormTextArea } from "./FormTextArea.vue"; +export * from "./common"; +export * from "./FormBootstrapVueComponents"; +export * from "./FormSelectList"; +export * from "./mixins"; +export { dateUtils }; -// Export our components -let components = { - FormInput, - FormCheckbox, - FormRadioButtonGroup, - FormSelect, - FormSelectList, - FormTextArea, - FormDatePicker, - FormAccordion, - FormHtmlEditor, - FormHtmlViewer, - FormDelayTimeControl, - FormMultiSelect, - FormPlainMultiSelect, - BFormComponent, - BWrapperComponent, -} +// Export our Vue plugin as our default +export default function install(Vue) { + // First check to see if we're already installed + if (Vue._processMakerVueFormElementsInstalled) { + return; + } -// Export our named exports -export { - FormInput, - FormCheckbox, - FormRadioButtonGroup, - FormSelect, - FormSelectList, - FormTextArea, - FormDatePicker, - FormAccordion, - FormHtmlEditor, - FormHtmlViewer, - FormDelayTimeControl, - FormMultiSelect, - FormPlainMultiSelect, - dateUtils, - RequiredAsterisk, - BFormComponent, - BWrapperComponent, -} + // Boolean flag to see if we're already installed + Vue._processMakerVueFormElementsInstalled = true; -// Export our Vue plugin as our default -export default { - install: function (Vue) { - // First check to see if we're already installed - if (Vue._processMakerVueFormElementsInstalled) { - return - } + // Register each of our components + const vueComponents = require.context("./", true, /\.(vue)$/); + + vueComponents.keys().forEach((key) => { + const component = vueComponents(key).default; - // Boolean flag to see if we're already installed - Vue._processMakerVueFormElementsInstalled = true + // if a component has a name defined use the name, else use the path as the component name + const name = component.name ? component.name : key.replace(/^.*[\\\/]/, "").replace(/\.[^/.]+$/, ""); - // Register each of our components - for (let component in components) { - Vue.component(component, components[component]) - } - } + Vue.component(name, component); + }); +} + +const plugin = { + install +}; + +// Auto-install when vue is found (eg. in browser via