coer-elements 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- package/components/index.d.ts +2 -0
- package/components/src/coer-alert/coer-alert.component.d.ts +23 -0
- package/components/src/components.module.d.ts +10 -0
- package/esm2022/components/index.mjs +3 -0
- package/esm2022/components/src/coer-alert/coer-alert.component.mjs +227 -0
- package/esm2022/components/src/components.module.mjs +92 -0
- package/esm2022/index.mjs +2 -2
- package/esm2022/interfaces/index.mjs +7 -0
- package/esm2022/interfaces/src/IAppSource.interface.mjs +2 -0
- package/esm2022/interfaces/src/IBreadcrumb.interface.mjs +2 -0
- package/esm2022/interfaces/src/ICoerRef.interface.mjs +2 -0
- package/esm2022/interfaces/src/IGoBack.interface.mjs +2 -0
- package/esm2022/interfaces/src/IPatch.interface.mjs +2 -0
- package/esm2022/interfaces/src/IScreenSize.interface.mjs +2 -0
- package/esm2022/tools/index.mjs +9 -0
- package/esm2022/tools/src/Breadcrumbs.class.mjs +63 -0
- package/esm2022/tools/src/ControlValue.mjs +44 -0
- package/esm2022/tools/src/DateTime.class.mjs +22 -0
- package/esm2022/tools/src/Files.class.mjs +93 -0
- package/esm2022/tools/src/Page.class.mjs +162 -0
- package/esm2022/tools/src/Screen.class.mjs +43 -0
- package/esm2022/tools/src/Source.class.mjs +80 -0
- package/esm2022/tools/src/Tools.mjs +200 -0
- package/fesm2022/coer-elements.mjs +1000 -0
- package/fesm2022/coer-elements.mjs.map +1 -1
- package/index.d.ts +1 -1
- package/interfaces/index.d.ts +6 -0
- package/interfaces/src/IAppSource.interface.d.ts +4 -0
- package/interfaces/src/IBreadcrumb.interface.d.ts +6 -0
- package/interfaces/src/ICoerRef.interface.d.ts +10 -0
- package/interfaces/src/IGoBack.interface.d.ts +6 -0
- package/interfaces/src/IPatch.interface.d.ts +5 -0
- package/interfaces/src/IScreenSize.interface.d.ts +5 -0
- package/package.json +1 -1
- package/tools/index.d.ts +8 -0
- package/tools/src/Breadcrumbs.class.d.ts +18 -0
- package/tools/src/ControlValue.d.ts +23 -0
- package/tools/src/DateTime.class.d.ts +11 -0
- package/tools/src/Files.class.d.ts +16 -0
- package/tools/src/Page.class.d.ts +66 -0
- package/tools/src/Screen.class.d.ts +11 -0
- package/tools/src/Source.class.d.ts +20 -0
- package/tools/src/Tools.d.ts +33 -0
@@ -1,4 +1,1004 @@
|
|
1
|
+
import * as i0 from '@angular/core';
|
2
|
+
import { signal, forwardRef, Component, NgModule, inject, Inject } from '@angular/core';
|
3
|
+
import { NG_VALUE_ACCESSOR, FormsModule, ReactiveFormsModule } from '@angular/forms';
|
4
|
+
import moment from 'moment';
|
5
|
+
import * as XLSX from 'xlsx';
|
6
|
+
import { RouterModule, Router, ActivatedRoute } from '@angular/router';
|
7
|
+
import { CommonModule } from '@angular/common';
|
8
|
+
import * as bootstrap from 'bootstrap';
|
9
|
+
import Swal from 'sweetalert2';
|
10
|
+
import { Observable } from 'rxjs';
|
11
|
+
|
12
|
+
const reference_signal = signal({});
|
13
|
+
const Tools = {
|
14
|
+
/** Generate a Guid */
|
15
|
+
GetGuid: (seed = 'coer-system') => {
|
16
|
+
let time = new Date().getTime();
|
17
|
+
seed = seed.toString().trim();
|
18
|
+
return seed + `-xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g, (c) => {
|
19
|
+
const random = (time + Math.random() * 16) % 16 | 0;
|
20
|
+
time = Math.floor(time / 16);
|
21
|
+
return (c == 'x' ? random : (random & 0x3 | 0x8)).toString(16);
|
22
|
+
});
|
23
|
+
},
|
24
|
+
/** Returns true if the value is null or undefined, false otherwise */
|
25
|
+
IsNull: (value) => {
|
26
|
+
if (value === undefined)
|
27
|
+
return true;
|
28
|
+
if (value === null)
|
29
|
+
return true;
|
30
|
+
return false;
|
31
|
+
},
|
32
|
+
/** Returns true if the value is not null or undefined, false otherwise */
|
33
|
+
IsNotNull: (value) => {
|
34
|
+
if (value === undefined)
|
35
|
+
return false;
|
36
|
+
if (value === null)
|
37
|
+
return false;
|
38
|
+
return true;
|
39
|
+
},
|
40
|
+
/** Returns true if the value is null or undefined or contains only whitespace, false otherwise */
|
41
|
+
IsOnlyWhiteSpace: (value) => {
|
42
|
+
if (value === undefined)
|
43
|
+
return true;
|
44
|
+
if (value === null)
|
45
|
+
return true;
|
46
|
+
if (value.toString().trim() === '')
|
47
|
+
return true;
|
48
|
+
return false;
|
49
|
+
},
|
50
|
+
/** Break reference of a object or array */
|
51
|
+
BreakReference: (object) => {
|
52
|
+
if (object === undefined)
|
53
|
+
return undefined;
|
54
|
+
if (object === null)
|
55
|
+
return null;
|
56
|
+
const OBJECT = JSON.parse(JSON.stringify(object));
|
57
|
+
return (Array.isArray(OBJECT)) ? [...OBJECT] : { ...OBJECT };
|
58
|
+
},
|
59
|
+
/** Clean extra whitespaces */
|
60
|
+
CleanUpBlanks: (text) => {
|
61
|
+
if (Tools.IsNull(text))
|
62
|
+
return '';
|
63
|
+
let worlds = String(text).split(' ');
|
64
|
+
worlds = worlds.filter(x => x.length > 0);
|
65
|
+
return worlds.join(' ');
|
66
|
+
},
|
67
|
+
/** Get properties of an object */
|
68
|
+
GetObjectProperties: (obj) => {
|
69
|
+
const properties = [];
|
70
|
+
if (Tools.IsNull(obj))
|
71
|
+
return properties;
|
72
|
+
for (const property in obj)
|
73
|
+
properties.push(String(property));
|
74
|
+
return properties;
|
75
|
+
},
|
76
|
+
/**
|
77
|
+
* Set an index and merge more arrays of the same type
|
78
|
+
* @returns A new array
|
79
|
+
* */
|
80
|
+
SetIndex: (array, ...args) => {
|
81
|
+
let index = 0;
|
82
|
+
for (const arg of args) {
|
83
|
+
array = Tools.BreakReference(array).concat(Tools.BreakReference(arg));
|
84
|
+
}
|
85
|
+
return Tools.BreakReference(array).map(item => Object.assign({ index: index++ }, item));
|
86
|
+
},
|
87
|
+
/** Set First Char To Lower */
|
88
|
+
FirstCharToLower: (text) => {
|
89
|
+
if (Tools.IsNull(text))
|
90
|
+
return '';
|
91
|
+
const textArray = [];
|
92
|
+
for (let i = 0; i < text.length; i++) {
|
93
|
+
if (i === 0)
|
94
|
+
textArray.push(text[i].toLowerCase());
|
95
|
+
else
|
96
|
+
textArray.push(text[i]);
|
97
|
+
}
|
98
|
+
return textArray.join('');
|
99
|
+
},
|
100
|
+
/** Set First Char To Upper */
|
101
|
+
FirstCharToUpper: (text) => {
|
102
|
+
if (Tools.IsNull(text))
|
103
|
+
return '';
|
104
|
+
const textArray = [];
|
105
|
+
for (let i = 0; i < text.length; i++) {
|
106
|
+
if (i === 0)
|
107
|
+
textArray.push(text[i].toUpperCase());
|
108
|
+
else
|
109
|
+
textArray.push(text[i]);
|
110
|
+
}
|
111
|
+
return textArray.join('');
|
112
|
+
},
|
113
|
+
/** Sort an array in ascending order by property */
|
114
|
+
SortBy: (array, property, propertyType = 'string') => {
|
115
|
+
switch (propertyType) {
|
116
|
+
case 'string': {
|
117
|
+
return array.sort((x, y) => {
|
118
|
+
if (String(x[property]).toUpperCase().trim() < String(y[property]).toUpperCase().trim())
|
119
|
+
return -1;
|
120
|
+
else if (String(x[property]).toUpperCase().trim() > String(y[property]).toUpperCase().trim())
|
121
|
+
return 1;
|
122
|
+
else
|
123
|
+
return 0;
|
124
|
+
});
|
125
|
+
}
|
126
|
+
case 'number': {
|
127
|
+
return array.sort((x, y) => Number(x[property] - Number(y[property])));
|
128
|
+
}
|
129
|
+
}
|
130
|
+
},
|
131
|
+
/** Sort an array in descending order by property */
|
132
|
+
SortByDesc: (array, property, propertyType = 'string') => {
|
133
|
+
switch (propertyType) {
|
134
|
+
case 'string': {
|
135
|
+
return array.sort((x, y) => {
|
136
|
+
if (String(x[property]).toUpperCase().trim() < String(y[property]).toUpperCase().trim())
|
137
|
+
return 1;
|
138
|
+
else if (String(x[property]).toUpperCase().trim() > String(y[property]).toUpperCase().trim())
|
139
|
+
return -1;
|
140
|
+
else
|
141
|
+
return 0;
|
142
|
+
});
|
143
|
+
}
|
144
|
+
case 'number': {
|
145
|
+
return array.sort((x, y) => Number(Number(y[property])) - x[property]);
|
146
|
+
}
|
147
|
+
}
|
148
|
+
},
|
149
|
+
/** Return a string with forman numeric */
|
150
|
+
GetNumericFormat: (value, decimals = 0) => {
|
151
|
+
if (value == undefined
|
152
|
+
|| value == null
|
153
|
+
|| value.toString().trim() == ''
|
154
|
+
|| isNaN(Number(value))) {
|
155
|
+
return '0';
|
156
|
+
}
|
157
|
+
let valueInteger = '';
|
158
|
+
let valueDecimal = '';
|
159
|
+
value = value.toString().replaceAll(' ', '');
|
160
|
+
if (value.includes('.') || (decimals > 0)) {
|
161
|
+
valueInteger = value.includes('.') ? value.split('.')[0] : value;
|
162
|
+
if (decimals > 0) {
|
163
|
+
const PADDING = decimals - valueDecimal.length;
|
164
|
+
valueDecimal = value.includes('.') ? value.split('.')[1] : '';
|
165
|
+
for (let i = 0; i < PADDING; i++)
|
166
|
+
valueDecimal += '0';
|
167
|
+
valueDecimal = valueDecimal.substring(0, decimals);
|
168
|
+
valueDecimal = `.${valueDecimal}`;
|
169
|
+
}
|
170
|
+
}
|
171
|
+
else {
|
172
|
+
valueInteger = value;
|
173
|
+
}
|
174
|
+
let counter = 0;
|
175
|
+
const VALUE_INTEGER_ARRAY = [];
|
176
|
+
for (const char of valueInteger.split('').reverse()) {
|
177
|
+
if (counter == 3) {
|
178
|
+
VALUE_INTEGER_ARRAY.push(',');
|
179
|
+
counter = 0;
|
180
|
+
}
|
181
|
+
VALUE_INTEGER_ARRAY.push(char);
|
182
|
+
++counter;
|
183
|
+
}
|
184
|
+
valueInteger = VALUE_INTEGER_ARRAY.reverse().join('');
|
185
|
+
return `${valueInteger}${valueDecimal}`;
|
186
|
+
},
|
187
|
+
/** Wait the time indicated */
|
188
|
+
Sleep: (milliseconds = 0, reference = null) => {
|
189
|
+
if (Tools.IsNull(reference)) {
|
190
|
+
return new Promise(Resolve => setTimeout(Resolve, milliseconds));
|
191
|
+
}
|
192
|
+
else
|
193
|
+
return new Promise(Resolve => {
|
194
|
+
reference = reference.replaceAll(' ', '_').toLowerCase();
|
195
|
+
if (reference_signal().hasOwnProperty(reference)) {
|
196
|
+
clearInterval(reference_signal()[reference]);
|
197
|
+
}
|
198
|
+
reference_signal.set(Object.assign(reference_signal(), {
|
199
|
+
[reference]: setTimeout(() => {
|
200
|
+
Resolve();
|
201
|
+
clearInterval(reference_signal()[reference]);
|
202
|
+
const _reference = { ...reference_signal() };
|
203
|
+
delete _reference[reference];
|
204
|
+
reference_signal.set({ ..._reference });
|
205
|
+
}, milliseconds)
|
206
|
+
}));
|
207
|
+
});
|
208
|
+
}
|
209
|
+
};
|
210
|
+
|
211
|
+
class Breadcrumbs {
|
212
|
+
static { this.storage = 'COER-System'; }
|
213
|
+
/** */
|
214
|
+
static Add(page, path) {
|
215
|
+
const breadcrumbs = this.Get();
|
216
|
+
const paths = breadcrumbs.map(item => item.path);
|
217
|
+
if (!paths.includes(path)) {
|
218
|
+
breadcrumbs.push({ page, path });
|
219
|
+
this.Save(breadcrumbs);
|
220
|
+
}
|
221
|
+
}
|
222
|
+
/** */
|
223
|
+
static Get() {
|
224
|
+
let storage = sessionStorage.getItem(this.storage);
|
225
|
+
if (storage) {
|
226
|
+
storage = JSON.parse(storage);
|
227
|
+
if (storage.hasOwnProperty('breadcrumbs')) {
|
228
|
+
return Tools.BreakReference(storage.breadcrumbs);
|
229
|
+
}
|
230
|
+
}
|
231
|
+
return [];
|
232
|
+
}
|
233
|
+
/** Source */
|
234
|
+
static GetFirst() {
|
235
|
+
const breadcrumbs = this.Get();
|
236
|
+
return (breadcrumbs.length > 0) ? breadcrumbs.shift() : null;
|
237
|
+
}
|
238
|
+
/** */
|
239
|
+
static Save(breadcrumbs) {
|
240
|
+
let storage = sessionStorage.getItem(this.storage);
|
241
|
+
if (storage)
|
242
|
+
storage = JSON.parse(storage);
|
243
|
+
storage = Object.assign({}, storage, { breadcrumbs });
|
244
|
+
sessionStorage.setItem(this.storage, JSON.stringify(storage));
|
245
|
+
}
|
246
|
+
/** */
|
247
|
+
static Remove(path) {
|
248
|
+
let breadcrumbs = this.Get();
|
249
|
+
const index = breadcrumbs.findIndex(x => x.path.toLowerCase().trim() === path.toLowerCase().trim());
|
250
|
+
if (index >= 0) {
|
251
|
+
breadcrumbs = Tools.BreakReference(breadcrumbs).splice(0, index + 1);
|
252
|
+
this.Save(breadcrumbs);
|
253
|
+
}
|
254
|
+
}
|
255
|
+
/** */
|
256
|
+
static SetLast(page, path) {
|
257
|
+
const breadcrumbs = this.Get();
|
258
|
+
if (breadcrumbs.length > 0) {
|
259
|
+
breadcrumbs[breadcrumbs.length - 1] = { page, path };
|
260
|
+
this.Save(breadcrumbs);
|
261
|
+
}
|
262
|
+
}
|
263
|
+
/** */
|
264
|
+
static RemoveLast() {
|
265
|
+
const breadcrumbs = this.Get();
|
266
|
+
if (breadcrumbs.length > 0) {
|
267
|
+
breadcrumbs.pop();
|
268
|
+
this.Save(breadcrumbs);
|
269
|
+
}
|
270
|
+
}
|
271
|
+
}
|
272
|
+
|
273
|
+
const CONTROL_VALUE = (component) => {
|
274
|
+
return {
|
275
|
+
provide: NG_VALUE_ACCESSOR,
|
276
|
+
useExisting: forwardRef(() => component),
|
277
|
+
multi: true
|
278
|
+
};
|
279
|
+
};
|
280
|
+
class ControlValue {
|
281
|
+
constructor() {
|
282
|
+
this._isTouched = false;
|
283
|
+
}
|
284
|
+
get isTouched() {
|
285
|
+
return this._isTouched;
|
286
|
+
}
|
287
|
+
/** */
|
288
|
+
SetValue(value) {
|
289
|
+
if (typeof this._UpdateValue === 'function') {
|
290
|
+
this._UpdateValue(value);
|
291
|
+
}
|
292
|
+
this._value = value;
|
293
|
+
}
|
294
|
+
/** */
|
295
|
+
SetTouched(isTouched) {
|
296
|
+
if (typeof this._IsTouched === 'function') {
|
297
|
+
this._IsTouched(isTouched);
|
298
|
+
}
|
299
|
+
this._isTouched = isTouched;
|
300
|
+
}
|
301
|
+
/** */
|
302
|
+
writeValue(value) {
|
303
|
+
this._value = value;
|
304
|
+
}
|
305
|
+
/** */
|
306
|
+
registerOnChange(callback) {
|
307
|
+
this._UpdateValue = callback;
|
308
|
+
}
|
309
|
+
/** */
|
310
|
+
registerOnTouched(callback) {
|
311
|
+
this._IsTouched = callback;
|
312
|
+
}
|
313
|
+
}
|
314
|
+
|
315
|
+
class DateTime {
|
316
|
+
/** Get UTC Offset */
|
317
|
+
static GetUTCOffset() {
|
318
|
+
return moment().utcOffset();
|
319
|
+
}
|
320
|
+
/** Convert UTC Date to Local Zone */
|
321
|
+
static ToLocalZone(utcDate) {
|
322
|
+
return moment(utcDate).add(DateTime.GetUTCOffset(), 'minutes').format('YYYY-MM-DD HH:mm:ss');
|
323
|
+
}
|
324
|
+
/** Convert Local Zone Date to UTC */
|
325
|
+
static ToUTC(utcDate) {
|
326
|
+
return moment(utcDate).subtract(DateTime.GetUTCOffset(), 'minutes').format('YYYY-MM-DD HH:mm:ss');
|
327
|
+
}
|
328
|
+
/** DD MMM YYYY */
|
329
|
+
static GetDateFormat(date) {
|
330
|
+
if ((typeof date === 'string'))
|
331
|
+
date = date.replaceAll('/', '-');
|
332
|
+
return moment(date).parseZone().local(true).format('DD MMM YYYY');
|
333
|
+
}
|
334
|
+
}
|
335
|
+
|
336
|
+
class Files {
|
337
|
+
static { this.EXCEL_EXTENSIONS = ['xls', 'xlsx', 'csv']; }
|
338
|
+
/** Get Extension File */
|
339
|
+
static GetExtension(file) {
|
340
|
+
const fileName = file.name;
|
341
|
+
if (fileName.includes('.')) {
|
342
|
+
let worlds = fileName.split('.');
|
343
|
+
if (worlds.length > 0) {
|
344
|
+
let extension = worlds.pop();
|
345
|
+
extension = extension.trim().toLowerCase();
|
346
|
+
if (extension.length > 0)
|
347
|
+
return extension;
|
348
|
+
}
|
349
|
+
}
|
350
|
+
return null;
|
351
|
+
}
|
352
|
+
/** Is Excel File */
|
353
|
+
static IsExcel(file) {
|
354
|
+
const EXTENSION = Files.GetExtension(file);
|
355
|
+
return Tools.IsNotNull(EXTENSION)
|
356
|
+
? this.EXCEL_EXTENSIONS.includes(EXTENSION)
|
357
|
+
: false;
|
358
|
+
}
|
359
|
+
/** Read excel file */
|
360
|
+
static ReadExcel(file) {
|
361
|
+
return new Promise(Resolve => {
|
362
|
+
let columns = [];
|
363
|
+
let rows = [];
|
364
|
+
const reader = new FileReader();
|
365
|
+
reader.readAsArrayBuffer(file);
|
366
|
+
reader.onload = () => {
|
367
|
+
const dataBytes = new Uint8Array(reader.result);
|
368
|
+
if (dataBytes) {
|
369
|
+
const workbook = XLSX.read(dataBytes, {});
|
370
|
+
const sheet = workbook.Sheets[workbook.SheetNames[0]];
|
371
|
+
let dataSheet = XLSX.utils.sheet_to_json(sheet, {
|
372
|
+
header: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
|
373
|
+
});
|
374
|
+
//Get Headers
|
375
|
+
for (const column in dataSheet[0]) {
|
376
|
+
columns.push(Tools.FirstCharToLower(String(dataSheet[0][column]).replaceAll(' ', '')));
|
377
|
+
}
|
378
|
+
//Get Rows
|
379
|
+
rows = XLSX.utils.sheet_to_json(sheet, { header: columns });
|
380
|
+
rows.shift();
|
381
|
+
rows = rows.map(row => {
|
382
|
+
const item = Tools.BreakReference(row);
|
383
|
+
delete item['__rowNum__'];
|
384
|
+
return item;
|
385
|
+
});
|
386
|
+
}
|
387
|
+
Resolve({ columns, rows });
|
388
|
+
};
|
389
|
+
reader.onerror = () => { Resolve({ columns, rows }); };
|
390
|
+
});
|
391
|
+
}
|
392
|
+
/** Export to excel file */
|
393
|
+
static ExportExcel(data, fileName = 'coer_report', sheetName = 'Sheet1') {
|
394
|
+
sheetName = Tools.CleanUpBlanks(sheetName);
|
395
|
+
fileName = Tools.CleanUpBlanks(fileName);
|
396
|
+
if (fileName.endsWith('.xls') || fileName.endsWith('.xlsx') || fileName.endsWith('.csv')) {
|
397
|
+
if (fileName.includes('.xls')) {
|
398
|
+
fileName = fileName.replaceAll('.xls', '.xlsx');
|
399
|
+
}
|
400
|
+
if (fileName.includes('.csv')) {
|
401
|
+
fileName = fileName.replaceAll('.csv', '.xlsx');
|
402
|
+
}
|
403
|
+
}
|
404
|
+
else {
|
405
|
+
fileName += '.xlsx';
|
406
|
+
}
|
407
|
+
const WORK_SHEET = XLSX.utils.json_to_sheet(data);
|
408
|
+
const WORK_BOOK = XLSX.utils.book_new();
|
409
|
+
XLSX.utils.book_append_sheet(WORK_BOOK, WORK_SHEET, 'Sheet1');
|
410
|
+
XLSX.writeFile(WORK_BOOK, fileName);
|
411
|
+
}
|
412
|
+
/** Convert file to string base64 */
|
413
|
+
static ConvertToBase64(file) {
|
414
|
+
return new Promise(Resolve => {
|
415
|
+
const reader = new FileReader();
|
416
|
+
reader.readAsDataURL(file);
|
417
|
+
reader.onload = () => {
|
418
|
+
Resolve(reader.result?.toString() || '');
|
419
|
+
};
|
420
|
+
reader.onerror = () => {
|
421
|
+
Resolve('');
|
422
|
+
};
|
423
|
+
});
|
424
|
+
}
|
425
|
+
}
|
426
|
+
|
427
|
+
class CoerAlert {
|
428
|
+
/** */
|
429
|
+
Success(message = null, title = null, icon = null, autohide = 3000) {
|
430
|
+
//Title
|
431
|
+
if (!title || title == '')
|
432
|
+
title = 'Success';
|
433
|
+
const alertSuccessTitle = document.getElementById('alert-success-title');
|
434
|
+
alertSuccessTitle.textContent = title;
|
435
|
+
//Icon
|
436
|
+
icon = this.GetIcon(title, icon, 'bi-check-circle fa-beat');
|
437
|
+
const alertSuccessIcon = document.getElementById('alert-success-icon');
|
438
|
+
this.SetIcon(alertSuccessIcon, icon);
|
439
|
+
//Message
|
440
|
+
if (!message)
|
441
|
+
message = '';
|
442
|
+
const alertSuccessMessage = document.getElementById('alert-success-message');
|
443
|
+
alertSuccessMessage.innerHTML = message;
|
444
|
+
//Toast
|
445
|
+
const alertSuccess = document.getElementById('alert-success');
|
446
|
+
this.SetAutoHide(alertSuccess, autohide);
|
447
|
+
const toast = bootstrap.Toast.getOrCreateInstance(alertSuccess);
|
448
|
+
toast.show();
|
449
|
+
}
|
450
|
+
/** */
|
451
|
+
Error(message = null, title = null, icon = null, autohide = 3000) {
|
452
|
+
//Title
|
453
|
+
if (!title || title == '')
|
454
|
+
title = 'Error';
|
455
|
+
const alertErrorTitle = document.getElementById('alert-error-title');
|
456
|
+
alertErrorTitle.textContent = title;
|
457
|
+
//Icon
|
458
|
+
icon = this.GetIcon(title, icon, 'bi-exclamation-octagon fa-beat');
|
459
|
+
const alertErrorIcon = document.getElementById('alert-error-icon');
|
460
|
+
this.SetIcon(alertErrorIcon, icon);
|
461
|
+
//Message
|
462
|
+
if (!message)
|
463
|
+
message = '';
|
464
|
+
const alertErrorBody = document.getElementById('alert-error-message');
|
465
|
+
alertErrorBody.innerHTML = message;
|
466
|
+
//Toast
|
467
|
+
const alertError = document.getElementById('alert-error');
|
468
|
+
this.SetAutoHide(alertError, autohide);
|
469
|
+
const toast = bootstrap.Toast.getOrCreateInstance(alertError);
|
470
|
+
toast.show();
|
471
|
+
}
|
472
|
+
/** */
|
473
|
+
Info(message = null, title = null, icon = null, autohide = 3000) {
|
474
|
+
//Title
|
475
|
+
if (!title || title == '')
|
476
|
+
title = 'Info';
|
477
|
+
const alertInfoTitle = document.getElementById('alert-info-title');
|
478
|
+
alertInfoTitle.textContent = title;
|
479
|
+
//Icon
|
480
|
+
icon = this.GetIcon(title, icon, 'bi-info-circle fa-beat');
|
481
|
+
const alertInfoIcon = document.getElementById('alert-info-icon');
|
482
|
+
this.SetIcon(alertInfoIcon, icon);
|
483
|
+
//Message
|
484
|
+
if (!message)
|
485
|
+
message = '';
|
486
|
+
const alertInfoBody = document.getElementById('alert-info-message');
|
487
|
+
alertInfoBody.innerHTML = message;
|
488
|
+
//Toast
|
489
|
+
const alertInfo = document.getElementById('alert-info');
|
490
|
+
this.SetAutoHide(alertInfo, autohide);
|
491
|
+
const toast = bootstrap.Toast.getOrCreateInstance(alertInfo);
|
492
|
+
toast.show();
|
493
|
+
}
|
494
|
+
/** */
|
495
|
+
Warning(message = null, title = null, icon = null, autohide = 3000) {
|
496
|
+
//Title
|
497
|
+
if (!title || title == '')
|
498
|
+
title = 'Warning';
|
499
|
+
const alertWarningTitle = document.getElementById('alert-warning-title');
|
500
|
+
alertWarningTitle.textContent = title;
|
501
|
+
//Icon
|
502
|
+
icon = this.GetIcon(title, icon, 'bi-exclamation-triangle-fill fa-beat');
|
503
|
+
const alertWarningIcon = document.getElementById('alert-warning-icon');
|
504
|
+
this.SetIcon(alertWarningIcon, icon);
|
505
|
+
//Message
|
506
|
+
if (!message)
|
507
|
+
message = '';
|
508
|
+
const alertWarningBody = document.getElementById('alert-warning-message');
|
509
|
+
alertWarningBody.innerHTML = message;
|
510
|
+
//Toast
|
511
|
+
const alertWarning = document.getElementById('alert-warning');
|
512
|
+
this.SetAutoHide(alertWarning, autohide);
|
513
|
+
const toast = bootstrap.Toast.getOrCreateInstance(alertWarning);
|
514
|
+
toast.show();
|
515
|
+
}
|
516
|
+
/** */
|
517
|
+
Close(alert) {
|
518
|
+
return new Promise(Resolve => {
|
519
|
+
const element = document.getElementById(alert);
|
520
|
+
const toast = bootstrap.Toast.getOrCreateInstance(element);
|
521
|
+
toast.hide();
|
522
|
+
setTimeout(() => { Resolve(); }, 200);
|
523
|
+
});
|
524
|
+
}
|
525
|
+
/** */
|
526
|
+
Confirm(message = 'Proceed?', alertType = 'warning', icon = null) {
|
527
|
+
return new Promise(Resolve => {
|
528
|
+
let color;
|
529
|
+
let iconType;
|
530
|
+
switch (alertType) {
|
531
|
+
case 'danger':
|
532
|
+
{
|
533
|
+
if (icon == null)
|
534
|
+
icon = 'bi-exclamation-octagon';
|
535
|
+
iconType = 'error';
|
536
|
+
color = '#dc3545'; //red
|
537
|
+
break;
|
538
|
+
}
|
539
|
+
;
|
540
|
+
case 'success':
|
541
|
+
{
|
542
|
+
if (icon == null)
|
543
|
+
icon = 'bi-check-circle';
|
544
|
+
iconType = 'info';
|
545
|
+
color = '#198754'; //green
|
546
|
+
break;
|
547
|
+
}
|
548
|
+
;
|
549
|
+
case 'info':
|
550
|
+
{
|
551
|
+
if (icon == null)
|
552
|
+
icon = 'bi-info-circle';
|
553
|
+
iconType = 'error';
|
554
|
+
color = '#0d6efd'; //blue
|
555
|
+
break;
|
556
|
+
}
|
557
|
+
;
|
558
|
+
default: {
|
559
|
+
if (icon == null)
|
560
|
+
icon = 'bi-exclamation-triangle-fill';
|
561
|
+
iconType = 'warning';
|
562
|
+
color = '#ffc107'; //yellow
|
563
|
+
break;
|
564
|
+
}
|
565
|
+
}
|
566
|
+
switch (icon) {
|
567
|
+
case 'delete':
|
568
|
+
icon = 'fa-regular fa-trash-can';
|
569
|
+
break;
|
570
|
+
}
|
571
|
+
Swal.fire({
|
572
|
+
icon: iconType,
|
573
|
+
iconColor: 'transparent',
|
574
|
+
iconHtml: `<i class="${icon}" style="color: ${color};"></i>`,
|
575
|
+
html: message,
|
576
|
+
showConfirmButton: true,
|
577
|
+
confirmButtonText: 'Yes',
|
578
|
+
confirmButtonColor: color,
|
579
|
+
focusConfirm: true,
|
580
|
+
showDenyButton: true,
|
581
|
+
denyButtonColor: color,
|
582
|
+
focusDeny: false,
|
583
|
+
reverseButtons: true,
|
584
|
+
allowOutsideClick: false,
|
585
|
+
allowEscapeKey: false,
|
586
|
+
allowEnterKey: true,
|
587
|
+
customClass: {
|
588
|
+
denyButton: 'sweet-alert-button',
|
589
|
+
confirmButton: 'sweet-alert-button'
|
590
|
+
}
|
591
|
+
}).then(({ value }) => setTimeout(() => Resolve(value)));
|
592
|
+
});
|
593
|
+
}
|
594
|
+
/** */
|
595
|
+
SetIcon(element, icon) {
|
596
|
+
for (const item of [...element.classList.value.split(' ')]) {
|
597
|
+
if (item.length > 0) {
|
598
|
+
element.classList.remove(item);
|
599
|
+
element.classList.remove('q');
|
600
|
+
}
|
601
|
+
}
|
602
|
+
icon = icon.trim();
|
603
|
+
const hasWhiteSpaces = / /;
|
604
|
+
if (hasWhiteSpaces.test(icon)) {
|
605
|
+
const classes = icon.split(' ');
|
606
|
+
for (const icon of classes)
|
607
|
+
element.classList.add(icon);
|
608
|
+
}
|
609
|
+
else
|
610
|
+
element.classList.add(icon);
|
611
|
+
}
|
612
|
+
/** */
|
613
|
+
SetAutoHide(element, autohide) {
|
614
|
+
element.removeAttribute('data-bs-autohide');
|
615
|
+
element.removeAttribute('data-bs-delay');
|
616
|
+
if (autohide && autohide > 0) {
|
617
|
+
if (autohide < 1000)
|
618
|
+
autohide = 1000;
|
619
|
+
element.setAttribute('data-bs-autohide', 'true');
|
620
|
+
element.setAttribute('data-bs-delay', String(autohide));
|
621
|
+
}
|
622
|
+
else
|
623
|
+
element.setAttribute('data-bs-autohide', 'false');
|
624
|
+
}
|
625
|
+
/** */
|
626
|
+
GetIcon(title, icon, iconDefault) {
|
627
|
+
if (icon == null || icon == '') {
|
628
|
+
title = title.replaceAll(' ', '').toUpperCase();
|
629
|
+
switch (title) {
|
630
|
+
case 'ENABLED': return 'fa-solid fa-thumbs-up fa-flip-horizontal';
|
631
|
+
case 'ACTIVE': return 'fa-solid fa-thumbs-up fa-flip-horizontal';
|
632
|
+
case 'ACTIVED': return 'fa-solid fa-thumbs-up fa-flip-horizontal';
|
633
|
+
case 'DISABLE': return 'fa-solid fa-thumbs-down fa-flip-horizontal';
|
634
|
+
case 'DISABLED': return 'fa-solid fa-thumbs-down fa-flip-horizontal';
|
635
|
+
case 'DELETE': return 'fa-regular fa-trash-can';
|
636
|
+
case 'DELETED': return 'fa-regular fa-trash-can';
|
637
|
+
default: return iconDefault;
|
638
|
+
}
|
639
|
+
}
|
640
|
+
return icon;
|
641
|
+
}
|
642
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CoerAlert, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
643
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: CoerAlert, selector: "coer-alert", ngImport: i0, template: "<aside class=\"toast-container coer-alert\">\r\n <!-- Success -->\r\n <div id=\"alert-success\" role=\"alert\" aria-live=\"assertive\" aria-atomic=\"true\" class=\"toast\">\r\n <div class=\"toast-header\">\r\n <i id=\"alert-success-icon\"></i>\r\n <strong id=\"alert-success-title\"></strong>\r\n <button type=\"button\" (click)=\"Close('alert-success')\" class=\"btn-close btn-close-white\"></button>\r\n </div>\r\n\r\n <div class=\"toast-body\">\r\n <pre id=\"alert-success-message\"></pre>\r\n </div>\r\n </div>\r\n\r\n\r\n <!-- Error -->\r\n <div id=\"alert-error\" role=\"alert\" aria-live=\"assertive\" aria-atomic=\"true\" class=\"toast\">\r\n <div class=\"toast-header\">\r\n <i id=\"alert-error-icon\"></i>\r\n <strong id=\"alert-error-title\"></strong>\r\n <button type=\"button\" (click)=\"Close('alert-error')\" class=\"btn-close btn-close-white\"></button>\r\n </div>\r\n\r\n <div class=\"toast-body\">\r\n <pre id=\"alert-error-message\"></pre>\r\n </div>\r\n </div>\r\n\r\n\r\n <!-- Info -->\r\n <div id=\"alert-info\" role=\"alert\" aria-live=\"assertive\" aria-atomic=\"true\" class=\"toast\">\r\n <div class=\"toast-header\">\r\n <i id=\"alert-info-icon\"></i>\r\n <strong id=\"alert-info-title\"></strong>\r\n <button type=\"button\" (click)=\"Close('alert-info')\" class=\"btn-close btn-close-white\"></button>\r\n </div>\r\n\r\n <div class=\"toast-body\">\r\n <pre id=\"alert-info-message\"></pre>\r\n </div>\r\n </div>\r\n\r\n\r\n <!-- Warning -->\r\n <div id=\"alert-warning\" role=\"alert\" aria-live=\"assertive\" aria-atomic=\"true\" class=\"toast\">\r\n <div class=\"toast-header\">\r\n <i id=\"alert-warning-icon\"></i>\r\n <strong id=\"alert-warning-title\"></strong>\r\n <button type=\"button\" (click)=\"Close('alert-warning')\" class=\"btn-close\"></button>\r\n </div>\r\n\r\n <div class=\"toast-body\">\r\n <pre id=\"alert-warning-message\"></pre>\r\n </div>\r\n </div>\r\n</aside>", styles: [".text-blue{color:#0d6efd!important}.text-blue-bold{color:#0d6efd!important;font-weight:700!important}.background-blue{background-color:#0d6efd!important}.background-border-blue{background-color:#0d6efd!important;border-color:#0d6efd!important}.text-gray{color:#6c757d!important}.text-gray-bold{color:#6c757d!important;font-weight:700!important}.background-gray{background-color:#6c757d!important}.background-border-gray{background-color:#6c757d!important;border-color:#6c757d!important}.text-green{color:#198754!important}.text-green-bold{color:#198754!important;font-weight:700!important}.background-green{background-color:#198754!important}.background-border-green{background-color:#198754!important;border-color:#198754!important}.text-yellow{color:#ffc107!important}.text-yellow-bold{color:#ffc107!important;font-weight:700!important}.background-yellow{background-color:#ffc107!important}.background-border-yellow{background-color:#ffc107!important;border-color:#ffc107!important}.text-red{color:#dc3545!important}.text-red-bold{color:#dc3545!important;font-weight:700!important}.background-red{background-color:#dc3545!important}.background-border-red{background-color:#dc3545!important;border-color:#dc3545!important}.text-white{color:#f5f5f5!important}.text-white-bold{color:#f5f5f5!important;font-weight:700!important}.background-white{background-color:#f5f5f5!important}.background-border-white{background-color:#f5f5f5!important;border-color:#f5f5f5!important}.text-black{color:#252525!important}.text-black-bold{color:#252525!important;font-weight:700!important}.background-black{background-color:#252525!important}.background-border-black{background-color:#252525!important;border-color:#252525!important}.text-orange{color:#fd6031!important}.text-orange-bold{color:#fd6031!important;font-weight:700!important}.background-orange{background-color:#fd6031!important}.background-border-orange{background-color:#fd6031!important;border-color:#fd6031!important}aside.toast-container{position:fixed;bottom:0;right:0;padding:15px!important;z-index:2000!important}aside.toast-container i,aside.toast-container svg{display:flex;align-items:center}aside.toast-container strong{margin:0 auto 0 5px}aside.toast-container div.toast,aside.toast-container div.toast-header{border-top-left-radius:10px;border-top-right-radius:10px;color:#f5f5f5}aside.toast-container div.toast,aside.toast-container div.toast-body{border-bottom-left-radius:10px;border-bottom-right-radius:10px;color:#f5f5f5}aside.toast-container div.toast-body{min-height:36px}aside.toast-container pre{font-family:Roboto,RobotoFallback,Noto Kufi Arabic,Helvetica,Arial,sans-serif;white-space:pre-wrap;font-size:medium}aside.toast-container button{margin:0 2px!important;width:10px!important;height:10px!important;box-shadow:none!important;outline:none!important;border:none!important}aside.toast-container div#alert-success div.toast-header,aside.toast-container div#alert-success div.toast-body{background-color:#198754}aside.toast-container div#alert-info div.toast-header,aside.toast-container div#alert-info div.toast-body{background-color:#0d6efd}aside.toast-container div#alert-error div.toast-header,aside.toast-container div#alert-error div.toast-body{background-color:#dc3545}aside.toast-container div#alert-warning div.toast-header,aside.toast-container div#alert-warning div.toast-body{background-color:#ffc107;border-color:#252525;color:#252525}aside.toast-container div#alert-success:hover,aside.toast-container div#alert-info:hover,aside.toast-container div#alert-error:hover,aside.toast-container div#alert-warning:hover{transform:scale(1.01);box-shadow:2px 2px 10px #789;cursor:default}button.sweet-alert-button{width:100px!important;height:40px!important;display:flex!important;align-items:center!important;justify-content:center!important;margin:0 5px!important;outline:none!important;border:none!important;box-shadow:none!important}aside.toast-container>*{border:none!important;z-index:2000!important;margin:15px 0 0!important}\n"] }); }
|
644
|
+
}
|
645
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CoerAlert, decorators: [{
|
646
|
+
type: Component,
|
647
|
+
args: [{ selector: 'coer-alert', template: "<aside class=\"toast-container coer-alert\">\r\n <!-- Success -->\r\n <div id=\"alert-success\" role=\"alert\" aria-live=\"assertive\" aria-atomic=\"true\" class=\"toast\">\r\n <div class=\"toast-header\">\r\n <i id=\"alert-success-icon\"></i>\r\n <strong id=\"alert-success-title\"></strong>\r\n <button type=\"button\" (click)=\"Close('alert-success')\" class=\"btn-close btn-close-white\"></button>\r\n </div>\r\n\r\n <div class=\"toast-body\">\r\n <pre id=\"alert-success-message\"></pre>\r\n </div>\r\n </div>\r\n\r\n\r\n <!-- Error -->\r\n <div id=\"alert-error\" role=\"alert\" aria-live=\"assertive\" aria-atomic=\"true\" class=\"toast\">\r\n <div class=\"toast-header\">\r\n <i id=\"alert-error-icon\"></i>\r\n <strong id=\"alert-error-title\"></strong>\r\n <button type=\"button\" (click)=\"Close('alert-error')\" class=\"btn-close btn-close-white\"></button>\r\n </div>\r\n\r\n <div class=\"toast-body\">\r\n <pre id=\"alert-error-message\"></pre>\r\n </div>\r\n </div>\r\n\r\n\r\n <!-- Info -->\r\n <div id=\"alert-info\" role=\"alert\" aria-live=\"assertive\" aria-atomic=\"true\" class=\"toast\">\r\n <div class=\"toast-header\">\r\n <i id=\"alert-info-icon\"></i>\r\n <strong id=\"alert-info-title\"></strong>\r\n <button type=\"button\" (click)=\"Close('alert-info')\" class=\"btn-close btn-close-white\"></button>\r\n </div>\r\n\r\n <div class=\"toast-body\">\r\n <pre id=\"alert-info-message\"></pre>\r\n </div>\r\n </div>\r\n\r\n\r\n <!-- Warning -->\r\n <div id=\"alert-warning\" role=\"alert\" aria-live=\"assertive\" aria-atomic=\"true\" class=\"toast\">\r\n <div class=\"toast-header\">\r\n <i id=\"alert-warning-icon\"></i>\r\n <strong id=\"alert-warning-title\"></strong>\r\n <button type=\"button\" (click)=\"Close('alert-warning')\" class=\"btn-close\"></button>\r\n </div>\r\n\r\n <div class=\"toast-body\">\r\n <pre id=\"alert-warning-message\"></pre>\r\n </div>\r\n </div>\r\n</aside>", styles: [".text-blue{color:#0d6efd!important}.text-blue-bold{color:#0d6efd!important;font-weight:700!important}.background-blue{background-color:#0d6efd!important}.background-border-blue{background-color:#0d6efd!important;border-color:#0d6efd!important}.text-gray{color:#6c757d!important}.text-gray-bold{color:#6c757d!important;font-weight:700!important}.background-gray{background-color:#6c757d!important}.background-border-gray{background-color:#6c757d!important;border-color:#6c757d!important}.text-green{color:#198754!important}.text-green-bold{color:#198754!important;font-weight:700!important}.background-green{background-color:#198754!important}.background-border-green{background-color:#198754!important;border-color:#198754!important}.text-yellow{color:#ffc107!important}.text-yellow-bold{color:#ffc107!important;font-weight:700!important}.background-yellow{background-color:#ffc107!important}.background-border-yellow{background-color:#ffc107!important;border-color:#ffc107!important}.text-red{color:#dc3545!important}.text-red-bold{color:#dc3545!important;font-weight:700!important}.background-red{background-color:#dc3545!important}.background-border-red{background-color:#dc3545!important;border-color:#dc3545!important}.text-white{color:#f5f5f5!important}.text-white-bold{color:#f5f5f5!important;font-weight:700!important}.background-white{background-color:#f5f5f5!important}.background-border-white{background-color:#f5f5f5!important;border-color:#f5f5f5!important}.text-black{color:#252525!important}.text-black-bold{color:#252525!important;font-weight:700!important}.background-black{background-color:#252525!important}.background-border-black{background-color:#252525!important;border-color:#252525!important}.text-orange{color:#fd6031!important}.text-orange-bold{color:#fd6031!important;font-weight:700!important}.background-orange{background-color:#fd6031!important}.background-border-orange{background-color:#fd6031!important;border-color:#fd6031!important}aside.toast-container{position:fixed;bottom:0;right:0;padding:15px!important;z-index:2000!important}aside.toast-container i,aside.toast-container svg{display:flex;align-items:center}aside.toast-container strong{margin:0 auto 0 5px}aside.toast-container div.toast,aside.toast-container div.toast-header{border-top-left-radius:10px;border-top-right-radius:10px;color:#f5f5f5}aside.toast-container div.toast,aside.toast-container div.toast-body{border-bottom-left-radius:10px;border-bottom-right-radius:10px;color:#f5f5f5}aside.toast-container div.toast-body{min-height:36px}aside.toast-container pre{font-family:Roboto,RobotoFallback,Noto Kufi Arabic,Helvetica,Arial,sans-serif;white-space:pre-wrap;font-size:medium}aside.toast-container button{margin:0 2px!important;width:10px!important;height:10px!important;box-shadow:none!important;outline:none!important;border:none!important}aside.toast-container div#alert-success div.toast-header,aside.toast-container div#alert-success div.toast-body{background-color:#198754}aside.toast-container div#alert-info div.toast-header,aside.toast-container div#alert-info div.toast-body{background-color:#0d6efd}aside.toast-container div#alert-error div.toast-header,aside.toast-container div#alert-error div.toast-body{background-color:#dc3545}aside.toast-container div#alert-warning div.toast-header,aside.toast-container div#alert-warning div.toast-body{background-color:#ffc107;border-color:#252525;color:#252525}aside.toast-container div#alert-success:hover,aside.toast-container div#alert-info:hover,aside.toast-container div#alert-error:hover,aside.toast-container div#alert-warning:hover{transform:scale(1.01);box-shadow:2px 2px 10px #789;cursor:default}button.sweet-alert-button{width:100px!important;height:40px!important;display:flex!important;align-items:center!important;justify-content:center!important;margin:0 5px!important;outline:none!important;border:none!important;box-shadow:none!important}aside.toast-container>*{border:none!important;z-index:2000!important;margin:15px 0 0!important}\n"] }]
|
648
|
+
}] });
|
649
|
+
|
650
|
+
//import { CoerButton } from './coer-button/coer-button.component';
|
651
|
+
//import { CoerCheckbox } from './coer-checkbox/coer-checkbox.component';
|
652
|
+
//import { CoerFilebox } from './coer-filebox/coer-filebox.component';
|
653
|
+
//import { CoerForm } from './coer-form/coer-form.component';
|
654
|
+
//import { CoerGrid } from './coer-grid/coer-grid.component';
|
655
|
+
//import { CoerModal } from './coer-modal/coer-modal.component';
|
656
|
+
//import { CoerNumberBox } from './coer-numberbox/coer-numberbox.component';
|
657
|
+
//import { CoerPageTitle } from './coer-page-title/coer-page-title.component';
|
658
|
+
//import { CoerSelectbox } from './coer-selectbox/coer-selectbox.component';
|
659
|
+
//import { CoerSwitch } from './coer-switch/coer-switch.component';
|
660
|
+
//import { CoerTab } from './coer-tab/coer-tab.component';
|
661
|
+
//import { CoerTextarea } from './coer-textarea/coer-textarea.component';
|
662
|
+
//import { CoerTextBox } from './coer-textbox/coer-textbox.component';
|
663
|
+
class ComponentsModule {
|
664
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ComponentsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
665
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.3.12", ngImport: i0, type: ComponentsModule, declarations: [CoerAlert], imports: [CommonModule,
|
666
|
+
RouterModule,
|
667
|
+
FormsModule,
|
668
|
+
ReactiveFormsModule], exports: [CoerAlert] }); }
|
669
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ComponentsModule, imports: [CommonModule,
|
670
|
+
RouterModule,
|
671
|
+
FormsModule,
|
672
|
+
ReactiveFormsModule] }); }
|
673
|
+
}
|
674
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ComponentsModule, decorators: [{
|
675
|
+
type: NgModule,
|
676
|
+
args: [{
|
677
|
+
imports: [
|
678
|
+
CommonModule,
|
679
|
+
RouterModule,
|
680
|
+
FormsModule,
|
681
|
+
ReactiveFormsModule,
|
682
|
+
//PipesModule,
|
683
|
+
//MatButtonModule,
|
684
|
+
//MatCheckboxModule,
|
685
|
+
//MatInputModule,
|
686
|
+
//MatFormFieldModule,
|
687
|
+
//MatSlideToggleModule,
|
688
|
+
//MatTabsModule,
|
689
|
+
//DirectivesModule
|
690
|
+
],
|
691
|
+
declarations: [
|
692
|
+
CoerAlert,
|
693
|
+
//CoerButton,
|
694
|
+
//CoerCheckbox,
|
695
|
+
//CoerFilebox,
|
696
|
+
//CoerForm,
|
697
|
+
//CoerGrid,
|
698
|
+
//CoerModal,
|
699
|
+
//CoerNumberBox,
|
700
|
+
//CoerPageTitle,
|
701
|
+
//CoerSelectbox,
|
702
|
+
//CoerSwitch,
|
703
|
+
//CoerTextarea,
|
704
|
+
//CoerTab,
|
705
|
+
//CoerTextBox,
|
706
|
+
],
|
707
|
+
exports: [
|
708
|
+
CoerAlert,
|
709
|
+
//CoerButton,
|
710
|
+
//CoerCheckbox,
|
711
|
+
//CoerFilebox,
|
712
|
+
//CoerForm,
|
713
|
+
//CoerGrid,
|
714
|
+
//CoerModal,
|
715
|
+
//CoerNumberBox,
|
716
|
+
//CoerPageTitle,
|
717
|
+
//CoerSelectbox,
|
718
|
+
//CoerSwitch,
|
719
|
+
//CoerTextarea,
|
720
|
+
//CoerTab,
|
721
|
+
//CoerTextBox,
|
722
|
+
]
|
723
|
+
}]
|
724
|
+
}] });
|
725
|
+
|
726
|
+
class Source {
|
727
|
+
static { this.storage = 'COER-System'; }
|
728
|
+
/** */
|
729
|
+
static Set(page) {
|
730
|
+
const ROUTER = inject(Router);
|
731
|
+
let path = ROUTER.url;
|
732
|
+
if (path.includes('?'))
|
733
|
+
path = path.split('?')[0];
|
734
|
+
Breadcrumbs.Add(page, path);
|
735
|
+
const breadcrumbs = Breadcrumbs.Get();
|
736
|
+
if (breadcrumbs.length >= 2) {
|
737
|
+
breadcrumbs.pop();
|
738
|
+
const breadcrumb = breadcrumbs.pop();
|
739
|
+
this.Save({ page: breadcrumb.page, path: breadcrumb.path });
|
740
|
+
}
|
741
|
+
else
|
742
|
+
this.Save(null);
|
743
|
+
}
|
744
|
+
/** */
|
745
|
+
static Save(source) {
|
746
|
+
let storage = sessionStorage.getItem(this.storage);
|
747
|
+
if (storage)
|
748
|
+
storage = JSON.parse(storage);
|
749
|
+
storage = Object.assign({}, storage, { source });
|
750
|
+
sessionStorage.setItem(this.storage, JSON.stringify(storage));
|
751
|
+
}
|
752
|
+
/** */
|
753
|
+
static Get() {
|
754
|
+
let storage = sessionStorage.getItem(this.storage);
|
755
|
+
if (storage) {
|
756
|
+
storage = JSON.parse(storage);
|
757
|
+
if (storage.hasOwnProperty('source')) {
|
758
|
+
return storage.source;
|
759
|
+
}
|
760
|
+
}
|
761
|
+
return null;
|
762
|
+
}
|
763
|
+
/** */
|
764
|
+
static GetRoot() {
|
765
|
+
const breadcrumbs = Breadcrumbs.Get();
|
766
|
+
return (breadcrumbs.length > 0) ? breadcrumbs.shift() : null;
|
767
|
+
}
|
768
|
+
/** */
|
769
|
+
static SetPageResponse(pageResponse) {
|
770
|
+
let storage = sessionStorage.getItem(this.storage);
|
771
|
+
storage = JSON.parse(storage);
|
772
|
+
storage = Object.assign({}, storage, { pageResponse });
|
773
|
+
sessionStorage.setItem(this.storage, JSON.stringify(storage));
|
774
|
+
}
|
775
|
+
/** */
|
776
|
+
static GetPageResponse() {
|
777
|
+
let storage = sessionStorage.getItem(this.storage);
|
778
|
+
if (storage) {
|
779
|
+
storage = JSON.parse(storage);
|
780
|
+
if (storage.hasOwnProperty('pageResponse')) {
|
781
|
+
return Tools.BreakReference(storage.pageResponse);
|
782
|
+
}
|
783
|
+
}
|
784
|
+
return null;
|
785
|
+
}
|
786
|
+
/** */
|
787
|
+
static ClearPageResponse() {
|
788
|
+
let storage = sessionStorage.getItem(this.storage);
|
789
|
+
storage = JSON.parse(storage);
|
790
|
+
if (storage.hasOwnProperty('pageResponse')) {
|
791
|
+
delete storage.pageResponse;
|
792
|
+
}
|
793
|
+
storage = Object.assign({}, storage);
|
794
|
+
sessionStorage.setItem(this.storage, JSON.stringify(storage));
|
795
|
+
}
|
796
|
+
/** Clear Source */
|
797
|
+
static Reset() {
|
798
|
+
sessionStorage.removeItem(this.storage);
|
799
|
+
}
|
800
|
+
}
|
801
|
+
|
802
|
+
class Page {
|
803
|
+
constructor(page) {
|
804
|
+
//Injection
|
805
|
+
this.alert = inject(CoerAlert);
|
806
|
+
this.router = inject(Router);
|
807
|
+
this.activatedRoute = inject(ActivatedRoute);
|
808
|
+
/** */
|
809
|
+
this.isUpdate = false;
|
810
|
+
/** */
|
811
|
+
this.isLoading = false;
|
812
|
+
/** */
|
813
|
+
this.isReady = false;
|
814
|
+
/** */
|
815
|
+
this.enableAnimations = false;
|
816
|
+
/** */
|
817
|
+
this.breadcrumbs = [];
|
818
|
+
/** */
|
819
|
+
this.pageResponse = null;
|
820
|
+
/** */
|
821
|
+
this.goBack = { show: false };
|
822
|
+
//Private Variables
|
823
|
+
this._page = '';
|
824
|
+
this._source = null;
|
825
|
+
this._preventDestroy = false;
|
826
|
+
/** */
|
827
|
+
this.GoBack = (path) => (() => {
|
828
|
+
if (path)
|
829
|
+
Breadcrumbs.Remove(path);
|
830
|
+
else
|
831
|
+
Breadcrumbs.RemoveLast();
|
832
|
+
});
|
833
|
+
/** Returns true if the value is null or undefined, false otherwise */
|
834
|
+
this.IsNotNull = Tools.IsNotNull;
|
835
|
+
/** Returns true if the value is null or undefined, false otherwise */
|
836
|
+
this.IsNull = Tools.IsNull;
|
837
|
+
/** Returns true if the value is null or undefined or contains only whitespace, false otherwise */
|
838
|
+
this.IsOnlyWhiteSpace = Tools.IsOnlyWhiteSpace;
|
839
|
+
this.SetPageName(page);
|
840
|
+
this.SetSource();
|
841
|
+
this.GetSource();
|
842
|
+
this.GetNavigation();
|
843
|
+
this.SetGoBack();
|
844
|
+
this.GetPageResponse();
|
845
|
+
}
|
846
|
+
ngAfterViewInit() {
|
847
|
+
this.routeParams = this.activatedRoute.snapshot.params;
|
848
|
+
this.queryParams = this.activatedRoute.snapshot.queryParams;
|
849
|
+
setTimeout(() => {
|
850
|
+
this.isReady = true;
|
851
|
+
this.RunPage();
|
852
|
+
setTimeout(() => { this.enableAnimations = true; }, 1000);
|
853
|
+
});
|
854
|
+
}
|
855
|
+
ngOnDestroy() {
|
856
|
+
if (!this._preventDestroy)
|
857
|
+
Source.ClearPageResponse();
|
858
|
+
}
|
859
|
+
/** Main method. Starts after ngAfterViewInit() */
|
860
|
+
RunPage() { }
|
861
|
+
;
|
862
|
+
/** Rename the last breadcrumb and update the url id */
|
863
|
+
SetPageName(name, id = null) {
|
864
|
+
this._page = name;
|
865
|
+
let path = this.router.url;
|
866
|
+
if (path.includes('?'))
|
867
|
+
path = path.split('?')[0];
|
868
|
+
if (id) {
|
869
|
+
const PATH_ARRAY = path.split('/');
|
870
|
+
const PATH_ID = Tools.BreakReference(PATH_ARRAY).pop();
|
871
|
+
if (PATH_ID) {
|
872
|
+
PATH_ARRAY[PATH_ARRAY.length - 1] = String(id);
|
873
|
+
path = PATH_ARRAY.join('/');
|
874
|
+
}
|
875
|
+
}
|
876
|
+
if (this.breadcrumbs.length > 0) {
|
877
|
+
this.breadcrumbs[this.breadcrumbs.length - 1].page = name;
|
878
|
+
this.breadcrumbs[this.breadcrumbs.length - 1].path = path;
|
879
|
+
Breadcrumbs.SetLast(name, path);
|
880
|
+
}
|
881
|
+
this.router.navigateByUrl(path);
|
882
|
+
}
|
883
|
+
/** */
|
884
|
+
SetSource() {
|
885
|
+
Source.Set(this._page);
|
886
|
+
}
|
887
|
+
/** */
|
888
|
+
GetSource() {
|
889
|
+
this._source = Source.Get();
|
890
|
+
}
|
891
|
+
/** */
|
892
|
+
GetPageResponse() {
|
893
|
+
this.pageResponse = Source.GetPageResponse();
|
894
|
+
}
|
895
|
+
/** */
|
896
|
+
GetNavigation() {
|
897
|
+
if (this._source) {
|
898
|
+
this.breadcrumbs = Breadcrumbs.Get().map(item => Object.assign({
|
899
|
+
page: item.page,
|
900
|
+
path: item.path,
|
901
|
+
click: this.GoBack(item.path)
|
902
|
+
}));
|
903
|
+
}
|
904
|
+
else
|
905
|
+
this.breadcrumbs = [{ page: this._page }];
|
906
|
+
}
|
907
|
+
/** */
|
908
|
+
SetGoBack() {
|
909
|
+
if (this._source) {
|
910
|
+
this.goBack = {
|
911
|
+
show: true,
|
912
|
+
path: this._source.path,
|
913
|
+
click: this.GoBack()
|
914
|
+
};
|
915
|
+
}
|
916
|
+
}
|
917
|
+
/** Navigate to previous page */
|
918
|
+
GoToSource(pageResponse = null) {
|
919
|
+
if (this._source) {
|
920
|
+
Breadcrumbs.RemoveLast();
|
921
|
+
this.SetPageResponse(pageResponse);
|
922
|
+
Tools.Sleep().then(_ => this.router.navigateByUrl(this._source.path));
|
923
|
+
}
|
924
|
+
}
|
925
|
+
;
|
926
|
+
/** */
|
927
|
+
SetPageResponse(pageResponse = null) {
|
928
|
+
if (Tools.IsNotNull(pageResponse)) {
|
929
|
+
this._preventDestroy = true;
|
930
|
+
Source.SetPageResponse(pageResponse);
|
931
|
+
}
|
932
|
+
}
|
933
|
+
;
|
934
|
+
/** */
|
935
|
+
ReloadPage() {
|
936
|
+
Breadcrumbs.RemoveLast();
|
937
|
+
Tools.Sleep().then(_ => window.location.reload());
|
938
|
+
}
|
939
|
+
/** */
|
940
|
+
Log(value, log = null) {
|
941
|
+
if (Tools.IsNotNull(log))
|
942
|
+
console.log({ log, value });
|
943
|
+
else
|
944
|
+
console.log(value);
|
945
|
+
}
|
946
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: Page, deps: [{ token: String }], target: i0.ɵɵFactoryTarget.Component }); }
|
947
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: Page, selector: "ng-component", ngImport: i0, template: '', isInline: true }); }
|
948
|
+
}
|
949
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: Page, decorators: [{
|
950
|
+
type: Component,
|
951
|
+
args: [{ template: '' }]
|
952
|
+
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
953
|
+
type: Inject,
|
954
|
+
args: [String]
|
955
|
+
}] }] });
|
956
|
+
|
957
|
+
class Screen {
|
958
|
+
static get WINDOW_WIDTH() {
|
959
|
+
return window.innerWidth;
|
960
|
+
}
|
961
|
+
static get WINDOW_HEIGHT() {
|
962
|
+
return window.innerHeight;
|
963
|
+
}
|
964
|
+
static get DEVICE_WIDTH() {
|
965
|
+
return window.screen.width;
|
966
|
+
}
|
967
|
+
static get DEVICE_HEIGHT() {
|
968
|
+
return window.screen.height;
|
969
|
+
}
|
970
|
+
static get BREAKPOINT() {
|
971
|
+
if (window.innerWidth < 576)
|
972
|
+
return 'xs';
|
973
|
+
else if (window.innerWidth >= 576 && window.innerWidth < 768)
|
974
|
+
return 'sm';
|
975
|
+
else if (window.innerWidth >= 768 && window.innerWidth < 992)
|
976
|
+
return 'md';
|
977
|
+
else if (window.innerWidth >= 992 && window.innerWidth < 1200)
|
978
|
+
return 'lg';
|
979
|
+
else if (window.innerWidth >= 1200 && window.innerWidth < 1400)
|
980
|
+
return 'xl';
|
981
|
+
else
|
982
|
+
return 'xxl';
|
983
|
+
}
|
984
|
+
/** */
|
985
|
+
static { this.Resize = new Observable(subscriber => {
|
986
|
+
window.addEventListener("load", () => {
|
987
|
+
window.dispatchEvent(new Event('resize'));
|
988
|
+
});
|
989
|
+
window.onresize = () => {
|
990
|
+
subscriber.next({
|
991
|
+
width: window.innerWidth,
|
992
|
+
height: window.innerHeight,
|
993
|
+
breakpoin: this.BREAKPOINT
|
994
|
+
});
|
995
|
+
};
|
996
|
+
}); }
|
997
|
+
}
|
998
|
+
|
1
999
|
/**
|
2
1000
|
* Generated bundle index. Do not edit.
|
3
1001
|
*/
|
1002
|
+
|
1003
|
+
export { Breadcrumbs, CONTROL_VALUE, ControlValue, DateTime, Files, Page, Screen, Source, Tools };
|
4
1004
|
//# sourceMappingURL=coer-elements.mjs.map
|