qcobjects 2.4.9-beta → 2.4.16-beta

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.
Files changed (3) hide show
  1. package/QCObjects.js +55 -21
  2. package/VERSION +1 -1
  3. package/package.json +1 -1
package/QCObjects.js CHANGED
@@ -309,8 +309,14 @@
309
309
  }
310
310
  },
311
311
  info (message) {
312
+ var color;
312
313
  if (this.infoEnabled) {
313
- console.info("\x1b[33m%s\x1b[0m","[INFO] " + message);
314
+ if (isBrowser) {
315
+ color = "\x1b[103m%s\x1b[0m";
316
+ } else {
317
+ color = "\x1b[33m%s\x1b[0m";
318
+ }
319
+ console.info(color,"[INFO] " + message);
314
320
  }
315
321
  },
316
322
  warn (message) {
@@ -901,9 +907,13 @@
901
907
 
902
908
  if (typeof self.__definition !== "undefined") {
903
909
  Object.keys(self.__definition).filter(function (k){
904
- return isNaN(k) && !["name","__instanceID", "__classType", "__definition","__new__", "_new_", "css", "hierarchy", "append", "attachIn"].includes(k);
910
+ return isNaN(k) && !["name","__instanceID", "__classType", "__definition"].includes(k);
905
911
  }).forEach(function(key) {
906
- self[key] = self.__definition[key];
912
+ if (typeof self.__definition[key] === "function") {
913
+ self[key] = self.__definition[key].bind(self);
914
+ } else {
915
+ self[key] = self.__definition[key];
916
+ }
907
917
  });
908
918
  }
909
919
  _methods_(_QC_CLASSES[self.__classType]).map (function(m) {
@@ -2117,27 +2127,51 @@
2117
2127
  route () {
2118
2128
  var componentClass = this;
2119
2129
  var isValidInstance = ((!!componentClass.__instanceID) &&
2120
- componentClass.hasOwnProperty.call(componentClass,"subcomponents")) ? (true) : (false);
2130
+ Object.hasOwnProperty.call(componentClass,"subcomponents")) ? (true) : (false);
2121
2131
  var __route__ = function(componentList) {
2122
- componentList.map(function (rc, r){
2123
- if (typeof rc !== "undefined"
2124
- && rc.hasOwnProperty.call(rc,"_reroute_")){
2125
- rc._reroute_();
2126
- if (rc.hasOwnProperty.call(rc,"subcomponents") &&
2127
- typeof rc.subcomponents !== "undefined" &&
2128
- rc.subcomponents.length > 0
2129
- ) {
2130
- logger.debug("LOOKING FOR ROUTINGS IN SUBCOMPONENTS FOR: " + rc.name);
2131
- __route__.call(componentClass, rc.subcomponents);
2132
- }
2133
- } else if (typeof rc !== "undefined"){
2134
- logger.debug("IT WAS NOT POSSIBLE TO RE-ROUTE: " + rc.name);
2132
+ var _componentNames_ = [];
2133
+ var _promises_ = componentList.filter(function (rc){return typeof rc !== "undefined";}).map(function (rc){
2134
+ if (typeof rc.name !== "undefined"){
2135
+ _componentNames_.push(rc.name);
2136
+ } else {
2137
+ throw new Error(__getType__(rc)+" does not have a name");
2135
2138
  }
2139
+ return new Promise (function (resolve, reject){
2140
+ var _promise_;
2141
+ if (typeof rc !== "undefined"
2142
+ && Object.hasOwnProperty.call(rc,"_reroute_")){
2143
+ _promise_ = rc._reroute_()
2144
+ .then(function (){
2145
+ rc.body.innerHTML = "";
2146
+ rc.innerHTML = "";
2147
+ return rc.rebuild();})
2148
+ .then (function (_rc_){
2149
+ if (Object.hasOwnProperty.call(_rc_,"subcomponents") &&
2150
+ typeof _rc_.subcomponents !== "undefined" &&
2151
+ _rc_.subcomponents.length > 0
2152
+ ) {
2153
+ logger.debug("LOOKING FOR ROUTINGS IN SUBCOMPONENTS FOR: " + _rc_.name);
2154
+ return __route__.call(_rc_, _rc_.subcomponents);
2155
+ } else {
2156
+ resolve(_rc_);
2157
+ }
2158
+ });
2159
+ } else if (typeof rc !== "undefined"){
2160
+ reject("Component " + rc.name + " is not an instance of Component");
2161
+ }
2162
+ return _promise_;
2163
+ });
2136
2164
  });
2165
+ return Promise.all(_promises_)
2166
+ .then(function (){
2167
+ logger.debug("ROUTING COMPLETED FOR "+ _componentNames_.join(", "));
2168
+ }).catch(function (err){
2169
+ logger.error("ROUTING FAILED FOR "+ _componentNames_.join(", ") + ": " + err);
2170
+ });
2137
2171
  };
2138
- if (isValidInstance || global.hasOwnProperty.call(_top.global,"componentsStack")) {
2139
- if (isValidInstance && componentClass.hasOwnProperty.call(componentClass,"name")) {
2140
- logger.debug("loading routings for instance" + componentClass.name);
2172
+ if (isValidInstance || Object.hasOwnProperty.call(global,"componentsStack")) {
2173
+ if (isValidInstance && is_a(componentClass, "Component")){
2174
+ logger.debug("loading routings for instance " + componentClass.name);
2141
2175
  }
2142
2176
  __route__.call(componentClass, (isValidInstance) ? (componentClass.subcomponents) : (global.componentsStack));
2143
2177
  } else {
@@ -2235,7 +2269,7 @@
2235
2269
  var self = this;
2236
2270
 
2237
2271
  if (typeof self.name === "undefined"){
2238
- logger.debug("Component name is not defined");
2272
+ logger.warn("A name is not defined for "+__getType__(self));
2239
2273
  }
2240
2274
 
2241
2275
  self.routingWay = _top.CONFIG.get("routingWay");
package/VERSION CHANGED
@@ -1 +1 @@
1
- 2.4.9-beta
1
+ 2.4.16-beta
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qcobjects",
3
- "version": "2.4.9-beta",
3
+ "version": "2.4.16-beta",
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",