Migrate ABViewForm#715
Conversation
…he included plugins directory
|
Please add one release label: |
… in view_form plugin
johnny-hausman
left a comment
There was a problem hiding this comment.
You are definitely tackling a big project and you are off to a good start.
OK, So I have a thought about how we might make this a little less verbose.
What if we do two things:
-
make each of our Form items manage their own Core version. For example we let ABViewFormButton internally prepare it's ABViewFormButtonCore value.
-
we make a FormAPI value, that packages the necessary objects that all our related form items need.
If we do that, then we could simplify some of this setup to be like:
First, create a "barrel" file:
view_form/FormComponents.js:
export { default as FNAbviewformButton } from "./FNAbviewformButton.js";
export { default as FNAbviewformCheckbox } from "./FNAbviewformCheckbox.js";
export { default as FNAbviewformConnect } from "./FNAbviewformConnect.js";
export { default as FNAbviewformCustom } from "./FNAbviewformCustom.js";
export { default as FNAbviewformDatepicker } from "./FNAbviewformDatepicker.js";
export { default as FNAbviewformItem } from "./FNAbviewformItem.js";
export { default as FNAbviewformJson } from "./FNAbviewformJson.js";
export { default as FNAbviewformNumber } from "./FNAbviewformNumber.js";
export { default as FNAbviewformReadonly } from "./FNAbviewformReadonly.js";
export { default as FNAbviewformSelectMultiple } from "./FNAbviewformSelectMultiple.js";
export { default as FNAbviewformSelectSingle } from "./FNAbviewformSelectSingle.js";
export { default as FNAbviewformTree } from "./FNAbviewformTree.js";
export { default as FNAbviewformTextbox } from "./FNAbviewformTextbox.js";
export { default as FNAbviewformURL } from "./FNAbviewformURL.js";
Then your view_form/ABviewform.js would have:
let FormAPI = {
ABViewComponentPlugin,
ABViewFormItemComponent,
ABViewPropertyAddPage,
ABViewPropertyEditPage,
ABFieldImage,
FocusableTemplate,
}
import * as fObjs from "./FormComponents.js";
let views = Object.values(fObjs).map((FNv) => FNv(FormAPI));
views.forEach((v) => {
v.getPluginKey = () => v.common().key;
v.getPluginType = () => "view";
});
This could reduce some of the code in the main file and make things easier to read/follow.
Lighthouse Performance ReportMetrics📄Full Report |
Hiro-Nakamura
left a comment
There was a problem hiding this comment.
Wow! That was a lot of files.
Here are a few things to review:
# Conflicts: # AppBuilder/core # AppBuilder/platform/views/ABViewKanbanFormSidePanel.js # package-lock.json # package.json
# Conflicts: # AppBuilder/platform/ABClassManager.js # AppBuilder/platform/dataFields/ABFieldList.js # AppBuilder/platform/plugins/included/index.js
…d consistency and readability
johnny-hausman
left a comment
There was a problem hiding this comment.
these changes look good.
What about the Pending Comments?
| ABViewDataviewPropertyComponentDefaults.detailsTab; | ||
| this.settings.editTab = | ||
| this.settings.editTab || | ||
| ABViewDataviewPropertyComponentDefaults.editTab; |
There was a problem hiding this comment.
OK, I know this is how the original code was, but now that they are in the same file, it is easy to see that we are just reduplicating work in both of these, .fromValues() methods.
Update these to be ?? instead of || and remove the redundant checks down below.
| this.settings.detailsTab = | ||
| this.settings.detailsTab ?? ABViewDataviewDefaults.detailsTab; | ||
| this.settings.editTab = | ||
| this.settings.editTab ?? ABViewDataviewDefaults.editTab; |
| import FNABViewDetailComponent from "../view_detail/FNAbviewdetailComponent.js"; | ||
|
|
||
| export default function FNAbviewdataviewComponent({ | ||
| /*AB,*/ |
There was a problem hiding this comment.
you should probably uncomment this AB here so you can reference it below.
| this.initDetailComponent(); | ||
|
|
||
| const ids = this.ids; | ||
| const L = (...params) => (this.AB ?? AB).Multilingual.label(...params); |
There was a problem hiding this comment.
uncomment that /* AB */ above and it will be accessible here.
| clearTimeout(this.__throttleRefreshWarning); | ||
|
|
||
| this.__throttleRefreshWarning = setTimeout(() => { | ||
| $$(this.ids.reload)?.show(); |
There was a problem hiding this comment.
we should add a:
delete this.__throttleRefreshWarning;
here as well.
Moved the form system to a more modern structure and fixed several display and data bugs.
Relate PR.
CruGlobal/appbuilder_class_core#339
CruGlobal/plugin_ABDesigner#357