bruce-models 0.1.4 → 0.1.6

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.
@@ -756,6 +756,61 @@
756
756
  ObjectUtils.UId = UId;
757
757
  })(exports.ObjectUtils || (exports.ObjectUtils = {}));
758
758
 
759
+ (function (PathUtils) {
760
+ function Parse(str) {
761
+ if (!str) {
762
+ return [];
763
+ }
764
+ var broken = str.split("\"/\"");
765
+ if (broken.length > 0) {
766
+ var top_1 = broken[0];
767
+ if (top_1.length > 0) {
768
+ if (top_1.charAt(0) == "\"") {
769
+ top_1 = top_1.substring(1);
770
+ }
771
+ broken[0] = top_1;
772
+ }
773
+ var endIndex = broken.length - 1;
774
+ var bot = broken[endIndex];
775
+ if (bot.length > 0) {
776
+ if (bot.charAt(bot.length - 1) == "\"") {
777
+ bot = bot.substring(0, bot.length - 1);
778
+ }
779
+ broken[endIndex] = bot;
780
+ }
781
+ }
782
+ return broken;
783
+ }
784
+ PathUtils.Parse = Parse;
785
+ function Wrap(path) {
786
+ var tmp = "\"";
787
+ for (var i = 0; i < path.length; i++) {
788
+ var section = path[i];
789
+ tmp += section;
790
+ if (i < path.length - 1) {
791
+ tmp += "\"/\"";
792
+ }
793
+ }
794
+ tmp += "\"";
795
+ return tmp;
796
+ }
797
+ PathUtils.Wrap = Wrap;
798
+ function ParseLegacy(str) {
799
+ var broken = str.split(".");
800
+ for (var i = 0; i < broken.length; i++) {
801
+ var piece = broken[0];
802
+ if (piece.charAt(0) == "\"") {
803
+ piece = broken[0] = piece.substring(1);
804
+ }
805
+ if (piece.charAt(piece.length - 1) == "\"") {
806
+ broken[0] = piece.substring(0, piece.length - 1);
807
+ }
808
+ }
809
+ return broken;
810
+ }
811
+ PathUtils.ParseLegacy = ParseLegacy;
812
+ })(exports.PathUtils || (exports.PathUtils = {}));
813
+
759
814
  (function (Entity) {
760
815
  function GetCacheKey(entityId) {
761
816
  return "" + exports.Api.ECacheKey.Entity + exports.Api.ECacheKey.Id + entityId;
@@ -942,6 +997,22 @@
942
997
  return null;
943
998
  }
944
999
  Entity.GetValue = GetValue;
1000
+ function CalculateName(entity, type) {
1001
+ var attrStr = type.DisplayNameAttributePath;
1002
+ if (attrStr) {
1003
+ var attrPaths = attrStr.split(",");
1004
+ for (var i = 0; i < attrPaths.length; i++) {
1005
+ var pathStr = attrPaths[i];
1006
+ var path = exports.PathUtils.Parse(pathStr);
1007
+ var name_1 = Entity.GetValue(entity, path);
1008
+ if (name_1) {
1009
+ return name_1;
1010
+ }
1011
+ }
1012
+ }
1013
+ return entity.Bruce.ID;
1014
+ }
1015
+ Entity.CalculateName = CalculateName;
945
1016
  var Filter;
946
1017
  (function (Filter) {
947
1018
  var V1;
@@ -1007,61 +1078,6 @@
1007
1078
  })(Filter = Entity.Filter || (Entity.Filter = {}));
1008
1079
  })(exports.Entity || (exports.Entity = {}));
1009
1080
 
1010
- (function (PathUtils) {
1011
- function Parse(str) {
1012
- if (!str) {
1013
- return [];
1014
- }
1015
- var broken = str.split("\"/\"");
1016
- if (broken.length > 0) {
1017
- var top_1 = broken[0];
1018
- if (top_1.length > 0) {
1019
- if (top_1.charAt(0) == "\"") {
1020
- top_1 = top_1.substring(1);
1021
- }
1022
- broken[0] = top_1;
1023
- }
1024
- var endIndex = broken.length - 1;
1025
- var bot = broken[endIndex];
1026
- if (bot.length > 0) {
1027
- if (bot.charAt(bot.length - 1) == "\"") {
1028
- bot = bot.substring(0, bot.length - 1);
1029
- }
1030
- broken[endIndex] = bot;
1031
- }
1032
- }
1033
- return broken;
1034
- }
1035
- PathUtils.Parse = Parse;
1036
- function Wrap(path) {
1037
- var tmp = "\"";
1038
- for (var i = 0; i < path.length; i++) {
1039
- var section = path[i];
1040
- tmp += section;
1041
- if (i < path.length - 1) {
1042
- tmp += "\"/\"";
1043
- }
1044
- }
1045
- tmp += "\"";
1046
- return tmp;
1047
- }
1048
- PathUtils.Wrap = Wrap;
1049
- function ParseLegacy(str) {
1050
- var broken = str.split(".");
1051
- for (var i = 0; i < broken.length; i++) {
1052
- var piece = broken[0];
1053
- if (piece.charAt(0) == "\"") {
1054
- piece = broken[0] = piece.substring(1);
1055
- }
1056
- if (piece.charAt(piece.length - 1) == "\"") {
1057
- broken[0] = piece.substring(0, piece.length - 1);
1058
- }
1059
- }
1060
- return broken;
1061
- }
1062
- PathUtils.ParseLegacy = ParseLegacy;
1063
- })(exports.PathUtils || (exports.PathUtils = {}));
1064
-
1065
1081
  function getVariable(str) {
1066
1082
  var start = str.indexOf("${");
1067
1083
  if (start > -1) {
@@ -4811,6 +4827,104 @@
4811
4827
  MathUtils.RandInt = RandInt;
4812
4828
  })(exports.MathUtils || (exports.MathUtils = {}));
4813
4829
 
4830
+ (function (UrlUtils) {
4831
+ function GetQueryString(doc) {
4832
+ var qs = {};
4833
+ var p0 = doc.location.href.indexOf("?");
4834
+ if (p0 >= 0) {
4835
+ var str = doc.location.href.substring(p0 + 1);
4836
+ var tokens = str.split("&");
4837
+ tokens.forEach(function (token) {
4838
+ var p = token.split("=");
4839
+ if (p.length == 2) {
4840
+ qs[p[0]] = p[1];
4841
+ }
4842
+ });
4843
+ }
4844
+ return qs;
4845
+ }
4846
+ UrlUtils.GetQueryString = GetQueryString;
4847
+ var Handler = /** @class */ (function () {
4848
+ function Handler(window, allowedKeys) {
4849
+ this._allowedKeys = null;
4850
+ this._window = window;
4851
+ this._allowedKeys = allowedKeys;
4852
+ }
4853
+ Object.defineProperty(Handler.prototype, "window", {
4854
+ get: function () {
4855
+ return this._window;
4856
+ },
4857
+ enumerable: false,
4858
+ configurable: true
4859
+ });
4860
+ Object.defineProperty(Handler.prototype, "document", {
4861
+ get: function () {
4862
+ var _a;
4863
+ return (_a = this.window) === null || _a === void 0 ? void 0 : _a.document;
4864
+ },
4865
+ enumerable: false,
4866
+ configurable: true
4867
+ });
4868
+ Object.defineProperty(Handler.prototype, "allowedKeys", {
4869
+ get: function () {
4870
+ return this._allowedKeys;
4871
+ },
4872
+ enumerable: false,
4873
+ configurable: true
4874
+ });
4875
+ Handler.prototype.UpdateAllowedKeys = function (allowedKeys) {
4876
+ this._allowedKeys = allowedKeys;
4877
+ var params = this.GetParams();
4878
+ this.refresh(params);
4879
+ };
4880
+ Handler.prototype.UpdateParam = function (key, value) {
4881
+ var params = this.GetParams();
4882
+ params[key + ""] = value + "";
4883
+ this.refresh(params);
4884
+ };
4885
+ Handler.prototype.RemoveParam = function (key) {
4886
+ var params = this.GetParams();
4887
+ params[key + ""] = null;
4888
+ this.refresh(params);
4889
+ };
4890
+ Handler.prototype.GetParamKeys = function () {
4891
+ var params = GetQueryString(this.document);
4892
+ return Object.keys(params);
4893
+ };
4894
+ Handler.prototype.GetParams = function () {
4895
+ return GetQueryString(this.document);
4896
+ };
4897
+ Handler.prototype.GetParam = function (key) {
4898
+ var params = this.GetParams();
4899
+ return params[key + ""];
4900
+ };
4901
+ Handler.prototype.Clear = function () {
4902
+ this.refresh({});
4903
+ };
4904
+ Handler.prototype.refresh = function (data) {
4905
+ var params = [];
4906
+ var keys = Object.keys(data);
4907
+ for (var i = 0; i < keys.length; i++) {
4908
+ var key = keys[i];
4909
+ if (this._allowedKeys == null || this._allowedKeys.includes(key)) {
4910
+ var val = data[key];
4911
+ if (!!val || val == 0) {
4912
+ params.push(key + "=" + val);
4913
+ }
4914
+ }
4915
+ }
4916
+ if (params.length > 0) {
4917
+ this.window.history.replaceState({}, null, "?" + params.join("&"));
4918
+ }
4919
+ else {
4920
+ this.window.history.replaceState({}, null, "");
4921
+ }
4922
+ };
4923
+ return Handler;
4924
+ }());
4925
+ UrlUtils.Handler = Handler;
4926
+ })(exports.UrlUtils || (exports.UrlUtils = {}));
4927
+
4814
4928
  exports.AbstractApi = AbstractApi;
4815
4929
  exports.BruceApi = BruceApi;
4816
4930
  exports.CamApi = CamApi;