@senior-gestao-relacionamento/angular-components 1.7.0 → 1.7.1
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.
- package/bundles/senior-gestao-relacionamento-angular-components.umd.js +109 -25
- package/bundles/senior-gestao-relacionamento-angular-components.umd.js.map +1 -1
- package/bundles/senior-gestao-relacionamento-angular-components.umd.min.js +2 -2
- package/bundles/senior-gestao-relacionamento-angular-components.umd.min.js.map +1 -1
- package/esm2015/services/current-collaborator/current-collaborator.module.js +2 -2
- package/esm2015/services/current-collaborator/current-collaborator.service.js +1 -14
- package/esm2015/services/current-collaborator/models/collaborator-e-070-fil-crmx.js +9 -3
- package/esm2015/services/current-collaborator/models/collaborator-squad.js +3 -2
- package/esm2015/services/current-collaborator/models/collaborator.js +8 -3
- package/esm2015/services/current-collaborator/models/e-070-emp.js +3 -2
- package/esm2015/services/current-collaborator/models/e-070-fil-crmx.js +3 -2
- package/esm2015/services/current-collaborator/models/e-070-fil.js +3 -2
- package/esm2015/services/current-collaborator/models/squad.js +3 -2
- package/esm2015/services/current-collaborator/models/user.js +3 -2
- package/esm2015/services/storage/storage.service.js +3 -2
- package/esm2015/utils/index.js +2 -1
- package/esm2015/utils/utils.js +80 -0
- package/esm5/services/current-collaborator/current-collaborator.module.js +2 -2
- package/esm5/services/current-collaborator/current-collaborator.service.js +1 -14
- package/esm5/services/current-collaborator/models/collaborator-e-070-fil-crmx.js +9 -3
- package/esm5/services/current-collaborator/models/collaborator-squad.js +3 -2
- package/esm5/services/current-collaborator/models/collaborator.js +8 -3
- package/esm5/services/current-collaborator/models/e-070-emp.js +3 -2
- package/esm5/services/current-collaborator/models/e-070-fil-crmx.js +3 -2
- package/esm5/services/current-collaborator/models/e-070-fil.js +3 -2
- package/esm5/services/current-collaborator/models/squad.js +3 -2
- package/esm5/services/current-collaborator/models/user.js +3 -2
- package/esm5/services/storage/storage.service.js +3 -2
- package/esm5/utils/index.js +2 -1
- package/esm5/utils/utils.js +82 -0
- package/fesm2015/senior-gestao-relacionamento-angular-components.js +101 -26
- package/fesm2015/senior-gestao-relacionamento-angular-components.js.map +1 -1
- package/fesm5/senior-gestao-relacionamento-angular-components.js +102 -26
- package/fesm5/senior-gestao-relacionamento-angular-components.js.map +1 -1
- package/package.json +1 -1
- package/senior-gestao-relacionamento-angular-components.metadata.json +1 -1
- package/services/current-collaborator/current-collaborator.service.d.ts +0 -1
- package/services/current-collaborator/models/collaborator-e-070-fil-crmx.d.ts +1 -0
- package/services/current-collaborator/models/collaborator-squad.d.ts +1 -0
- package/services/current-collaborator/models/e-070-emp.d.ts +1 -0
- package/services/current-collaborator/models/e-070-fil-crmx.d.ts +1 -1
- package/services/current-collaborator/models/e-070-fil.d.ts +1 -0
- package/services/current-collaborator/models/squad.d.ts +1 -0
- package/services/current-collaborator/models/user.d.ts +1 -0
- package/utils/index.d.ts +1 -0
- package/utils/utils.d.ts +12 -0
|
@@ -407,6 +407,85 @@ const fallback = {
|
|
|
407
407
|
"crmx.angular_components.refresh_websocket_alert_summary_default": "Atualização de dados"
|
|
408
408
|
};
|
|
409
409
|
|
|
410
|
+
const numberTypes = [FieldType.Integer, FieldType.Double];
|
|
411
|
+
const numberPattern = /^\d+\b$/;
|
|
412
|
+
const mergeUnique = (array, otherArray) => array.concat(otherArray.filter((item) => !array.includes(item)));
|
|
413
|
+
const getTypeInformation = (type, value) => {
|
|
414
|
+
switch (type) {
|
|
415
|
+
case FieldType.Time:
|
|
416
|
+
case FieldType.Date:
|
|
417
|
+
case FieldType.LocalDateTime:
|
|
418
|
+
case FieldType.DateTime:
|
|
419
|
+
return { isValidValue: false, typeExists: true };
|
|
420
|
+
case FieldType.Integer:
|
|
421
|
+
case FieldType.Double:
|
|
422
|
+
return {
|
|
423
|
+
isValidValue: value.match(numberPattern),
|
|
424
|
+
typeExists: numberTypes.includes(type),
|
|
425
|
+
};
|
|
426
|
+
default:
|
|
427
|
+
return {
|
|
428
|
+
isValidValue: value.match(numberPattern),
|
|
429
|
+
typeExists: numberTypes.includes(type),
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
};
|
|
433
|
+
const isValidFilter = (type, value) => {
|
|
434
|
+
const { isValidValue, typeExists } = getTypeInformation(type, value);
|
|
435
|
+
return !(typeExists && !isValidValue);
|
|
436
|
+
};
|
|
437
|
+
const getProp = (obj, path) => {
|
|
438
|
+
return path.split('.').reduce((result, prop) => (result[prop] === undefined ? '' : result[prop]), obj);
|
|
439
|
+
};
|
|
440
|
+
const getLabelValueRequest = (contents, displayFields) => {
|
|
441
|
+
return contents.map((item) => (Object.assign(Object.assign({}, item), { label: displayFields.map((field) => getProp(item, field)).join(' - ') })));
|
|
442
|
+
};
|
|
443
|
+
const getSuggestionValue = (displayFields, ownerEntity, value, separator) => {
|
|
444
|
+
return displayFields.map((field) => getProp(value, `${ownerEntity}.${field}`)).reduce((acc, val) => `${acc}${separator}${val}`) + '';
|
|
445
|
+
};
|
|
446
|
+
const getEnumQuery = (name, value, multiple = false) => {
|
|
447
|
+
if (multiple) {
|
|
448
|
+
return `(${value.map((selected) => `${name} eq '${selected}'`).join(' or ')})`;
|
|
449
|
+
}
|
|
450
|
+
return `${name} eq '${value}'`;
|
|
451
|
+
};
|
|
452
|
+
const resolveRefs = (payload) => {
|
|
453
|
+
const getDataFromRef = (ref, rootObj) => {
|
|
454
|
+
const regex = /\["(.*?)"\]/g;
|
|
455
|
+
const result = [];
|
|
456
|
+
let match;
|
|
457
|
+
while ((match = regex.exec(ref)) !== null) {
|
|
458
|
+
result.push(match[1]);
|
|
459
|
+
}
|
|
460
|
+
return result.reduce((acc, part) => acc && acc[part], rootObj);
|
|
461
|
+
};
|
|
462
|
+
const resolve = (obj, rootObj) => {
|
|
463
|
+
if (Array.isArray(obj)) {
|
|
464
|
+
obj.forEach((item) => resolve(item, rootObj));
|
|
465
|
+
}
|
|
466
|
+
else if (obj !== null && typeof obj === 'object') {
|
|
467
|
+
// Remove self-reference to root object
|
|
468
|
+
Object.keys(obj).forEach((key) => {
|
|
469
|
+
if (obj[key] === rootObj) {
|
|
470
|
+
delete obj[key];
|
|
471
|
+
}
|
|
472
|
+
});
|
|
473
|
+
Object.keys(obj).forEach((key) => {
|
|
474
|
+
if (key === '$ref' && obj[key]) {
|
|
475
|
+
const refPath = obj[key];
|
|
476
|
+
Object.assign(obj, getDataFromRef(refPath, rootObj));
|
|
477
|
+
delete obj[key];
|
|
478
|
+
}
|
|
479
|
+
else {
|
|
480
|
+
resolve(obj[key], rootObj);
|
|
481
|
+
}
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
};
|
|
485
|
+
resolve(payload, payload);
|
|
486
|
+
return payload;
|
|
487
|
+
};
|
|
488
|
+
|
|
410
489
|
class User {
|
|
411
490
|
constructor() {
|
|
412
491
|
this.blocked = false;
|
|
@@ -415,7 +494,7 @@ class User {
|
|
|
415
494
|
const model = Object.assign({}, userDto);
|
|
416
495
|
const lookupSeparator = ' - ';
|
|
417
496
|
const displayFields = ['username', 'fullName'];
|
|
418
|
-
model.label = displayFields
|
|
497
|
+
model.label = getSuggestionValue(displayFields, 'user', { user: model }, lookupSeparator);
|
|
419
498
|
return model;
|
|
420
499
|
}
|
|
421
500
|
static toDto(user, originEntity) {
|
|
@@ -430,7 +509,7 @@ class E070Emp {
|
|
|
430
509
|
const model = Object.assign({}, e070EmpDto);
|
|
431
510
|
const lookupSeparator = ' - ';
|
|
432
511
|
const displayFields = ['codEmp', 'nomEmp'];
|
|
433
|
-
model.label = displayFields
|
|
512
|
+
model.label = getSuggestionValue(displayFields, 'e070Emp', { e070Emp: model }, lookupSeparator);
|
|
434
513
|
return model;
|
|
435
514
|
}
|
|
436
515
|
static toDto(e070Emp, originEntity) {
|
|
@@ -445,7 +524,7 @@ class E070Fil {
|
|
|
445
524
|
const model = Object.assign({}, e070FilDto);
|
|
446
525
|
const lookupSeparator = ' - ';
|
|
447
526
|
const displayFields = ['e070emp.codEmp', 'e070emp.nomEmp', 'codFil', 'nomFil'];
|
|
448
|
-
model.label = displayFields
|
|
527
|
+
model.label = getSuggestionValue(displayFields, 'e070Fil', { e070Fil: model }, lookupSeparator);
|
|
449
528
|
if (originEntity !== 'E070Emp' && model.e070emp) {
|
|
450
529
|
model.e070emp = E070Emp.fromDto(model.e070emp, 'E070Fil');
|
|
451
530
|
}
|
|
@@ -469,7 +548,7 @@ class E070FilCrmx {
|
|
|
469
548
|
const model = Object.assign({}, e070FilCrmxDto);
|
|
470
549
|
const lookupSeparator = ' - ';
|
|
471
550
|
const displayFields = ['e070fil.e070emp.codEmp', 'e070fil.e070emp.nomEmp', 'e070fil.codFil', 'e070fil.nomFil'];
|
|
472
|
-
model.label = displayFields
|
|
551
|
+
model.label = getSuggestionValue(displayFields, 'e070FilCrmx', { e070FilCrmx: model }, lookupSeparator);
|
|
473
552
|
if (originEntity !== 'E070Fil' && model.e070fil) {
|
|
474
553
|
model.e070fil = E070Fil.fromDto(model.e070fil, 'E070FilCrmx');
|
|
475
554
|
}
|
|
@@ -492,8 +571,13 @@ class CollaboratorE070FilCrmx {
|
|
|
492
571
|
static fromDto(collaboratorE070FilCrmxDto, originEntity) {
|
|
493
572
|
const model = Object.assign({}, collaboratorE070FilCrmxDto);
|
|
494
573
|
const lookupSeparator = ' - ';
|
|
495
|
-
const displayFields = [
|
|
496
|
-
|
|
574
|
+
const displayFields = [
|
|
575
|
+
'e070filCrmx.e070fil.e070emp.codEmp',
|
|
576
|
+
'e070filCrmx.e070fil.e070emp.nomEmp',
|
|
577
|
+
'e070filCrmx.e070fil.codFil',
|
|
578
|
+
'e070filCrmx.e070fil.nomFil'
|
|
579
|
+
];
|
|
580
|
+
model.label = getSuggestionValue(displayFields, 'collaboratorE070FilCrmx', { collaboratorE070FilCrmx: model }, lookupSeparator);
|
|
497
581
|
if (originEntity !== 'Collaborator' && model.collaborator) {
|
|
498
582
|
model.collaborator = Collaborator.fromDto(model.collaborator, 'CollaboratorE070FilCrmx');
|
|
499
583
|
}
|
|
@@ -520,7 +604,7 @@ class Squad {
|
|
|
520
604
|
const model = Object.assign({}, squadDto);
|
|
521
605
|
const lookupSeparator = ' - ';
|
|
522
606
|
const displayFields = ['name'];
|
|
523
|
-
model.label = displayFields
|
|
607
|
+
model.label = getSuggestionValue(displayFields, 'squad', { squad: model }, lookupSeparator);
|
|
524
608
|
return model;
|
|
525
609
|
}
|
|
526
610
|
static toDto(squad, originEntity) {
|
|
@@ -535,7 +619,7 @@ class CollaboratorSquad {
|
|
|
535
619
|
const model = Object.assign({}, collaboratorSquadDto);
|
|
536
620
|
const lookupSeparator = ' - ';
|
|
537
621
|
const displayFields = ['squad.name'];
|
|
538
|
-
model.label = displayFields
|
|
622
|
+
model.label = getSuggestionValue(displayFields, 'collaboratorSquad', { collaboratorSquad: model }, lookupSeparator);
|
|
539
623
|
if (originEntity !== 'Collaborator' && model.collaborator) {
|
|
540
624
|
model.collaborator = Collaborator.fromDto(model.collaborator, 'CollaboratorSquad');
|
|
541
625
|
}
|
|
@@ -566,7 +650,7 @@ class Collaborator {
|
|
|
566
650
|
const model = Object.assign({}, collaboratorDto);
|
|
567
651
|
const lookupSeparator = ' - ';
|
|
568
652
|
const displayFields = ['code', 'name'];
|
|
569
|
-
model.label = displayFields
|
|
653
|
+
model.label = getSuggestionValue(displayFields, 'collaborator', { collaborator: model }, lookupSeparator);
|
|
570
654
|
if (originEntity !== 'User' && model.user) {
|
|
571
655
|
model.user = User.fromDto(model.user, 'Collaborator');
|
|
572
656
|
}
|
|
@@ -574,7 +658,11 @@ class Collaborator {
|
|
|
574
658
|
model.leader = Collaborator.fromDto(model.leader, 'Collaborator');
|
|
575
659
|
}
|
|
576
660
|
if (originEntity !== 'CollaboratorE070FilCrmx' && model.branches) {
|
|
577
|
-
model.branches = Object.values(model.branches).map((item) =>
|
|
661
|
+
model.branches = Object.values(model.branches).map((item) => {
|
|
662
|
+
item = CollaboratorE070FilCrmx.fromDto(item, 'Collaborator');
|
|
663
|
+
item.collaborator = model;
|
|
664
|
+
return item;
|
|
665
|
+
});
|
|
578
666
|
}
|
|
579
667
|
if (originEntity !== 'CollaboratorSquad' && model.squads) {
|
|
580
668
|
model.squads = Object.values(model.squads).map((item) => CollaboratorSquad.fromDto(item, 'Collaborator'));
|
|
@@ -616,7 +704,7 @@ let StorageService = class StorageService {
|
|
|
616
704
|
}
|
|
617
705
|
store(key, value) {
|
|
618
706
|
const userId = this.getUserId();
|
|
619
|
-
localStorage.setItem(`${userId}_${key}`, JSON.stringify(value));
|
|
707
|
+
localStorage.setItem(`${userId}_${key}`, JSON.stringify(resolveRefs(value)));
|
|
620
708
|
}
|
|
621
709
|
get(key) {
|
|
622
710
|
const userId = this.getUserId();
|
|
@@ -704,7 +792,6 @@ let CurrentCollaboratorService = class CurrentCollaboratorService {
|
|
|
704
792
|
throw err;
|
|
705
793
|
}))
|
|
706
794
|
.subscribe((collaboratorDto) => {
|
|
707
|
-
collaboratorDto = this.removeCircularReferences(collaboratorDto);
|
|
708
795
|
this.storageService.store(this.COLLABORATOR_KEY, collaboratorDto);
|
|
709
796
|
observer.next(Collaborator.fromDto(collaboratorDto));
|
|
710
797
|
});
|
|
@@ -715,18 +802,6 @@ let CurrentCollaboratorService = class CurrentCollaboratorService {
|
|
|
715
802
|
redirect(page) {
|
|
716
803
|
location.href = `${this.storageService.getBaseUrl()}/gestao-relacionamento/crmx_collaborator/foundation/#/${page}`;
|
|
717
804
|
}
|
|
718
|
-
removeCircularReferences(obj) {
|
|
719
|
-
const seen = new WeakSet();
|
|
720
|
-
return JSON.parse(JSON.stringify(obj, (key, value) => {
|
|
721
|
-
if (typeof value === 'object') {
|
|
722
|
-
if (seen.has(value)) {
|
|
723
|
-
return undefined;
|
|
724
|
-
}
|
|
725
|
-
seen.add(value);
|
|
726
|
-
}
|
|
727
|
-
return value;
|
|
728
|
-
}));
|
|
729
|
-
}
|
|
730
805
|
};
|
|
731
806
|
CurrentCollaboratorService.ctorParameters = () => [
|
|
732
807
|
{ type: HttpClient },
|
|
@@ -757,7 +832,7 @@ CurrentCollaboratorModule = __decorate([
|
|
|
757
832
|
StorageModule,
|
|
758
833
|
],
|
|
759
834
|
providers: [
|
|
760
|
-
CurrentCollaboratorService
|
|
835
|
+
CurrentCollaboratorService,
|
|
761
836
|
],
|
|
762
837
|
})
|
|
763
838
|
], CurrentCollaboratorModule);
|
|
@@ -1271,5 +1346,5 @@ class ValueChangesService {
|
|
|
1271
1346
|
* Generated bundle index. Do not edit.
|
|
1272
1347
|
*/
|
|
1273
1348
|
|
|
1274
|
-
export { Collaborator, CollaboratorE070FilCrmx, CollaboratorSquad, CurrentCollaboratorModule, CurrentCollaboratorService, CurrentTenantModule, CurrentTenantService, DateValidatorsService, E070Emp, E070Fil, E070FilCrmx, Event, FormGroupValidatorsService, FormatEnum, Modulo, MonthEnum, OrdinalWeekDayEnum, RecurrenceEnum, RefreshWebsocketAlertComponent, RefreshWebsocketAlertModule, RepeatWhenEnum, ReportsComponent, ReportsModule, ReportsService, ScheduleFormRulesModule, ScheduleFormRulesService, Squad, StandardFiltersModule, StandardFiltersService, StorageService, StringConverterService, Topic, User, ValueChangesService, ViewModeEnum, WebsocketModule, WebsocketService, WeekDayEnum, fallback, StorageModule as ɵa };
|
|
1349
|
+
export { Collaborator, CollaboratorE070FilCrmx, CollaboratorSquad, CurrentCollaboratorModule, CurrentCollaboratorService, CurrentTenantModule, CurrentTenantService, DateValidatorsService, E070Emp, E070Fil, E070FilCrmx, Event, FormGroupValidatorsService, FormatEnum, Modulo, MonthEnum, OrdinalWeekDayEnum, RecurrenceEnum, RefreshWebsocketAlertComponent, RefreshWebsocketAlertModule, RepeatWhenEnum, ReportsComponent, ReportsModule, ReportsService, ScheduleFormRulesModule, ScheduleFormRulesService, Squad, StandardFiltersModule, StandardFiltersService, StorageService, StringConverterService, Topic, User, ValueChangesService, ViewModeEnum, WebsocketModule, WebsocketService, WeekDayEnum, fallback, getEnumQuery, getLabelValueRequest, getProp, getSuggestionValue, getTypeInformation, isValidFilter, mergeUnique, resolveRefs, StorageModule as ɵa };
|
|
1275
1350
|
//# sourceMappingURL=senior-gestao-relacionamento-angular-components.js.map
|