coer-elements 0.0.50 → 0.0.52

Sign up to get free protection for your applications and to get access to all the features.
@@ -776,6 +776,54 @@ class Files {
776
776
  }
777
777
  }
778
778
 
779
+ class Filters {
780
+ static { this.storage = 'COER-System'; }
781
+ /** */
782
+ static Add(filters, path) {
783
+ let storage = sessionStorage.getItem(this.storage);
784
+ storage = JSON.parse(storage);
785
+ let dictionary = [[path, filters]];
786
+ if (Tools.IsNotNull(storage?.filters)) {
787
+ if (!storage.filters.some((x) => x.some(y => y === path))) {
788
+ storage.filters.concat(dictionary);
789
+ }
790
+ }
791
+ storage = Object.assign({}, storage, {
792
+ filters: dictionary
793
+ });
794
+ sessionStorage.setItem(this.storage, JSON.stringify(storage));
795
+ }
796
+ /** */
797
+ static Get(path) {
798
+ let storage = sessionStorage.getItem(this.storage);
799
+ storage = JSON.parse(storage);
800
+ return (Tools.IsNotNull(storage?.filters))
801
+ ? storage.filters.find((x) => x.some((y) => y === path))[1] || null
802
+ : null;
803
+ }
804
+ /** */
805
+ static Remove(path) {
806
+ let storage = sessionStorage.getItem(this.storage);
807
+ storage = JSON.parse(storage);
808
+ if (Tools.IsNotNull(storage?.filters)) {
809
+ const index = storage.filters.findIndex((x) => x.some((y) => y === path));
810
+ if (index >= 0) {
811
+ storage.filters.splice(index, 1);
812
+ }
813
+ }
814
+ sessionStorage.setItem(this.storage, JSON.stringify(storage));
815
+ }
816
+ /** */
817
+ static RemoveAll() {
818
+ let storage = sessionStorage.getItem(this.storage);
819
+ storage = JSON.parse(storage);
820
+ if (Tools.IsNotNull(storage?.filters)) {
821
+ delete storage.filters;
822
+ }
823
+ sessionStorage.setItem(this.storage, JSON.stringify(storage));
824
+ }
825
+ }
826
+
779
827
  class Menu {
780
828
  static { this.storage = 'COER-System'; }
781
829
  /** */
@@ -894,8 +942,11 @@ class Page {
894
942
  /** */
895
943
  this.pageResponse = null;
896
944
  /** */
945
+ this.pageFilters = {};
946
+ /** */
897
947
  this.goBack = { show: false };
898
948
  //Private Variables
949
+ this._path = '';
899
950
  this._page = '';
900
951
  this._source = null;
901
952
  this._preventDestroy = false;
@@ -921,7 +972,8 @@ class Page {
921
972
  this.__GetSource();
922
973
  this.__GetNavigation();
923
974
  this.__SetGoBack();
924
- this.GetPageResponse();
975
+ this.__GetPageFilter();
976
+ this.__GetPageResponse();
925
977
  }
926
978
  ngAfterViewInit() {
927
979
  this.routeParams = this.activatedRoute.snapshot.params;
@@ -942,23 +994,23 @@ class Page {
942
994
  /** Rename the last breadcrumb and update the url id */
943
995
  SetPageName(name, id = null) {
944
996
  this._page = name;
945
- let path = this.router.url;
946
- if (path.includes('?'))
947
- path = path.split('?')[0];
997
+ this._path = this.router.url;
998
+ if (this._path.includes('?'))
999
+ this._path = this._path.split('?')[0];
948
1000
  if (id) {
949
- const PATH_ARRAY = path.split('/');
1001
+ const PATH_ARRAY = this._path.split('/');
950
1002
  const PATH_ID = Tools.BreakReference(PATH_ARRAY).pop();
951
1003
  if (PATH_ID) {
952
1004
  PATH_ARRAY[PATH_ARRAY.length - 1] = String(id);
953
- path = PATH_ARRAY.join('/');
1005
+ this._path = PATH_ARRAY.join('/');
954
1006
  }
955
1007
  }
956
1008
  if (this.breadcrumbs.length > 0) {
957
1009
  this.breadcrumbs[this.breadcrumbs.length - 1].page = name;
958
- this.breadcrumbs[this.breadcrumbs.length - 1].path = path;
959
- Breadcrumbs.SetLast(name, path);
1010
+ this.breadcrumbs[this.breadcrumbs.length - 1].path = this._path;
1011
+ Breadcrumbs.SetLast(name, this._path);
960
1012
  }
961
- this.router.navigateByUrl(path);
1013
+ this.router.navigateByUrl(this._path);
962
1014
  }
963
1015
  /** */
964
1016
  __SetSource() {
@@ -969,7 +1021,7 @@ class Page {
969
1021
  this._source = Source.Get();
970
1022
  }
971
1023
  /** */
972
- GetPageResponse() {
1024
+ __GetPageResponse() {
973
1025
  this.pageResponse = Source.GetPageResponse();
974
1026
  }
975
1027
  /** */
@@ -1017,6 +1069,15 @@ class Page {
1017
1069
  setTimeout(() => window.location.reload());
1018
1070
  }
1019
1071
  /** */
1072
+ SetPageFilters(filters) {
1073
+ this.pageFilters = Tools.BreakReference(filters);
1074
+ Filters.Add(this.pageFilters, this._path);
1075
+ }
1076
+ /** */
1077
+ __GetPageFilter() {
1078
+ this.pageFilters = Filters.Get(this._path);
1079
+ }
1080
+ /** */
1020
1081
  Log(value, log = null) {
1021
1082
  if (Tools.IsNotNull(log))
1022
1083
  console.log({ log, value });
@@ -1492,5 +1553,5 @@ class Service {
1492
1553
  * Generated bundle index. Do not edit.
1493
1554
  */
1494
1555
 
1495
- export { Breadcrumbs, CONTROL_VALUE, CoerAlert, Colors, ControlValue, DateTime, Files, GridTemplates, Menu, Page, Screen, Service, Source, Tools };
1556
+ export { Breadcrumbs, CONTROL_VALUE, CoerAlert, Colors, ControlValue, DateTime, Files, Filters, GridTemplates, Menu, Page, Screen, Service, Source, Tools };
1496
1557
  //# sourceMappingURL=coer-elements-tools.mjs.map