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.
@@ -754,6 +754,62 @@ var ObjectUtils;
754
754
  ObjectUtils.UId = UId;
755
755
  })(ObjectUtils || (ObjectUtils = {}));
756
756
 
757
+ var PathUtils;
758
+ (function (PathUtils) {
759
+ function Parse(str) {
760
+ if (!str) {
761
+ return [];
762
+ }
763
+ var broken = str.split("\"/\"");
764
+ if (broken.length > 0) {
765
+ var top_1 = broken[0];
766
+ if (top_1.length > 0) {
767
+ if (top_1.charAt(0) == "\"") {
768
+ top_1 = top_1.substring(1);
769
+ }
770
+ broken[0] = top_1;
771
+ }
772
+ var endIndex = broken.length - 1;
773
+ var bot = broken[endIndex];
774
+ if (bot.length > 0) {
775
+ if (bot.charAt(bot.length - 1) == "\"") {
776
+ bot = bot.substring(0, bot.length - 1);
777
+ }
778
+ broken[endIndex] = bot;
779
+ }
780
+ }
781
+ return broken;
782
+ }
783
+ PathUtils.Parse = Parse;
784
+ function Wrap(path) {
785
+ var tmp = "\"";
786
+ for (var i = 0; i < path.length; i++) {
787
+ var section = path[i];
788
+ tmp += section;
789
+ if (i < path.length - 1) {
790
+ tmp += "\"/\"";
791
+ }
792
+ }
793
+ tmp += "\"";
794
+ return tmp;
795
+ }
796
+ PathUtils.Wrap = Wrap;
797
+ function ParseLegacy(str) {
798
+ var broken = str.split(".");
799
+ for (var i = 0; i < broken.length; i++) {
800
+ var piece = broken[0];
801
+ if (piece.charAt(0) == "\"") {
802
+ piece = broken[0] = piece.substring(1);
803
+ }
804
+ if (piece.charAt(piece.length - 1) == "\"") {
805
+ broken[0] = piece.substring(0, piece.length - 1);
806
+ }
807
+ }
808
+ return broken;
809
+ }
810
+ PathUtils.ParseLegacy = ParseLegacy;
811
+ })(PathUtils || (PathUtils = {}));
812
+
757
813
  var Entity;
758
814
  (function (Entity) {
759
815
  function GetCacheKey(entityId) {
@@ -941,6 +997,22 @@ var Entity;
941
997
  return null;
942
998
  }
943
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 = 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;
944
1016
  var Filter;
945
1017
  (function (Filter) {
946
1018
  var V1;
@@ -1006,62 +1078,6 @@ var Entity;
1006
1078
  })(Filter = Entity.Filter || (Entity.Filter = {}));
1007
1079
  })(Entity || (Entity = {}));
1008
1080
 
1009
- var PathUtils;
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
- })(PathUtils || (PathUtils = {}));
1064
-
1065
1081
  function getVariable(str) {
1066
1082
  var start = str.indexOf("${");
1067
1083
  if (start > -1) {
@@ -4848,5 +4864,104 @@ var MathUtils;
4848
4864
  MathUtils.RandInt = RandInt;
4849
4865
  })(MathUtils || (MathUtils = {}));
4850
4866
 
4851
- export { AnnDocument, AbstractApi, Api, BruceApi, CamApi, IdmApi, Calculator, BruceEvent, CacheControl, Camera, Cartes, Carto, Color, DelayQueue, Geometry, UTC, EntityAttachmentType, EntityAttachment, EntityComment, EntityLink, EntityLod, EntityRelationType, EntityRelation, EntitySource, EntityTag, EntityType, Entity, EntityGlobe, EntityFilterGetter, BatchedDataGetter, ClientFile, ProgramKey, ZoomControl, MenuItem, ProjectViewBookmark, ProjectView, PendingAction, Style, TilesetEntitiesMapTiles, TilesetExtMapTiles, Tileset, Ucs, Permission, Session, UserGroup, User, EncryptUtils, MathUtils, ObjectUtils, PathUtils };
4867
+ var UrlUtils;
4868
+ (function (UrlUtils) {
4869
+ function GetQueryString(doc) {
4870
+ var qs = {};
4871
+ var p0 = doc.location.href.indexOf("?");
4872
+ if (p0 >= 0) {
4873
+ var str = doc.location.href.substring(p0 + 1);
4874
+ var tokens = str.split("&");
4875
+ tokens.forEach(function (token) {
4876
+ var p = token.split("=");
4877
+ if (p.length == 2) {
4878
+ qs[p[0]] = p[1];
4879
+ }
4880
+ });
4881
+ }
4882
+ return qs;
4883
+ }
4884
+ UrlUtils.GetQueryString = GetQueryString;
4885
+ var Handler = /** @class */ (function () {
4886
+ function Handler(window, allowedKeys) {
4887
+ this._allowedKeys = null;
4888
+ this._window = window;
4889
+ this._allowedKeys = allowedKeys;
4890
+ }
4891
+ Object.defineProperty(Handler.prototype, "window", {
4892
+ get: function () {
4893
+ return this._window;
4894
+ },
4895
+ enumerable: false,
4896
+ configurable: true
4897
+ });
4898
+ Object.defineProperty(Handler.prototype, "document", {
4899
+ get: function () {
4900
+ var _a;
4901
+ return (_a = this.window) === null || _a === void 0 ? void 0 : _a.document;
4902
+ },
4903
+ enumerable: false,
4904
+ configurable: true
4905
+ });
4906
+ Object.defineProperty(Handler.prototype, "allowedKeys", {
4907
+ get: function () {
4908
+ return this._allowedKeys;
4909
+ },
4910
+ enumerable: false,
4911
+ configurable: true
4912
+ });
4913
+ Handler.prototype.UpdateAllowedKeys = function (allowedKeys) {
4914
+ this._allowedKeys = allowedKeys;
4915
+ var params = this.GetParams();
4916
+ this.refresh(params);
4917
+ };
4918
+ Handler.prototype.UpdateParam = function (key, value) {
4919
+ var params = this.GetParams();
4920
+ params[key + ""] = value + "";
4921
+ this.refresh(params);
4922
+ };
4923
+ Handler.prototype.RemoveParam = function (key) {
4924
+ var params = this.GetParams();
4925
+ params[key + ""] = null;
4926
+ this.refresh(params);
4927
+ };
4928
+ Handler.prototype.GetParamKeys = function () {
4929
+ var params = GetQueryString(this.document);
4930
+ return Object.keys(params);
4931
+ };
4932
+ Handler.prototype.GetParams = function () {
4933
+ return GetQueryString(this.document);
4934
+ };
4935
+ Handler.prototype.GetParam = function (key) {
4936
+ var params = this.GetParams();
4937
+ return params[key + ""];
4938
+ };
4939
+ Handler.prototype.Clear = function () {
4940
+ this.refresh({});
4941
+ };
4942
+ Handler.prototype.refresh = function (data) {
4943
+ var params = [];
4944
+ var keys = Object.keys(data);
4945
+ for (var i = 0; i < keys.length; i++) {
4946
+ var key = keys[i];
4947
+ if (this._allowedKeys == null || this._allowedKeys.includes(key)) {
4948
+ var val = data[key];
4949
+ if (!!val || val == 0) {
4950
+ params.push(key + "=" + val);
4951
+ }
4952
+ }
4953
+ }
4954
+ if (params.length > 0) {
4955
+ this.window.history.replaceState({}, null, "?" + params.join("&"));
4956
+ }
4957
+ else {
4958
+ this.window.history.replaceState({}, null, "");
4959
+ }
4960
+ };
4961
+ return Handler;
4962
+ }());
4963
+ UrlUtils.Handler = Handler;
4964
+ })(UrlUtils || (UrlUtils = {}));
4965
+
4966
+ export { AnnDocument, AbstractApi, Api, BruceApi, CamApi, IdmApi, Calculator, BruceEvent, CacheControl, Camera, Cartes, Carto, Color, DelayQueue, Geometry, UTC, EntityAttachmentType, EntityAttachment, EntityComment, EntityLink, EntityLod, EntityRelationType, EntityRelation, EntitySource, EntityTag, EntityType, Entity, EntityGlobe, EntityFilterGetter, BatchedDataGetter, ClientFile, ProgramKey, ZoomControl, MenuItem, ProjectViewBookmark, ProjectView, PendingAction, Style, TilesetEntitiesMapTiles, TilesetExtMapTiles, Tileset, Ucs, Permission, Session, UserGroup, User, EncryptUtils, MathUtils, ObjectUtils, PathUtils, UrlUtils };
4852
4967
  //# sourceMappingURL=bruce-models.es5.js.map