coer-elements 1.0.9 → 1.0.10
Sign up to get free protection for your applications and to get access to all the features.
- package/components/coer-alert/coer-alert.component.html +56 -0
- package/components/coer-alert/coer-alert.component.scss +100 -0
- package/components/coer-alert/coer-alert.component.ts +249 -0
- package/components/index.ts +97 -0
- package/dist_browser/Tools/Breadcrumbs.class.js +66 -0
- package/dist_browser/Tools/ControlValue.js +49 -0
- package/dist_browser/Tools/Page.class.js +212 -0
- package/dist_browser/Tools/Source.class.js +83 -0
- package/dist_browser/index.js +5 -1
- package/dist_node/Tools/Breadcrumbs.class.js +69 -0
- package/dist_node/Tools/ControlValue.js +53 -0
- package/dist_node/Tools/Page.class.js +215 -0
- package/dist_node/Tools/Source.class.js +86 -0
- package/dist_node/index.js +5 -1
- package/package.json +9 -1
- package/styles/bootstrap.scss +22 -0
- package/styles/coer.scss +95 -0
- package/styles/colors.scss +167 -0
@@ -0,0 +1,212 @@
|
|
1
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
2
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
3
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
4
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
5
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
6
|
+
var _, done = false;
|
7
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
8
|
+
var context = {};
|
9
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
10
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
11
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
12
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
13
|
+
if (kind === "accessor") {
|
14
|
+
if (result === void 0) continue;
|
15
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
16
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
17
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
18
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
19
|
+
}
|
20
|
+
else if (_ = accept(result)) {
|
21
|
+
if (kind === "field") initializers.unshift(_);
|
22
|
+
else descriptor[key] = _;
|
23
|
+
}
|
24
|
+
}
|
25
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
26
|
+
done = true;
|
27
|
+
};
|
28
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
29
|
+
var useValue = arguments.length > 2;
|
30
|
+
for (var i = 0; i < initializers.length; i++) {
|
31
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
32
|
+
}
|
33
|
+
return useValue ? value : void 0;
|
34
|
+
};
|
35
|
+
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
|
36
|
+
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
37
|
+
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
38
|
+
};
|
39
|
+
import { Component, inject } from '@angular/core';
|
40
|
+
import { Breadcrumbs } from "./Breadcrumbs.class";
|
41
|
+
import { Source } from './Source.class';
|
42
|
+
import { ActivatedRoute, Router } from '@angular/router';
|
43
|
+
import { Tools } from './Tools';
|
44
|
+
var Page = function () {
|
45
|
+
var _classDecorators = [Component({ template: '' })];
|
46
|
+
var _classDescriptor;
|
47
|
+
var _classExtraInitializers = [];
|
48
|
+
var _classThis;
|
49
|
+
var Page = _classThis = /** @class */ (function () {
|
50
|
+
function Page_1(page) {
|
51
|
+
//Injection
|
52
|
+
//protected readonly alert = inject(CoerAlert);
|
53
|
+
this.router = inject(Router);
|
54
|
+
this.activatedRoute = inject(ActivatedRoute);
|
55
|
+
/** */
|
56
|
+
this.isUpdate = false;
|
57
|
+
/** */
|
58
|
+
this.isLoading = false;
|
59
|
+
/** */
|
60
|
+
this.isReady = false;
|
61
|
+
/** */
|
62
|
+
this.enableAnimations = false;
|
63
|
+
/** */
|
64
|
+
this.breadcrumbs = [];
|
65
|
+
/** */
|
66
|
+
this.pageResponse = null;
|
67
|
+
/** */
|
68
|
+
this.goBack = { show: false };
|
69
|
+
//Private Variables
|
70
|
+
this._page = '';
|
71
|
+
this._source = null;
|
72
|
+
this._preventDestroy = false;
|
73
|
+
/** */
|
74
|
+
this.GoBack = function (path) { return (function () {
|
75
|
+
if (path)
|
76
|
+
Breadcrumbs.Remove(path);
|
77
|
+
else
|
78
|
+
Breadcrumbs.RemoveLast();
|
79
|
+
}); };
|
80
|
+
/** Returns true if the value is null or undefined, false otherwise */
|
81
|
+
this.IsNotNull = Tools.IsNotNull;
|
82
|
+
/** Returns true if the value is null or undefined, false otherwise */
|
83
|
+
this.IsNull = Tools.IsNull;
|
84
|
+
/** Returns true if the value is null or undefined or contains only whitespace, false otherwise */
|
85
|
+
this.IsOnlyWhiteSpace = Tools.IsOnlyWhiteSpace;
|
86
|
+
this.SetPageName(page);
|
87
|
+
this.SetSource();
|
88
|
+
this.GetSource();
|
89
|
+
this.GetNavigation();
|
90
|
+
this.SetGoBack();
|
91
|
+
this.GetPageResponse();
|
92
|
+
}
|
93
|
+
Page_1.prototype.ngAfterViewInit = function () {
|
94
|
+
var _this = this;
|
95
|
+
this.routeParams = this.activatedRoute.snapshot.params;
|
96
|
+
this.queryParams = this.activatedRoute.snapshot.queryParams;
|
97
|
+
setTimeout(function () {
|
98
|
+
_this.isReady = true;
|
99
|
+
_this.RunPage();
|
100
|
+
setTimeout(function () { _this.enableAnimations = true; }, 1000);
|
101
|
+
});
|
102
|
+
};
|
103
|
+
Page_1.prototype.ngOnDestroy = function () {
|
104
|
+
if (!this._preventDestroy)
|
105
|
+
Source.ClearPageResponse();
|
106
|
+
};
|
107
|
+
/** Main method. Starts after ngAfterViewInit() */
|
108
|
+
Page_1.prototype.RunPage = function () { };
|
109
|
+
;
|
110
|
+
/** Rename the last breadcrumb and update the url id */
|
111
|
+
Page_1.prototype.SetPageName = function (name, id) {
|
112
|
+
if (id === void 0) { id = null; }
|
113
|
+
this._page = name;
|
114
|
+
var path = this.router.url;
|
115
|
+
if (path.includes('?'))
|
116
|
+
path = path.split('?')[0];
|
117
|
+
if (id) {
|
118
|
+
var PATH_ARRAY = path.split('/');
|
119
|
+
var PATH_ID = Tools.BreakReference(PATH_ARRAY).pop();
|
120
|
+
if (PATH_ID) {
|
121
|
+
PATH_ARRAY[PATH_ARRAY.length - 1] = String(id);
|
122
|
+
path = PATH_ARRAY.join('/');
|
123
|
+
}
|
124
|
+
}
|
125
|
+
if (this.breadcrumbs.length > 0) {
|
126
|
+
this.breadcrumbs[this.breadcrumbs.length - 1].page = name;
|
127
|
+
this.breadcrumbs[this.breadcrumbs.length - 1].path = path;
|
128
|
+
Breadcrumbs.SetLast(name, path);
|
129
|
+
}
|
130
|
+
this.router.navigateByUrl(path);
|
131
|
+
};
|
132
|
+
/** */
|
133
|
+
Page_1.prototype.SetSource = function () {
|
134
|
+
Source.Set(this._page);
|
135
|
+
};
|
136
|
+
/** */
|
137
|
+
Page_1.prototype.GetSource = function () {
|
138
|
+
this._source = Source.Get();
|
139
|
+
};
|
140
|
+
/** */
|
141
|
+
Page_1.prototype.GetPageResponse = function () {
|
142
|
+
this.pageResponse = Source.GetPageResponse();
|
143
|
+
};
|
144
|
+
/** */
|
145
|
+
Page_1.prototype.GetNavigation = function () {
|
146
|
+
var _this = this;
|
147
|
+
if (this._source) {
|
148
|
+
this.breadcrumbs = Breadcrumbs.Get().map(function (item) { return Object.assign({
|
149
|
+
page: item.page,
|
150
|
+
path: item.path,
|
151
|
+
click: _this.GoBack(item.path)
|
152
|
+
}); });
|
153
|
+
}
|
154
|
+
else
|
155
|
+
this.breadcrumbs = [{ page: this._page }];
|
156
|
+
};
|
157
|
+
/** */
|
158
|
+
Page_1.prototype.SetGoBack = function () {
|
159
|
+
if (this._source) {
|
160
|
+
this.goBack = {
|
161
|
+
show: true,
|
162
|
+
path: this._source.path,
|
163
|
+
click: this.GoBack()
|
164
|
+
};
|
165
|
+
}
|
166
|
+
};
|
167
|
+
/** Navigate to previous page */
|
168
|
+
Page_1.prototype.GoToSource = function (pageResponse) {
|
169
|
+
var _this = this;
|
170
|
+
if (pageResponse === void 0) { pageResponse = null; }
|
171
|
+
if (this._source) {
|
172
|
+
Breadcrumbs.RemoveLast();
|
173
|
+
this.SetPageResponse(pageResponse);
|
174
|
+
Tools.Sleep().then(function (_) { return _this.router.navigateByUrl(_this._source.path); });
|
175
|
+
}
|
176
|
+
};
|
177
|
+
;
|
178
|
+
/** */
|
179
|
+
Page_1.prototype.SetPageResponse = function (pageResponse) {
|
180
|
+
if (pageResponse === void 0) { pageResponse = null; }
|
181
|
+
if (Tools.IsNotNull(pageResponse)) {
|
182
|
+
this._preventDestroy = true;
|
183
|
+
Source.SetPageResponse(pageResponse);
|
184
|
+
}
|
185
|
+
};
|
186
|
+
;
|
187
|
+
/** */
|
188
|
+
Page_1.prototype.ReloadPage = function () {
|
189
|
+
Breadcrumbs.RemoveLast();
|
190
|
+
Tools.Sleep().then(function (_) { return window.location.reload(); });
|
191
|
+
};
|
192
|
+
/** */
|
193
|
+
Page_1.prototype.Log = function (value, log) {
|
194
|
+
if (log === void 0) { log = null; }
|
195
|
+
if (Tools.IsNotNull(log))
|
196
|
+
console.log({ log: log, value: value });
|
197
|
+
else
|
198
|
+
console.log(value);
|
199
|
+
};
|
200
|
+
return Page_1;
|
201
|
+
}());
|
202
|
+
__setFunctionName(_classThis, "Page");
|
203
|
+
(function () {
|
204
|
+
var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
205
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
206
|
+
Page = _classThis = _classDescriptor.value;
|
207
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
208
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
209
|
+
})();
|
210
|
+
return Page = _classThis;
|
211
|
+
}();
|
212
|
+
export { Page };
|
@@ -0,0 +1,83 @@
|
|
1
|
+
import { Breadcrumbs } from "./Breadcrumbs.class";
|
2
|
+
import { Router } from '@angular/router';
|
3
|
+
import { inject } from "@angular/core";
|
4
|
+
import { Tools } from './Tools';
|
5
|
+
var Source = /** @class */ (function () {
|
6
|
+
function Source() {
|
7
|
+
}
|
8
|
+
/** */
|
9
|
+
Source.Set = function (page) {
|
10
|
+
var ROUTER = inject(Router);
|
11
|
+
var path = ROUTER.url;
|
12
|
+
if (path.includes('?'))
|
13
|
+
path = path.split('?')[0];
|
14
|
+
Breadcrumbs.Add(page, path);
|
15
|
+
var breadcrumbs = Breadcrumbs.Get();
|
16
|
+
if (breadcrumbs.length >= 2) {
|
17
|
+
breadcrumbs.pop();
|
18
|
+
var breadcrumb = breadcrumbs.pop();
|
19
|
+
this.Save({ page: breadcrumb.page, path: breadcrumb.path });
|
20
|
+
}
|
21
|
+
else
|
22
|
+
this.Save(null);
|
23
|
+
};
|
24
|
+
/** */
|
25
|
+
Source.Save = function (source) {
|
26
|
+
var storage = sessionStorage.getItem(this.storage);
|
27
|
+
if (storage)
|
28
|
+
storage = JSON.parse(storage);
|
29
|
+
storage = Object.assign({}, storage, { source: source });
|
30
|
+
sessionStorage.setItem(this.storage, JSON.stringify(storage));
|
31
|
+
};
|
32
|
+
/** */
|
33
|
+
Source.Get = function () {
|
34
|
+
var storage = sessionStorage.getItem(this.storage);
|
35
|
+
if (storage) {
|
36
|
+
storage = JSON.parse(storage);
|
37
|
+
if (storage.hasOwnProperty('source')) {
|
38
|
+
return storage.source;
|
39
|
+
}
|
40
|
+
}
|
41
|
+
return null;
|
42
|
+
};
|
43
|
+
/** */
|
44
|
+
Source.GetRoot = function () {
|
45
|
+
var breadcrumbs = Breadcrumbs.Get();
|
46
|
+
return (breadcrumbs.length > 0) ? breadcrumbs.shift() : null;
|
47
|
+
};
|
48
|
+
/** */
|
49
|
+
Source.SetPageResponse = function (pageResponse) {
|
50
|
+
var storage = sessionStorage.getItem(this.storage);
|
51
|
+
storage = JSON.parse(storage);
|
52
|
+
storage = Object.assign({}, storage, { pageResponse: pageResponse });
|
53
|
+
sessionStorage.setItem(this.storage, JSON.stringify(storage));
|
54
|
+
};
|
55
|
+
/** */
|
56
|
+
Source.GetPageResponse = function () {
|
57
|
+
var storage = sessionStorage.getItem(this.storage);
|
58
|
+
if (storage) {
|
59
|
+
storage = JSON.parse(storage);
|
60
|
+
if (storage.hasOwnProperty('pageResponse')) {
|
61
|
+
return Tools.BreakReference(storage.pageResponse);
|
62
|
+
}
|
63
|
+
}
|
64
|
+
return null;
|
65
|
+
};
|
66
|
+
/** */
|
67
|
+
Source.ClearPageResponse = function () {
|
68
|
+
var storage = sessionStorage.getItem(this.storage);
|
69
|
+
storage = JSON.parse(storage);
|
70
|
+
if (storage.hasOwnProperty('pageResponse')) {
|
71
|
+
delete storage.pageResponse;
|
72
|
+
}
|
73
|
+
storage = Object.assign({}, storage);
|
74
|
+
sessionStorage.setItem(this.storage, JSON.stringify(storage));
|
75
|
+
};
|
76
|
+
/** Clear Source */
|
77
|
+
Source.Reset = function () {
|
78
|
+
sessionStorage.removeItem(this.storage);
|
79
|
+
};
|
80
|
+
Source.storage = 'COER-System';
|
81
|
+
return Source;
|
82
|
+
}());
|
83
|
+
export { Source };
|
package/dist_browser/index.js
CHANGED
@@ -1,4 +1,8 @@
|
|
1
|
-
export * from './Tools/
|
1
|
+
export * from './Tools/Breadcrumbs.class';
|
2
|
+
export * from './Tools/ControlValue';
|
2
3
|
export * from './Tools/DateTime.class';
|
3
4
|
export * from './Tools/Files.class';
|
5
|
+
export * from './Tools/Page.class';
|
4
6
|
export * from './Tools/Screen.class';
|
7
|
+
export * from './Tools/Source.class';
|
8
|
+
export * from './Tools/Tools';
|
@@ -0,0 +1,69 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.Breadcrumbs = void 0;
|
4
|
+
var Tools_1 = require("./Tools");
|
5
|
+
var Breadcrumbs = /** @class */ (function () {
|
6
|
+
function Breadcrumbs() {
|
7
|
+
}
|
8
|
+
/** */
|
9
|
+
Breadcrumbs.Add = function (page, path) {
|
10
|
+
var breadcrumbs = this.Get();
|
11
|
+
var paths = breadcrumbs.map(function (item) { return item.path; });
|
12
|
+
if (!paths.includes(path)) {
|
13
|
+
breadcrumbs.push({ page: page, path: path });
|
14
|
+
this.Save(breadcrumbs);
|
15
|
+
}
|
16
|
+
};
|
17
|
+
/** */
|
18
|
+
Breadcrumbs.Get = function () {
|
19
|
+
var storage = sessionStorage.getItem(this.storage);
|
20
|
+
if (storage) {
|
21
|
+
storage = JSON.parse(storage);
|
22
|
+
if (storage.hasOwnProperty('breadcrumbs')) {
|
23
|
+
return Tools_1.Tools.BreakReference(storage.breadcrumbs);
|
24
|
+
}
|
25
|
+
}
|
26
|
+
return [];
|
27
|
+
};
|
28
|
+
/** Source */
|
29
|
+
Breadcrumbs.GetFirst = function () {
|
30
|
+
var breadcrumbs = this.Get();
|
31
|
+
return (breadcrumbs.length > 0) ? breadcrumbs.shift() : null;
|
32
|
+
};
|
33
|
+
/** */
|
34
|
+
Breadcrumbs.Save = function (breadcrumbs) {
|
35
|
+
var storage = sessionStorage.getItem(this.storage);
|
36
|
+
if (storage)
|
37
|
+
storage = JSON.parse(storage);
|
38
|
+
storage = Object.assign({}, storage, { breadcrumbs: breadcrumbs });
|
39
|
+
sessionStorage.setItem(this.storage, JSON.stringify(storage));
|
40
|
+
};
|
41
|
+
/** */
|
42
|
+
Breadcrumbs.Remove = function (path) {
|
43
|
+
var breadcrumbs = this.Get();
|
44
|
+
var index = breadcrumbs.findIndex(function (x) { return x.path.toLowerCase().trim() === path.toLowerCase().trim(); });
|
45
|
+
if (index >= 0) {
|
46
|
+
breadcrumbs = Tools_1.Tools.BreakReference(breadcrumbs).splice(0, index + 1);
|
47
|
+
this.Save(breadcrumbs);
|
48
|
+
}
|
49
|
+
};
|
50
|
+
/** */
|
51
|
+
Breadcrumbs.SetLast = function (page, path) {
|
52
|
+
var breadcrumbs = this.Get();
|
53
|
+
if (breadcrumbs.length > 0) {
|
54
|
+
breadcrumbs[breadcrumbs.length - 1] = { page: page, path: path };
|
55
|
+
this.Save(breadcrumbs);
|
56
|
+
}
|
57
|
+
};
|
58
|
+
/** */
|
59
|
+
Breadcrumbs.RemoveLast = function () {
|
60
|
+
var breadcrumbs = this.Get();
|
61
|
+
if (breadcrumbs.length > 0) {
|
62
|
+
breadcrumbs.pop();
|
63
|
+
this.Save(breadcrumbs);
|
64
|
+
}
|
65
|
+
};
|
66
|
+
Breadcrumbs.storage = 'COER-System';
|
67
|
+
return Breadcrumbs;
|
68
|
+
}());
|
69
|
+
exports.Breadcrumbs = Breadcrumbs;
|
@@ -0,0 +1,53 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.ControlValue = exports.CONTROL_VALUE = void 0;
|
4
|
+
var forms_1 = require("@angular/forms");
|
5
|
+
var core_1 = require("@angular/core");
|
6
|
+
var CONTROL_VALUE = function (component) {
|
7
|
+
return {
|
8
|
+
provide: forms_1.NG_VALUE_ACCESSOR,
|
9
|
+
useExisting: (0, core_1.forwardRef)(function () { return component; }),
|
10
|
+
multi: true
|
11
|
+
};
|
12
|
+
};
|
13
|
+
exports.CONTROL_VALUE = CONTROL_VALUE;
|
14
|
+
var ControlValue = /** @class */ (function () {
|
15
|
+
function ControlValue() {
|
16
|
+
this._isTouched = false;
|
17
|
+
}
|
18
|
+
Object.defineProperty(ControlValue.prototype, "isTouched", {
|
19
|
+
get: function () {
|
20
|
+
return this._isTouched;
|
21
|
+
},
|
22
|
+
enumerable: false,
|
23
|
+
configurable: true
|
24
|
+
});
|
25
|
+
/** */
|
26
|
+
ControlValue.prototype.SetValue = function (value) {
|
27
|
+
if (typeof this._UpdateValue === 'function') {
|
28
|
+
this._UpdateValue(value);
|
29
|
+
}
|
30
|
+
this._value = value;
|
31
|
+
};
|
32
|
+
/** */
|
33
|
+
ControlValue.prototype.SetTouched = function (isTouched) {
|
34
|
+
if (typeof this._IsTouched === 'function') {
|
35
|
+
this._IsTouched(isTouched);
|
36
|
+
}
|
37
|
+
this._isTouched = isTouched;
|
38
|
+
};
|
39
|
+
/** */
|
40
|
+
ControlValue.prototype.writeValue = function (value) {
|
41
|
+
this._value = value;
|
42
|
+
};
|
43
|
+
/** */
|
44
|
+
ControlValue.prototype.registerOnChange = function (callback) {
|
45
|
+
this._UpdateValue = callback;
|
46
|
+
};
|
47
|
+
/** */
|
48
|
+
ControlValue.prototype.registerOnTouched = function (callback) {
|
49
|
+
this._IsTouched = callback;
|
50
|
+
};
|
51
|
+
return ControlValue;
|
52
|
+
}());
|
53
|
+
exports.ControlValue = ControlValue;
|
@@ -0,0 +1,215 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
3
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
4
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
5
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
6
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
7
|
+
var _, done = false;
|
8
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
9
|
+
var context = {};
|
10
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
11
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
12
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
13
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
14
|
+
if (kind === "accessor") {
|
15
|
+
if (result === void 0) continue;
|
16
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
17
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
18
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
19
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
20
|
+
}
|
21
|
+
else if (_ = accept(result)) {
|
22
|
+
if (kind === "field") initializers.unshift(_);
|
23
|
+
else descriptor[key] = _;
|
24
|
+
}
|
25
|
+
}
|
26
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
27
|
+
done = true;
|
28
|
+
};
|
29
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
30
|
+
var useValue = arguments.length > 2;
|
31
|
+
for (var i = 0; i < initializers.length; i++) {
|
32
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
33
|
+
}
|
34
|
+
return useValue ? value : void 0;
|
35
|
+
};
|
36
|
+
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
|
37
|
+
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
38
|
+
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
39
|
+
};
|
40
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
41
|
+
exports.Page = void 0;
|
42
|
+
var core_1 = require("@angular/core");
|
43
|
+
var Breadcrumbs_class_1 = require("./Breadcrumbs.class");
|
44
|
+
var Source_class_1 = require("./Source.class");
|
45
|
+
var router_1 = require("@angular/router");
|
46
|
+
var Tools_1 = require("./Tools");
|
47
|
+
var Page = function () {
|
48
|
+
var _classDecorators = [(0, core_1.Component)({ template: '' })];
|
49
|
+
var _classDescriptor;
|
50
|
+
var _classExtraInitializers = [];
|
51
|
+
var _classThis;
|
52
|
+
var Page = _classThis = /** @class */ (function () {
|
53
|
+
function Page_1(page) {
|
54
|
+
//Injection
|
55
|
+
//protected readonly alert = inject(CoerAlert);
|
56
|
+
this.router = (0, core_1.inject)(router_1.Router);
|
57
|
+
this.activatedRoute = (0, core_1.inject)(router_1.ActivatedRoute);
|
58
|
+
/** */
|
59
|
+
this.isUpdate = false;
|
60
|
+
/** */
|
61
|
+
this.isLoading = false;
|
62
|
+
/** */
|
63
|
+
this.isReady = false;
|
64
|
+
/** */
|
65
|
+
this.enableAnimations = false;
|
66
|
+
/** */
|
67
|
+
this.breadcrumbs = [];
|
68
|
+
/** */
|
69
|
+
this.pageResponse = null;
|
70
|
+
/** */
|
71
|
+
this.goBack = { show: false };
|
72
|
+
//Private Variables
|
73
|
+
this._page = '';
|
74
|
+
this._source = null;
|
75
|
+
this._preventDestroy = false;
|
76
|
+
/** */
|
77
|
+
this.GoBack = function (path) { return (function () {
|
78
|
+
if (path)
|
79
|
+
Breadcrumbs_class_1.Breadcrumbs.Remove(path);
|
80
|
+
else
|
81
|
+
Breadcrumbs_class_1.Breadcrumbs.RemoveLast();
|
82
|
+
}); };
|
83
|
+
/** Returns true if the value is null or undefined, false otherwise */
|
84
|
+
this.IsNotNull = Tools_1.Tools.IsNotNull;
|
85
|
+
/** Returns true if the value is null or undefined, false otherwise */
|
86
|
+
this.IsNull = Tools_1.Tools.IsNull;
|
87
|
+
/** Returns true if the value is null or undefined or contains only whitespace, false otherwise */
|
88
|
+
this.IsOnlyWhiteSpace = Tools_1.Tools.IsOnlyWhiteSpace;
|
89
|
+
this.SetPageName(page);
|
90
|
+
this.SetSource();
|
91
|
+
this.GetSource();
|
92
|
+
this.GetNavigation();
|
93
|
+
this.SetGoBack();
|
94
|
+
this.GetPageResponse();
|
95
|
+
}
|
96
|
+
Page_1.prototype.ngAfterViewInit = function () {
|
97
|
+
var _this = this;
|
98
|
+
this.routeParams = this.activatedRoute.snapshot.params;
|
99
|
+
this.queryParams = this.activatedRoute.snapshot.queryParams;
|
100
|
+
setTimeout(function () {
|
101
|
+
_this.isReady = true;
|
102
|
+
_this.RunPage();
|
103
|
+
setTimeout(function () { _this.enableAnimations = true; }, 1000);
|
104
|
+
});
|
105
|
+
};
|
106
|
+
Page_1.prototype.ngOnDestroy = function () {
|
107
|
+
if (!this._preventDestroy)
|
108
|
+
Source_class_1.Source.ClearPageResponse();
|
109
|
+
};
|
110
|
+
/** Main method. Starts after ngAfterViewInit() */
|
111
|
+
Page_1.prototype.RunPage = function () { };
|
112
|
+
;
|
113
|
+
/** Rename the last breadcrumb and update the url id */
|
114
|
+
Page_1.prototype.SetPageName = function (name, id) {
|
115
|
+
if (id === void 0) { id = null; }
|
116
|
+
this._page = name;
|
117
|
+
var path = this.router.url;
|
118
|
+
if (path.includes('?'))
|
119
|
+
path = path.split('?')[0];
|
120
|
+
if (id) {
|
121
|
+
var PATH_ARRAY = path.split('/');
|
122
|
+
var PATH_ID = Tools_1.Tools.BreakReference(PATH_ARRAY).pop();
|
123
|
+
if (PATH_ID) {
|
124
|
+
PATH_ARRAY[PATH_ARRAY.length - 1] = String(id);
|
125
|
+
path = PATH_ARRAY.join('/');
|
126
|
+
}
|
127
|
+
}
|
128
|
+
if (this.breadcrumbs.length > 0) {
|
129
|
+
this.breadcrumbs[this.breadcrumbs.length - 1].page = name;
|
130
|
+
this.breadcrumbs[this.breadcrumbs.length - 1].path = path;
|
131
|
+
Breadcrumbs_class_1.Breadcrumbs.SetLast(name, path);
|
132
|
+
}
|
133
|
+
this.router.navigateByUrl(path);
|
134
|
+
};
|
135
|
+
/** */
|
136
|
+
Page_1.prototype.SetSource = function () {
|
137
|
+
Source_class_1.Source.Set(this._page);
|
138
|
+
};
|
139
|
+
/** */
|
140
|
+
Page_1.prototype.GetSource = function () {
|
141
|
+
this._source = Source_class_1.Source.Get();
|
142
|
+
};
|
143
|
+
/** */
|
144
|
+
Page_1.prototype.GetPageResponse = function () {
|
145
|
+
this.pageResponse = Source_class_1.Source.GetPageResponse();
|
146
|
+
};
|
147
|
+
/** */
|
148
|
+
Page_1.prototype.GetNavigation = function () {
|
149
|
+
var _this = this;
|
150
|
+
if (this._source) {
|
151
|
+
this.breadcrumbs = Breadcrumbs_class_1.Breadcrumbs.Get().map(function (item) { return Object.assign({
|
152
|
+
page: item.page,
|
153
|
+
path: item.path,
|
154
|
+
click: _this.GoBack(item.path)
|
155
|
+
}); });
|
156
|
+
}
|
157
|
+
else
|
158
|
+
this.breadcrumbs = [{ page: this._page }];
|
159
|
+
};
|
160
|
+
/** */
|
161
|
+
Page_1.prototype.SetGoBack = function () {
|
162
|
+
if (this._source) {
|
163
|
+
this.goBack = {
|
164
|
+
show: true,
|
165
|
+
path: this._source.path,
|
166
|
+
click: this.GoBack()
|
167
|
+
};
|
168
|
+
}
|
169
|
+
};
|
170
|
+
/** Navigate to previous page */
|
171
|
+
Page_1.prototype.GoToSource = function (pageResponse) {
|
172
|
+
var _this = this;
|
173
|
+
if (pageResponse === void 0) { pageResponse = null; }
|
174
|
+
if (this._source) {
|
175
|
+
Breadcrumbs_class_1.Breadcrumbs.RemoveLast();
|
176
|
+
this.SetPageResponse(pageResponse);
|
177
|
+
Tools_1.Tools.Sleep().then(function (_) { return _this.router.navigateByUrl(_this._source.path); });
|
178
|
+
}
|
179
|
+
};
|
180
|
+
;
|
181
|
+
/** */
|
182
|
+
Page_1.prototype.SetPageResponse = function (pageResponse) {
|
183
|
+
if (pageResponse === void 0) { pageResponse = null; }
|
184
|
+
if (Tools_1.Tools.IsNotNull(pageResponse)) {
|
185
|
+
this._preventDestroy = true;
|
186
|
+
Source_class_1.Source.SetPageResponse(pageResponse);
|
187
|
+
}
|
188
|
+
};
|
189
|
+
;
|
190
|
+
/** */
|
191
|
+
Page_1.prototype.ReloadPage = function () {
|
192
|
+
Breadcrumbs_class_1.Breadcrumbs.RemoveLast();
|
193
|
+
Tools_1.Tools.Sleep().then(function (_) { return window.location.reload(); });
|
194
|
+
};
|
195
|
+
/** */
|
196
|
+
Page_1.prototype.Log = function (value, log) {
|
197
|
+
if (log === void 0) { log = null; }
|
198
|
+
if (Tools_1.Tools.IsNotNull(log))
|
199
|
+
console.log({ log: log, value: value });
|
200
|
+
else
|
201
|
+
console.log(value);
|
202
|
+
};
|
203
|
+
return Page_1;
|
204
|
+
}());
|
205
|
+
__setFunctionName(_classThis, "Page");
|
206
|
+
(function () {
|
207
|
+
var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
208
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
209
|
+
Page = _classThis = _classDescriptor.value;
|
210
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
211
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
212
|
+
})();
|
213
|
+
return Page = _classThis;
|
214
|
+
}();
|
215
|
+
exports.Page = Page;
|