Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
51 changes: 48 additions & 3 deletions ABFactoryCore.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// const _ = require("lodash");
// const uuidv4 = require("uuid");

const ABClassManager = require("../platform/ABClassManager");

const ABApplication = require("../platform/ABApplication");
const ABApplicationMobile = require("../platform/ABApplicationMobile");
const ABDefinition = require("../platform/ABDefinition");
Expand Down Expand Up @@ -97,6 +99,9 @@ class ABFactory extends EventEmitter {
this._allDatacollections = [];
// {array} of all the ABDataCollection(s) in our site.

this.ClassManager = ABClassManager;
// {ClassManager} the single source for our Class Libraries.

//
// Class References
//
Expand Down Expand Up @@ -275,6 +280,10 @@ class ABFactory extends EventEmitter {
}

init() {
// BEFORE Definitions are loaded,
// make sure any local Plugins are loaded.
this.ClassManager.registerLocalPlugins(this.pluginAPI());

let allDefinitions = Object.keys(this._definitions).map(
(k) => this._definitions[k]
);
Expand Down Expand Up @@ -679,13 +688,20 @@ class ABFactory extends EventEmitter {
objectNew(values) {
var newObj = null;

if (values.isExternal == true)
if (values.plugin_key) {
// If this is from a plugin, create it from ClassManager
newObj = this.ClassManager.createObject(
values.plugin_key,
values,
this
);
} else if (values.isExternal == true)
newObj = new ABObjectExternal(values, this);
else if (values.isImported == true)
newObj = new ABObjectImport(values, this);
else if (values.isNetsuite == true)
else if (values.isNetsuite == true) {
newObj = new ABObjectApiNetsuite(values, this);
else if (values.isAPI == true) newObj = new ABObjectApi(values, this);
} else if (values.isAPI == true) newObj = new ABObjectApi(values, this);
else newObj = new ABObject(values, this);

/*
Expand All @@ -707,6 +723,14 @@ class ABFactory extends EventEmitter {
return this.objectByID("d84cd351-d96c-490f-9afb-2a0b880ca0ec");
}

objectPlugin() {
return this.objectByID("8a20528a-e472-4e80-911a-b14285425caf");
}

objectPluginLinks() {
return this.objectByID("7ff322ff-3434-4611-9fd1-4d2996414c1a");
}

objectProcessDefinition() {
return this.objectByID("af91fc75-fb73-4d71-af14-e22832eb5915");
}
Expand Down Expand Up @@ -743,6 +767,27 @@ class ABFactory extends EventEmitter {
return this.objectByID("db5b3b26-5300-4c92-bc73-8ce4f4696992");
}

//
// Plugin
//
pluginAPI() {
let api = this.ClassManager.getPluginAPI();
api.AB = this;
api.platform = this.platform ?? "service";
return api;
}

pluginRegister(plugin) {
let pluginClass = plugin(this.pluginAPI());
if (Array.isArray(pluginClass)) {
pluginClass.forEach((p) => {
this.ClassManager.pluginRegister(p);
});
} else {
this.ClassManager.pluginRegister(pluginClass);
}
}

//
// Hints
//
Expand Down
5 changes: 3 additions & 2 deletions ABViewManagerCore.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ var AllViews = [
require("../platform/views/ABViewFormSelectSingle"),
require("../platform/views/ABViewFormTextbox"),
require("../platform/views/ABViewFormTree"),
require("../platform/views/ABViewFormURL"),
];

/*
Expand Down Expand Up @@ -120,8 +121,8 @@ module.exports = class ABViewManagerCore {
if (!isPlugin(values.key)) {
console.error(
"!! View[" +
values.key +
"] not yet defined. Have an ABView instead:"
values.key +
"] not yet defined. Have an ABView instead:"
);
}
return new Views["view"](values, application, parent);
Expand Down
4 changes: 2 additions & 2 deletions views/ABViewCore.js
Original file line number Diff line number Diff line change
Expand Up @@ -352,11 +352,11 @@ module.exports = class ABViewCore extends ABMLClass {
var form = null;

var curr = this;
while (curr.key != "form" && !curr.isRoot() && curr.parent) {
while (!curr.isForm && !curr.isRoot() && curr.parent) {
curr = curr.parent;
}

if (curr.key == "form") {
if (curr.isForm) {
form = curr;
}

Expand Down
1 change: 1 addition & 0 deletions views/ABViewFormCore.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const ABViewFormPropertyComponentDefaults = {
module.exports = class ABViewFormCore extends ABViewContainer {
constructor(values, application, parent, defaultValues) {
super(values, application, parent, defaultValues || ABViewFormDefaults);
this.isForm = true;
}

static common() {
Expand Down
Loading