qcobjects 2.4.50 → 2.4.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/QCObjects.js +105 -37
- package/VERSION +1 -1
- package/package.json +1 -1
package/QCObjects.js
CHANGED
|
@@ -1310,9 +1310,12 @@
|
|
|
1310
1310
|
return shortCode;
|
|
1311
1311
|
};
|
|
1312
1312
|
var uniqueId = shortCode;
|
|
1313
|
+
Class("InheritClass", class {}, {});
|
|
1314
|
+
|
|
1315
|
+
class Processor extends ClassFactory("InheritClass") {
|
|
1316
|
+
component = null;
|
|
1313
1317
|
|
|
1314
|
-
|
|
1315
|
-
processors: {
|
|
1318
|
+
static processors= {
|
|
1316
1319
|
"config"(arg) {
|
|
1317
1320
|
return _top.CONFIG.get(arg, "");
|
|
1318
1321
|
},
|
|
@@ -1322,48 +1325,63 @@
|
|
|
1322
1325
|
"global"(arg) {
|
|
1323
1326
|
return (typeof global !== "undefined") ? (global[arg]) : ("");
|
|
1324
1327
|
}
|
|
1325
|
-
}
|
|
1326
|
-
setProcessor(_proc_) {
|
|
1328
|
+
};
|
|
1329
|
+
static setProcessor(_proc_) {
|
|
1327
1330
|
if (typeof _proc_ === "function" && _proc_.name !== "") {
|
|
1328
1331
|
this.processors[_proc_.name] = _proc_;
|
|
1329
1332
|
}
|
|
1330
|
-
}
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1333
|
+
}
|
|
1334
|
+
|
|
1335
|
+
constructor (){
|
|
1336
|
+
super(...arguments);
|
|
1337
|
+
this.processors = Processor.processors;
|
|
1338
|
+
this.process = Processor.process.bind(this);
|
|
1339
|
+
this.processObject = Processor.processObject.bind(this);
|
|
1340
|
+
this.setProcessor = Processor.setProcessor.bind(this);
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1343
|
+
execute(component,processorName, args) {
|
|
1344
|
+
var processorHandler = this;
|
|
1345
|
+
var component = processorHandler.component;
|
|
1346
|
+
return processorHandler.processors[processorName].bind(processorHandler).apply(processorHandler,[component,...args.split(",")]);
|
|
1347
|
+
}
|
|
1348
|
+
|
|
1349
|
+
static process(template, component = null) {
|
|
1350
|
+
var processorHandler = this;
|
|
1336
1351
|
if (typeof template === "string") {
|
|
1337
|
-
let processorHandler = this;
|
|
1338
1352
|
Object.keys(processorHandler.processors).map(function (funcName) {
|
|
1339
1353
|
[...template.matchAll(new RegExp("\\$" + funcName + "\\((.*)\\).*", "g"))].map(
|
|
1340
1354
|
function (procesorMatch) {
|
|
1341
1355
|
var match0 = `$${funcName}(${procesorMatch[1]})`;
|
|
1342
|
-
template = template.replace(match0, processorHandler.execute.call(processorHandler, funcName, procesorMatch[1]));
|
|
1356
|
+
template = template.replace(match0, processorHandler.execute.bind(processorHandler).call(processorHandler, component, funcName, procesorMatch[1]));
|
|
1343
1357
|
}
|
|
1344
1358
|
);
|
|
1345
1359
|
});
|
|
1346
1360
|
}
|
|
1347
1361
|
return template;
|
|
1348
|
-
}
|
|
1349
|
-
|
|
1350
|
-
|
|
1362
|
+
}
|
|
1363
|
+
|
|
1364
|
+
static processObject(obj, component = null) {
|
|
1365
|
+
var __instance__ = this;
|
|
1351
1366
|
if (typeof obj === "object") {
|
|
1352
1367
|
Object.keys(obj).map(
|
|
1353
1368
|
function (_k) {
|
|
1354
1369
|
if (typeof obj[_k] === "object" && !obj[_k].hasOwnProperty.call(obj[_k], "call")) {
|
|
1355
|
-
obj[_k] = __instance__.processObject(obj[_k]);
|
|
1370
|
+
obj[_k] = __instance__.processObject.bind(__instance__)(obj[_k], component);
|
|
1356
1371
|
} else if (typeof obj[_k] === "string") {
|
|
1357
|
-
obj[_k] = __instance__.process(obj[_k]);
|
|
1372
|
+
obj[_k] = __instance__.process.bind(__instance__)(obj[_k], component);
|
|
1358
1373
|
}
|
|
1359
1374
|
}
|
|
1360
1375
|
);
|
|
1361
1376
|
} else if (typeof obj === "string") {
|
|
1362
|
-
obj = __instance__.process(obj);
|
|
1377
|
+
obj = __instance__.process.bind(__instance__)(obj, component);
|
|
1363
1378
|
}
|
|
1364
1379
|
return obj;
|
|
1365
1380
|
}
|
|
1366
|
-
|
|
1381
|
+
|
|
1382
|
+
}
|
|
1383
|
+
RegisterClass(Processor,"com.qcobjects");
|
|
1384
|
+
|
|
1367
1385
|
|
|
1368
1386
|
class ConfigSettings {
|
|
1369
1387
|
static _instance = null;
|
|
@@ -1826,7 +1844,6 @@
|
|
|
1826
1844
|
} else {
|
|
1827
1845
|
global.onload = _Ready;
|
|
1828
1846
|
}
|
|
1829
|
-
Class("InheritClass", class {}, {});
|
|
1830
1847
|
|
|
1831
1848
|
/**
|
|
1832
1849
|
* Dynamic Data Objects Class
|
|
@@ -1917,8 +1934,13 @@
|
|
|
1917
1934
|
}
|
|
1918
1935
|
Export(DDO);
|
|
1919
1936
|
|
|
1920
|
-
|
|
1921
|
-
template
|
|
1937
|
+
class DefaultTemplateHandler {
|
|
1938
|
+
template= "";
|
|
1939
|
+
__definition = {};
|
|
1940
|
+
constructor ({component, template}){
|
|
1941
|
+
this.component = component;
|
|
1942
|
+
this.template = template;
|
|
1943
|
+
}
|
|
1922
1944
|
assign(data) {
|
|
1923
1945
|
var templateInstance = this;
|
|
1924
1946
|
if (typeof templateInstance.component === "undefined") {
|
|
@@ -1928,26 +1950,36 @@
|
|
|
1928
1950
|
throw new Error("DefaultTemplateHandler.assign: component.processorHandler is undefined");
|
|
1929
1951
|
}
|
|
1930
1952
|
var processorHandler = templateInstance.component.processorHandler;
|
|
1953
|
+
processorHandler.component = templateInstance.component;
|
|
1931
1954
|
var parsedAssignmentText = (typeof templateInstance.template !== "undefined") ? (templateInstance.template) : ("");
|
|
1932
1955
|
if (typeof data === "object") {
|
|
1933
1956
|
[...Object.keys(data)].map(function (k) {
|
|
1934
1957
|
var _value = data[k];
|
|
1935
1958
|
if (typeof _value === "string" || typeof _value === "number" || (!isNaN(_value))) {
|
|
1936
1959
|
try {
|
|
1937
|
-
_value = ClassFactory("Processor").processObject.call(processorHandler, _value);
|
|
1960
|
+
_value = ClassFactory("Processor").processObject.bind(processorHandler).call(processorHandler, _value, templateInstance.component);
|
|
1938
1961
|
parsedAssignmentText = parsedAssignmentText.replace((new RegExp(`{{${k}}}`, "g")), _value);
|
|
1939
1962
|
} catch (e) {
|
|
1940
|
-
logger.warn(
|
|
1963
|
+
logger.warn(`${templateInstance.component.name} could not parse processors.`);
|
|
1964
|
+
throw Error (`${templateInstance.component.name} could not parse processors. Reason: ${e.message}`);
|
|
1941
1965
|
}
|
|
1942
1966
|
}
|
|
1943
1967
|
});
|
|
1944
1968
|
} else {
|
|
1945
1969
|
logger.debug(`${templateInstance.component.name}.data is not an object`);
|
|
1946
1970
|
}
|
|
1947
|
-
|
|
1971
|
+
try {
|
|
1972
|
+
parsedAssignmentText = ClassFactory("Processor").processObject.call(processorHandler, parsedAssignmentText, templateInstance.component);
|
|
1973
|
+
}catch (e){
|
|
1974
|
+
logger.warn(`${templateInstance.component.name} could not parse processors.`);
|
|
1975
|
+
throw Error (`${templateInstance.component.name} could not parse processors. Reason: ${e.message}`);
|
|
1976
|
+
}
|
|
1948
1977
|
return parsedAssignmentText;
|
|
1949
1978
|
}
|
|
1950
|
-
|
|
1979
|
+
|
|
1980
|
+
}
|
|
1981
|
+
DefaultTemplateHandler.__definition = {};
|
|
1982
|
+
RegisterClass(DefaultTemplateHandler,"com.qcobjects");
|
|
1951
1983
|
|
|
1952
1984
|
var __routing_params__ = function (routing, routingPath) {
|
|
1953
1985
|
let standardRoutingPath = routing.path.replace(/{(.*?)}/g, "(?<$1>.*)"); //allowing {param}
|
|
@@ -2259,13 +2291,19 @@
|
|
|
2259
2291
|
request,
|
|
2260
2292
|
service
|
|
2261
2293
|
}) {
|
|
2262
|
-
var serviceResponse
|
|
2294
|
+
var serviceResponse;
|
|
2295
|
+
if (typeof service.JSONresponse !== "undefined" && service.JSONresponse !== null){
|
|
2296
|
+
serviceResponse = service.JSONresponse;
|
|
2297
|
+
} else {
|
|
2298
|
+
serviceResponse = service.template;
|
|
2299
|
+
}
|
|
2263
2300
|
if (_response_to_data_) {
|
|
2264
2301
|
if (typeof data === "object" && typeof serviceResponse === "object") {
|
|
2265
2302
|
data = Object.assign(data, serviceResponse);
|
|
2266
2303
|
} else {
|
|
2267
2304
|
data = serviceResponse;
|
|
2268
2305
|
}
|
|
2306
|
+
component.data = data;
|
|
2269
2307
|
}
|
|
2270
2308
|
component.serviceInstance = serviceInstance;
|
|
2271
2309
|
component.serviceData = data;
|
|
@@ -2621,7 +2659,9 @@
|
|
|
2621
2659
|
break;
|
|
2622
2660
|
case (_component.get("tplsource") === "inline"):
|
|
2623
2661
|
logger.debug("Component " + _component.name + " has specified template-source=inline, so it is assumed that template is already declared");
|
|
2624
|
-
_component
|
|
2662
|
+
(async function (_component){
|
|
2663
|
+
_component.feedComponent.bind(_component)();
|
|
2664
|
+
})(_component);
|
|
2625
2665
|
var standardResponse = {
|
|
2626
2666
|
request: null,
|
|
2627
2667
|
component: _component
|
|
@@ -2833,6 +2873,7 @@
|
|
|
2833
2873
|
component: _self,
|
|
2834
2874
|
template: value
|
|
2835
2875
|
});
|
|
2876
|
+
templateInstance.component = _self;
|
|
2836
2877
|
var selfData = _self.data;
|
|
2837
2878
|
if (Object.hasOwnProperty.call(_self, "assignRoutingParams") && _self.assignRoutingParams) {
|
|
2838
2879
|
try {
|
|
@@ -4586,7 +4627,7 @@
|
|
|
4586
4627
|
// Set Processors
|
|
4587
4628
|
(function (_top) {
|
|
4588
4629
|
|
|
4589
|
-
let mapper = function (componentName, valueName) {
|
|
4630
|
+
let mapper = function (componentInstance,componentName, valueName) {
|
|
4590
4631
|
/*
|
|
4591
4632
|
* Mapper processor
|
|
4592
4633
|
* @usage
|
|
@@ -4597,16 +4638,19 @@
|
|
|
4597
4638
|
* the component instance, the data object or a global value
|
|
4598
4639
|
*/
|
|
4599
4640
|
|
|
4600
|
-
|
|
4641
|
+
var self = this;
|
|
4642
|
+
if (typeof componentInstance === "undefined" || componentInstance === null){
|
|
4643
|
+
throw Error (`mapper.${componentName}.${valueName} does not have a component instance or it is null.`);
|
|
4644
|
+
}
|
|
4601
4645
|
let globalValue = _top.global.get(valueName);
|
|
4602
|
-
let componentValue =
|
|
4603
|
-
let dataValue =
|
|
4646
|
+
let componentValue = componentInstance.get(valueName);
|
|
4647
|
+
let dataValue = componentInstance.data[valueName];
|
|
4604
4648
|
let list = (typeof dataValue !== "undefined") ? (dataValue) : ((typeof componentValue !== "undefined") ? (componentValue) : (globalValue));
|
|
4605
4649
|
let listItems = "";
|
|
4606
4650
|
if (typeof list !== "undefined" && typeof list["map"] !== "undefined") {
|
|
4607
4651
|
listItems = list.map(function (element) {
|
|
4608
|
-
let dataItems = [...Object.keys(element)].map(k => ` data-${k}="${element[k].toString()}"`).join("");
|
|
4609
|
-
return `<component name="${componentName}" ${dataItems} ></component>`;
|
|
4652
|
+
let dataItems = [...Object.keys(element)].map(k => ` data-${k}="${(typeof element[k] !== "undefined" && element[k] !== null)?(element[k].toString()):("")}"`).join("");
|
|
4653
|
+
return `<quick-component name="${componentName}" ${dataItems} ></quick-component>`;
|
|
4610
4654
|
}).join("");
|
|
4611
4655
|
} else {
|
|
4612
4656
|
logger.debug(`${componentName}.${valueName} does not have a map property`);
|
|
@@ -4615,7 +4659,7 @@
|
|
|
4615
4659
|
};
|
|
4616
4660
|
ClassFactory("Processor").setProcessor(mapper);
|
|
4617
4661
|
|
|
4618
|
-
let layout = function (layoutname, cssfile) {
|
|
4662
|
+
let layout = function (componentInstance, layoutname, cssfile) {
|
|
4619
4663
|
/*
|
|
4620
4664
|
* Layout processor
|
|
4621
4665
|
* @usage
|
|
@@ -4660,7 +4704,7 @@
|
|
|
4660
4704
|
* Returns a component tag declaration like:
|
|
4661
4705
|
* <component name=<name> ...></component>
|
|
4662
4706
|
*/
|
|
4663
|
-
let arg = [...arguments].map(function (a) {
|
|
4707
|
+
let arg = [...arguments].slice(1).map(function (a) {
|
|
4664
4708
|
return {
|
|
4665
4709
|
[a.split("=")[0]]: a.split("=")[1]
|
|
4666
4710
|
};
|
|
@@ -4675,7 +4719,31 @@
|
|
|
4675
4719
|
|
|
4676
4720
|
ClassFactory("Processor").setProcessor(component);
|
|
4677
4721
|
|
|
4678
|
-
let
|
|
4722
|
+
let quick_component = function () {
|
|
4723
|
+
/*
|
|
4724
|
+
* component processor
|
|
4725
|
+
* @usage
|
|
4726
|
+
* $quick_component(name=<name>, componentClass=<componentClass>, ...)
|
|
4727
|
+
* Returns a component tag declaration like:
|
|
4728
|
+
* <quick-component name=<name> ...></quick-component>
|
|
4729
|
+
*/
|
|
4730
|
+
let arg = [...arguments].slice(1).map(function (a) {
|
|
4731
|
+
return {
|
|
4732
|
+
[a.split("=")[0]]: a.split("=")[1]
|
|
4733
|
+
};
|
|
4734
|
+
}).reduce(function (k1, k2) {
|
|
4735
|
+
return Object.assign(k1, k2);
|
|
4736
|
+
});
|
|
4737
|
+
let attrs = [...Object.keys(arg)].map(function (a) {
|
|
4738
|
+
return `${a}=${arg[a]}`;
|
|
4739
|
+
}).join(" ");
|
|
4740
|
+
return `<quick-component ${attrs}></quick-component>`;
|
|
4741
|
+
};
|
|
4742
|
+
|
|
4743
|
+
ClassFactory("Processor").setProcessor(quick_component);
|
|
4744
|
+
|
|
4745
|
+
|
|
4746
|
+
let repeat = function (componentInstance, length, text) {
|
|
4679
4747
|
/*
|
|
4680
4748
|
* Repeat processor
|
|
4681
4749
|
* @usage
|
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.4.
|
|
1
|
+
2.4.52
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qcobjects",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.52",
|
|
4
4
|
"description": "QCObjects is an Open-source framework that empowers full-stack developers to make micro-services and micro-frontends into an N-Tier architecture.",
|
|
5
5
|
"main": "QCObjects.js",
|
|
6
6
|
"license": "LGPL-3.0",
|