coer-elements 0.0.49 → 0.0.51

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
  /** */
@@ -896,6 +944,7 @@ class Page {
896
944
  /** */
897
945
  this.goBack = { show: false };
898
946
  //Private Variables
947
+ this._path = '';
899
948
  this._page = '';
900
949
  this._source = null;
901
950
  this._preventDestroy = false;
@@ -942,23 +991,23 @@ class Page {
942
991
  /** Rename the last breadcrumb and update the url id */
943
992
  SetPageName(name, id = null) {
944
993
  this._page = name;
945
- let path = this.router.url;
946
- if (path.includes('?'))
947
- path = path.split('?')[0];
994
+ this._path = this.router.url;
995
+ if (this._path.includes('?'))
996
+ this._path = this._path.split('?')[0];
948
997
  if (id) {
949
- const PATH_ARRAY = path.split('/');
998
+ const PATH_ARRAY = this._path.split('/');
950
999
  const PATH_ID = Tools.BreakReference(PATH_ARRAY).pop();
951
1000
  if (PATH_ID) {
952
1001
  PATH_ARRAY[PATH_ARRAY.length - 1] = String(id);
953
- path = PATH_ARRAY.join('/');
1002
+ this._path = PATH_ARRAY.join('/');
954
1003
  }
955
1004
  }
956
1005
  if (this.breadcrumbs.length > 0) {
957
1006
  this.breadcrumbs[this.breadcrumbs.length - 1].page = name;
958
- this.breadcrumbs[this.breadcrumbs.length - 1].path = path;
959
- Breadcrumbs.SetLast(name, path);
1007
+ this.breadcrumbs[this.breadcrumbs.length - 1].path = this._path;
1008
+ Breadcrumbs.SetLast(name, this._path);
960
1009
  }
961
- this.router.navigateByUrl(path);
1010
+ this.router.navigateByUrl(this._path);
962
1011
  }
963
1012
  /** */
964
1013
  __SetSource() {
@@ -1017,6 +1066,14 @@ class Page {
1017
1066
  setTimeout(() => window.location.reload());
1018
1067
  }
1019
1068
  /** */
1069
+ SetPageFilters(filters) {
1070
+ Filters.Add(filters, this._path);
1071
+ }
1072
+ /** */
1073
+ GetPageFilters() {
1074
+ return Filters.Get(this._path);
1075
+ }
1076
+ /** */
1020
1077
  Log(value, log = null) {
1021
1078
  if (Tools.IsNotNull(log))
1022
1079
  console.log({ log, value });
@@ -1492,5 +1549,5 @@ class Service {
1492
1549
  * Generated bundle index. Do not edit.
1493
1550
  */
1494
1551
 
1495
- export { Breadcrumbs, CONTROL_VALUE, CoerAlert, Colors, ControlValue, DateTime, Files, GridTemplates, Menu, Page, Screen, Service, Source, Tools };
1552
+ export { Breadcrumbs, CONTROL_VALUE, CoerAlert, Colors, ControlValue, DateTime, Files, Filters, GridTemplates, Menu, Page, Screen, Service, Source, Tools };
1496
1553
  //# sourceMappingURL=coer-elements-tools.mjs.map