@senior-gestao-relacionamento/angular-components 1.1.0 → 1.2.0
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 +407 -4
- 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/public-api.js +4 -1
- package/esm2015/services/current-collaborator/current-collaborator.module.js +18 -0
- package/esm2015/services/current-collaborator/current-collaborator.service.js +73 -0
- package/esm2015/services/current-collaborator/index.js +4 -0
- package/esm2015/services/current-collaborator/models/branch-dto.js +1 -0
- package/esm2015/services/current-collaborator/models/branch.js +26 -0
- package/esm2015/services/current-collaborator/models/collaborator-branch-dto.js +1 -0
- package/esm2015/services/current-collaborator/models/collaborator-branch.js +37 -0
- package/esm2015/services/current-collaborator/models/collaborator-dto.js +1 -0
- package/esm2015/services/current-collaborator/models/collaborator-squad-dto.js +1 -0
- package/esm2015/services/current-collaborator/models/collaborator-squad.js +34 -0
- package/esm2015/services/current-collaborator/models/collaborator.js +55 -0
- package/esm2015/services/current-collaborator/models/company-dto.js +1 -0
- package/esm2015/services/current-collaborator/models/company.js +18 -0
- package/esm2015/services/current-collaborator/models/index.js +7 -0
- package/esm2015/services/current-collaborator/models/squad-dto.js +1 -0
- package/esm2015/services/current-collaborator/models/squad.js +20 -0
- package/esm2015/services/current-collaborator/models/user-dto.js +1 -0
- package/esm2015/services/current-collaborator/models/user.js +18 -0
- package/esm2015/services/storage/storage.service.js +21 -1
- package/esm2015/services/utils/index.js +2 -0
- package/esm2015/services/utils/string-converter.service.js +7 -0
- package/esm2015/services/validators/date-validators.service.js +9 -0
- package/esm2015/services/validators/form-group-validators.service.js +36 -0
- package/esm2015/services/validators/index.js +3 -0
- package/esm5/public-api.js +4 -1
- package/esm5/services/current-collaborator/current-collaborator.module.js +21 -0
- package/esm5/services/current-collaborator/current-collaborator.service.js +76 -0
- package/esm5/services/current-collaborator/index.js +4 -0
- package/esm5/services/current-collaborator/models/branch-dto.js +1 -0
- package/esm5/services/current-collaborator/models/branch.js +29 -0
- package/esm5/services/current-collaborator/models/collaborator-branch-dto.js +1 -0
- package/esm5/services/current-collaborator/models/collaborator-branch.js +40 -0
- package/esm5/services/current-collaborator/models/collaborator-dto.js +1 -0
- package/esm5/services/current-collaborator/models/collaborator-squad-dto.js +1 -0
- package/esm5/services/current-collaborator/models/collaborator-squad.js +39 -0
- package/esm5/services/current-collaborator/models/collaborator.js +58 -0
- package/esm5/services/current-collaborator/models/company-dto.js +1 -0
- package/esm5/services/current-collaborator/models/company.js +21 -0
- package/esm5/services/current-collaborator/models/index.js +7 -0
- package/esm5/services/current-collaborator/models/squad-dto.js +1 -0
- package/esm5/services/current-collaborator/models/squad.js +25 -0
- package/esm5/services/current-collaborator/models/user-dto.js +1 -0
- package/esm5/services/current-collaborator/models/user.js +21 -0
- package/esm5/services/storage/storage.service.js +43 -1
- package/esm5/services/utils/index.js +2 -0
- package/esm5/services/utils/string-converter.service.js +11 -0
- package/esm5/services/validators/date-validators.service.js +13 -0
- package/esm5/services/validators/form-group-validators.service.js +40 -0
- package/esm5/services/validators/index.js +3 -0
- package/fesm2015/senior-gestao-relacionamento-angular-components.js +352 -4
- package/fesm2015/senior-gestao-relacionamento-angular-components.js.map +1 -1
- package/fesm5/senior-gestao-relacionamento-angular-components.js +400 -4
- package/fesm5/senior-gestao-relacionamento-angular-components.js.map +1 -1
- package/package.json +46 -1
- package/public-api.d.ts +3 -0
- package/senior-gestao-relacionamento-angular-components.metadata.json +1 -1
- package/services/current-collaborator/current-collaborator.module.d.ts +2 -0
- package/services/current-collaborator/current-collaborator.service.d.ts +14 -0
- package/services/current-collaborator/index.d.ts +3 -0
- package/services/current-collaborator/models/branch-dto.d.ts +8 -0
- package/services/current-collaborator/models/branch.d.ts +12 -0
- package/services/current-collaborator/models/collaborator-branch-dto.d.ts +11 -0
- package/services/current-collaborator/models/collaborator-branch.d.ts +16 -0
- package/services/current-collaborator/models/collaborator-dto.d.ts +18 -0
- package/services/current-collaborator/models/collaborator-squad-dto.d.ts +10 -0
- package/services/current-collaborator/models/collaborator-squad.d.ts +15 -0
- package/services/current-collaborator/models/collaborator.d.ts +24 -0
- package/services/current-collaborator/models/company-dto.d.ts +6 -0
- package/services/current-collaborator/models/company.d.ts +9 -0
- package/services/current-collaborator/models/index.d.ts +12 -0
- package/services/current-collaborator/models/squad-dto.d.ts +9 -0
- package/services/current-collaborator/models/squad.d.ts +12 -0
- package/services/current-collaborator/models/user-dto.d.ts +9 -0
- package/services/current-collaborator/models/user.d.ts +12 -0
- package/services/storage/storage.service.d.ts +3 -0
- package/services/utils/index.d.ts +1 -0
- package/services/utils/string-converter.service.d.ts +3 -0
- package/services/validators/date-validators.service.d.ts +3 -0
- package/services/validators/form-group-validators.service.d.ts +5 -0
- package/services/validators/index.d.ts +2 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('js-cookie'), require('@angular/core'), require('rxjs'), require('@stomp/stompjs'), require('sockjs-client')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define('@senior-gestao-relacionamento/angular-components', ['exports', 'js-cookie', '@angular/core', 'rxjs', '@stomp/stompjs', 'sockjs-client'], factory) :
|
|
4
|
-
(global = global || self, factory((global['senior-gestao-relacionamento'] = global['senior-gestao-relacionamento'] || {}, global['senior-gestao-relacionamento']['angular-components'] = {}), global.jsCookie, global.ng.core, global.rxjs, global.stompjs, global.SockJS));
|
|
5
|
-
}(this, (function (exports, jsCookie, core, rxjs, stompjs, SockJS) { 'use strict';
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('js-cookie'), require('@seniorsistemas/senior-platform-data'), require('@angular/core'), require('rxjs'), require('@stomp/stompjs'), require('sockjs-client'), require('moment'), require('@angular/common/http'), require('rxjs/operators')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define('@senior-gestao-relacionamento/angular-components', ['exports', 'js-cookie', '@seniorsistemas/senior-platform-data', '@angular/core', 'rxjs', '@stomp/stompjs', 'sockjs-client', 'moment', '@angular/common/http', 'rxjs/operators'], factory) :
|
|
4
|
+
(global = global || self, factory((global['senior-gestao-relacionamento'] = global['senior-gestao-relacionamento'] || {}, global['senior-gestao-relacionamento']['angular-components'] = {}), global.jsCookie, global.seniorPlatformData, global.ng.core, global.rxjs, global.stompjs, global.SockJS, global.moment, global.ng.common.http, global.rxjs.operators));
|
|
5
|
+
}(this, (function (exports, jsCookie, seniorPlatformData, core, rxjs, stompjs, SockJS, moment, http, operators) { 'use strict';
|
|
6
6
|
|
|
7
7
|
/*! *****************************************************************************
|
|
8
8
|
Copyright (c) Microsoft Corporation.
|
|
@@ -226,6 +226,46 @@
|
|
|
226
226
|
var StorageService = /** @class */ (function () {
|
|
227
227
|
function StorageService() {
|
|
228
228
|
}
|
|
229
|
+
StorageService.getUserId = function () {
|
|
230
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
231
|
+
var user$1;
|
|
232
|
+
return __generator(this, function (_a) {
|
|
233
|
+
switch (_a.label) {
|
|
234
|
+
case 0: return [4 /*yield*/, seniorPlatformData.user.getUserData()];
|
|
235
|
+
case 1:
|
|
236
|
+
user$1 = _a.sent();
|
|
237
|
+
return [2 /*return*/, user$1.id];
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
});
|
|
241
|
+
};
|
|
242
|
+
StorageService.store = function (key, value) {
|
|
243
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
244
|
+
var userId;
|
|
245
|
+
return __generator(this, function (_a) {
|
|
246
|
+
switch (_a.label) {
|
|
247
|
+
case 0: return [4 /*yield*/, this.getUserId()];
|
|
248
|
+
case 1:
|
|
249
|
+
userId = _a.sent();
|
|
250
|
+
localStorage.setItem(userId + "_" + key, JSON.stringify(value));
|
|
251
|
+
return [2 /*return*/];
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
});
|
|
255
|
+
};
|
|
256
|
+
StorageService.get = function (key) {
|
|
257
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
258
|
+
var userId;
|
|
259
|
+
return __generator(this, function (_a) {
|
|
260
|
+
switch (_a.label) {
|
|
261
|
+
case 0: return [4 /*yield*/, this.getUserId()];
|
|
262
|
+
case 1:
|
|
263
|
+
userId = _a.sent();
|
|
264
|
+
return [2 /*return*/, JSON.parse(localStorage.getItem(userId + "_" + key)) || {}];
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
});
|
|
268
|
+
};
|
|
229
269
|
StorageService.getComSeniorToken = function () {
|
|
230
270
|
return JSON.parse(jsCookie.get('com.senior.token'));
|
|
231
271
|
};
|
|
@@ -250,6 +290,67 @@
|
|
|
250
290
|
return StorageService;
|
|
251
291
|
}());
|
|
252
292
|
|
|
293
|
+
var StringConverterService = /** @class */ (function () {
|
|
294
|
+
function StringConverterService() {
|
|
295
|
+
}
|
|
296
|
+
StringConverterService.toUnderscore = function (camelCase) {
|
|
297
|
+
var regex = /([a-z])([A-Z])/g;
|
|
298
|
+
return camelCase.replace(regex, '$1_$2').toLowerCase();
|
|
299
|
+
};
|
|
300
|
+
return StringConverterService;
|
|
301
|
+
}());
|
|
302
|
+
|
|
303
|
+
var FormGroupValidatorsService = /** @class */ (function () {
|
|
304
|
+
function FormGroupValidatorsService() {
|
|
305
|
+
}
|
|
306
|
+
FormGroupValidatorsService.startDataGreaterThanEndDataValidator = function (endDateField, errorMessage) {
|
|
307
|
+
var fn = function (control) {
|
|
308
|
+
var _a;
|
|
309
|
+
if (control.parent) {
|
|
310
|
+
var startDate = new Date(control.value);
|
|
311
|
+
var endDate = new Date((_a = control.parent.controls[endDateField]) === null || _a === void 0 ? void 0 : _a.value);
|
|
312
|
+
if (startDate > endDate) {
|
|
313
|
+
var rtn = {};
|
|
314
|
+
rtn[errorMessage] = true;
|
|
315
|
+
return rtn;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
return null;
|
|
319
|
+
};
|
|
320
|
+
return fn;
|
|
321
|
+
};
|
|
322
|
+
FormGroupValidatorsService.endDateLessThanStartDateValidator = function (startDateField, errorMessage) {
|
|
323
|
+
var fn = function (control) {
|
|
324
|
+
var _a;
|
|
325
|
+
if (control.parent) {
|
|
326
|
+
var startDate = new Date((_a = control.parent.controls[startDateField]) === null || _a === void 0 ? void 0 : _a.value);
|
|
327
|
+
var endDate = new Date(control.value);
|
|
328
|
+
if (startDate > endDate) {
|
|
329
|
+
var rtn = {};
|
|
330
|
+
rtn[errorMessage] = true;
|
|
331
|
+
return rtn;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
return null;
|
|
335
|
+
};
|
|
336
|
+
return fn;
|
|
337
|
+
};
|
|
338
|
+
;
|
|
339
|
+
return FormGroupValidatorsService;
|
|
340
|
+
}());
|
|
341
|
+
|
|
342
|
+
var DateValidatorsService = /** @class */ (function () {
|
|
343
|
+
function DateValidatorsService() {
|
|
344
|
+
}
|
|
345
|
+
DateValidatorsService.isLastWeekdayOfMonth = function (date) {
|
|
346
|
+
var newDate = new Date(date);
|
|
347
|
+
var day = 7;
|
|
348
|
+
newDate.setDate(date.getDate() + day);
|
|
349
|
+
return newDate.getMonth() > date.getMonth() || newDate.getFullYear() > date.getFullYear();
|
|
350
|
+
};
|
|
351
|
+
return DateValidatorsService;
|
|
352
|
+
}());
|
|
353
|
+
|
|
253
354
|
var WebsocketService = /** @class */ (function () {
|
|
254
355
|
function WebsocketService() {
|
|
255
356
|
this.primitiveEventObservables = [];
|
|
@@ -317,7 +418,309 @@
|
|
|
317
418
|
return WebsocketService;
|
|
318
419
|
}());
|
|
319
420
|
|
|
421
|
+
var Company = /** @class */ (function () {
|
|
422
|
+
function Company() {
|
|
423
|
+
this.active = false;
|
|
424
|
+
}
|
|
425
|
+
Company.fromDto = function (companyDto, originEntity) {
|
|
426
|
+
var model = __assign({}, companyDto);
|
|
427
|
+
var lookupSeparator = ' - ';
|
|
428
|
+
var displayFields = ['code', 'name'];
|
|
429
|
+
model.label = displayFields.map(function (field) { return model[field]; }).join(lookupSeparator);
|
|
430
|
+
return model;
|
|
431
|
+
};
|
|
432
|
+
Company.toDto = function (company, originEntity) {
|
|
433
|
+
var dto = __assign({}, company);
|
|
434
|
+
delete dto.label;
|
|
435
|
+
return dto;
|
|
436
|
+
};
|
|
437
|
+
return Company;
|
|
438
|
+
}());
|
|
439
|
+
|
|
440
|
+
var Branch = /** @class */ (function () {
|
|
441
|
+
function Branch() {
|
|
442
|
+
this.master = false;
|
|
443
|
+
this.active = false;
|
|
444
|
+
}
|
|
445
|
+
Branch.fromDto = function (branchDto, originEntity) {
|
|
446
|
+
var model = __assign({}, branchDto);
|
|
447
|
+
var lookupSeparator = ' - ';
|
|
448
|
+
var displayFields = ['company.code', 'company.name', 'code', 'name'];
|
|
449
|
+
model.label = displayFields.map(function (field) { return model[field]; }).join(lookupSeparator);
|
|
450
|
+
if (originEntity !== 'Company' && model.company) {
|
|
451
|
+
model.company = Company.fromDto(model.company, 'Branch');
|
|
452
|
+
}
|
|
453
|
+
return model;
|
|
454
|
+
};
|
|
455
|
+
Branch.toDto = function (branch, originEntity) {
|
|
456
|
+
var dto = __assign({}, branch);
|
|
457
|
+
delete dto.label;
|
|
458
|
+
if (originEntity !== 'Company' && dto.company) {
|
|
459
|
+
dto.company = Company.toDto(dto.company, 'Branch');
|
|
460
|
+
}
|
|
461
|
+
return dto;
|
|
462
|
+
};
|
|
463
|
+
return Branch;
|
|
464
|
+
}());
|
|
465
|
+
|
|
466
|
+
var User = /** @class */ (function () {
|
|
467
|
+
function User() {
|
|
468
|
+
this.blocked = false;
|
|
469
|
+
}
|
|
470
|
+
User.fromDto = function (userDto, originEntity) {
|
|
471
|
+
var model = __assign({}, userDto);
|
|
472
|
+
var lookupSeparator = ' - ';
|
|
473
|
+
var displayFields = ['username', 'fullName'];
|
|
474
|
+
model.label = displayFields.map(function (field) { return model[field]; }).join(lookupSeparator);
|
|
475
|
+
return model;
|
|
476
|
+
};
|
|
477
|
+
User.toDto = function (user, originEntity) {
|
|
478
|
+
var dto = __assign({}, user);
|
|
479
|
+
delete dto.label;
|
|
480
|
+
return dto;
|
|
481
|
+
};
|
|
482
|
+
return User;
|
|
483
|
+
}());
|
|
484
|
+
|
|
485
|
+
var CollaboratorBranch = /** @class */ (function () {
|
|
486
|
+
function CollaboratorBranch() {
|
|
487
|
+
this.master = false;
|
|
488
|
+
}
|
|
489
|
+
CollaboratorBranch.fromDto = function (collaboratorBranchDto, originEntity) {
|
|
490
|
+
var model = __assign({}, collaboratorBranchDto);
|
|
491
|
+
model.createdAt = model.createdAt && moment(model.createdAt).toDate();
|
|
492
|
+
model.changedAt = model.changedAt && moment(model.changedAt).toDate();
|
|
493
|
+
var lookupSeparator = ' - ';
|
|
494
|
+
var displayFields = ['branch.company.code', 'branch.company.name', 'branch.code', 'branch.name', 'master'];
|
|
495
|
+
model.label = displayFields.map(function (field) { return model[field]; }).join(lookupSeparator);
|
|
496
|
+
if (originEntity !== 'Collaborator' && model.collaborator) {
|
|
497
|
+
model.collaborator = Collaborator.fromDto(model.collaborator, 'CollaboratorBranch');
|
|
498
|
+
}
|
|
499
|
+
if (originEntity !== 'Branch' && model.branch) {
|
|
500
|
+
model.branch = Branch.fromDto(model.branch, 'CollaboratorBranch');
|
|
501
|
+
}
|
|
502
|
+
return model;
|
|
503
|
+
};
|
|
504
|
+
CollaboratorBranch.toDto = function (collaboratorBranch, originEntity) {
|
|
505
|
+
var dto = __assign({}, collaboratorBranch);
|
|
506
|
+
dto.createdAt = dto.createdAt && moment(dto.createdAt).format();
|
|
507
|
+
dto.changedAt = dto.changedAt && moment(dto.changedAt).format();
|
|
508
|
+
delete dto.label;
|
|
509
|
+
if (originEntity !== 'Collaborator' && dto.collaborator) {
|
|
510
|
+
dto.collaborator = Collaborator.toDto(dto.collaborator, 'CollaboratorBranch');
|
|
511
|
+
}
|
|
512
|
+
if (originEntity !== 'Branch' && dto.branch) {
|
|
513
|
+
dto.branch = Branch.toDto(dto.branch, 'CollaboratorBranch');
|
|
514
|
+
}
|
|
515
|
+
return dto;
|
|
516
|
+
};
|
|
517
|
+
return CollaboratorBranch;
|
|
518
|
+
}());
|
|
519
|
+
|
|
520
|
+
var Squad = /** @class */ (function () {
|
|
521
|
+
function Squad() {
|
|
522
|
+
}
|
|
523
|
+
Squad.fromDto = function (squadDto, originEntity) {
|
|
524
|
+
var model = __assign({}, squadDto);
|
|
525
|
+
model.createdAt = model.createdAt && moment(model.createdAt).toDate();
|
|
526
|
+
model.changedAt = model.changedAt && moment(model.changedAt).toDate();
|
|
527
|
+
var lookupSeparator = ' - ';
|
|
528
|
+
var displayFields = ['name'];
|
|
529
|
+
model.label = displayFields.map(function (field) { return model[field]; }).join(lookupSeparator);
|
|
530
|
+
return model;
|
|
531
|
+
};
|
|
532
|
+
Squad.toDto = function (squad, originEntity) {
|
|
533
|
+
var dto = __assign({}, squad);
|
|
534
|
+
dto.createdAt = dto.createdAt && moment(dto.createdAt).format();
|
|
535
|
+
dto.changedAt = dto.changedAt && moment(dto.changedAt).format();
|
|
536
|
+
delete dto.label;
|
|
537
|
+
return dto;
|
|
538
|
+
};
|
|
539
|
+
return Squad;
|
|
540
|
+
}());
|
|
541
|
+
|
|
542
|
+
var CollaboratorSquad = /** @class */ (function () {
|
|
543
|
+
function CollaboratorSquad() {
|
|
544
|
+
}
|
|
545
|
+
CollaboratorSquad.fromDto = function (collaboratorSquadDto, originEntity) {
|
|
546
|
+
var model = __assign({}, collaboratorSquadDto);
|
|
547
|
+
model.createdAt = model.createdAt && moment(model.createdAt).toDate();
|
|
548
|
+
model.changedAt = model.changedAt && moment(model.changedAt).toDate();
|
|
549
|
+
var lookupSeparator = ' - ';
|
|
550
|
+
var displayFields = ['squad.name'];
|
|
551
|
+
model.label = displayFields.map(function (field) { return model[field]; }).join(lookupSeparator);
|
|
552
|
+
if (originEntity !== 'Collaborator' && model.collaborator) {
|
|
553
|
+
model.collaborator = Collaborator.fromDto(model.collaborator, 'CollaboratorSquad');
|
|
554
|
+
}
|
|
555
|
+
if (originEntity !== 'Squad' && model.squad) {
|
|
556
|
+
model.squad = Squad.fromDto(model.squad, 'CollaboratorSquad');
|
|
557
|
+
}
|
|
558
|
+
return model;
|
|
559
|
+
};
|
|
560
|
+
CollaboratorSquad.toDto = function (collaboratorSquad, originEntity) {
|
|
561
|
+
var dto = __assign({}, collaboratorSquad);
|
|
562
|
+
dto.createdAt = dto.createdAt && moment(dto.createdAt).format();
|
|
563
|
+
dto.changedAt = dto.changedAt && moment(dto.changedAt).format();
|
|
564
|
+
delete dto.label;
|
|
565
|
+
if (originEntity !== 'Collaborator' && dto.collaborator) {
|
|
566
|
+
dto.collaborator = Collaborator.toDto(dto.collaborator, 'CollaboratorSquad');
|
|
567
|
+
}
|
|
568
|
+
if (originEntity !== 'Squad' && dto.squad) {
|
|
569
|
+
dto.squad = Squad.toDto(dto.squad, 'CollaboratorSquad');
|
|
570
|
+
}
|
|
571
|
+
return dto;
|
|
572
|
+
};
|
|
573
|
+
return CollaboratorSquad;
|
|
574
|
+
}());
|
|
575
|
+
|
|
576
|
+
var Collaborator = /** @class */ (function () {
|
|
577
|
+
function Collaborator() {
|
|
578
|
+
this.active = false;
|
|
579
|
+
this.visible = false;
|
|
580
|
+
}
|
|
581
|
+
Collaborator.fromDto = function (collaboratorDto, originEntity) {
|
|
582
|
+
var model = __assign({}, collaboratorDto);
|
|
583
|
+
model.createdAt = model.createdAt && moment(model.createdAt).toDate();
|
|
584
|
+
model.changedAt = model.changedAt && moment(model.changedAt).toDate();
|
|
585
|
+
var lookupSeparator = ' - ';
|
|
586
|
+
var displayFields = ['code', 'name'];
|
|
587
|
+
model.label = displayFields.map(function (field) { return model[field]; }).join(lookupSeparator);
|
|
588
|
+
if (originEntity !== 'User' && model.user) {
|
|
589
|
+
model.user = User.fromDto(model.user, 'Collaborator');
|
|
590
|
+
}
|
|
591
|
+
if (originEntity !== 'Collaborator' && model.leader) {
|
|
592
|
+
model.leader = Collaborator.fromDto(model.leader, 'Collaborator');
|
|
593
|
+
}
|
|
594
|
+
if (originEntity !== 'CollaboratorBranch' && model.branches) {
|
|
595
|
+
model.branches = Object.values(model.branches).map(function (item) { return CollaboratorBranch.fromDto(item, 'Collaborator'); });
|
|
596
|
+
}
|
|
597
|
+
if (originEntity !== 'CollaboratorSquad' && model.squads) {
|
|
598
|
+
model.squads = Object.values(model.squads).map(function (item) { return CollaboratorSquad.fromDto(item, 'Collaborator'); });
|
|
599
|
+
}
|
|
600
|
+
return model;
|
|
601
|
+
};
|
|
602
|
+
Collaborator.toDto = function (collaborator, originEntity) {
|
|
603
|
+
var dto = __assign({}, collaborator);
|
|
604
|
+
dto.createdAt = dto.createdAt && moment(dto.createdAt).format();
|
|
605
|
+
dto.changedAt = dto.changedAt && moment(dto.changedAt).format();
|
|
606
|
+
delete dto.label;
|
|
607
|
+
if (originEntity !== 'User' && dto.user) {
|
|
608
|
+
dto.user = User.toDto(dto.user, 'Collaborator');
|
|
609
|
+
}
|
|
610
|
+
if (originEntity !== 'Collaborator' && dto.leader) {
|
|
611
|
+
dto.leader = Collaborator.toDto(dto.leader, 'Collaborator');
|
|
612
|
+
}
|
|
613
|
+
if (originEntity !== 'CollaboratorBranch' && dto.branches) {
|
|
614
|
+
dto.branches = Object.values(dto.branches)
|
|
615
|
+
.map(function (item) { return CollaboratorBranch.toDto(item, 'Collaborator'); })
|
|
616
|
+
.filter(function (item) { return Object.keys(item).length; });
|
|
617
|
+
}
|
|
618
|
+
if (originEntity !== 'CollaboratorSquad' && dto.squads) {
|
|
619
|
+
dto.squads = Object.values(dto.squads)
|
|
620
|
+
.map(function (item) { return CollaboratorSquad.toDto(item, 'Collaborator'); })
|
|
621
|
+
.filter(function (item) { return Object.keys(item).length; });
|
|
622
|
+
}
|
|
623
|
+
return dto;
|
|
624
|
+
};
|
|
625
|
+
return Collaborator;
|
|
626
|
+
}());
|
|
627
|
+
|
|
628
|
+
var CurrentCollaboratorService = /** @class */ (function () {
|
|
629
|
+
function CurrentCollaboratorService(http) {
|
|
630
|
+
this.http = http;
|
|
631
|
+
this.ngUnsubscribe = new rxjs.Subject();
|
|
632
|
+
this.COLLABORATOR_KEY = 'CRMX_COLLABORATOR';
|
|
633
|
+
}
|
|
634
|
+
CurrentCollaboratorService.prototype.validate = function () {
|
|
635
|
+
var _this = this;
|
|
636
|
+
this.call(false).subscribe(function (collaborator) {
|
|
637
|
+
if (collaborator.active === false) {
|
|
638
|
+
_this.redirect('collaborator-inactive');
|
|
639
|
+
}
|
|
640
|
+
});
|
|
641
|
+
};
|
|
642
|
+
CurrentCollaboratorService.prototype.get = function () {
|
|
643
|
+
return this.call(true);
|
|
644
|
+
};
|
|
645
|
+
CurrentCollaboratorService.prototype.call = function (useCache) {
|
|
646
|
+
var _this = this;
|
|
647
|
+
return new rxjs.Observable(function (observer) {
|
|
648
|
+
StorageService.get(_this.COLLABORATOR_KEY).then(function (collaboratorDto) {
|
|
649
|
+
if (collaboratorDto.hasOwnProperty('id') && useCache) {
|
|
650
|
+
observer.next(Collaborator.fromDto(collaboratorDto));
|
|
651
|
+
}
|
|
652
|
+
else {
|
|
653
|
+
_this.http.get('crmx/collaborator/queries/getCurrentCollaborator')
|
|
654
|
+
.pipe(operators.takeUntil(_this.ngUnsubscribe), operators.catchError(function (err) {
|
|
655
|
+
if (err.status === 404) {
|
|
656
|
+
_this.redirect('collaborator-not-found');
|
|
657
|
+
}
|
|
658
|
+
;
|
|
659
|
+
throw err;
|
|
660
|
+
}))
|
|
661
|
+
.subscribe(function (collaboratorDto) {
|
|
662
|
+
StorageService.store(_this.COLLABORATOR_KEY, _this.removeCircularReferences(collaboratorDto));
|
|
663
|
+
observer.next(Collaborator.fromDto(collaboratorDto));
|
|
664
|
+
});
|
|
665
|
+
}
|
|
666
|
+
});
|
|
667
|
+
});
|
|
668
|
+
};
|
|
669
|
+
CurrentCollaboratorService.prototype.redirect = function (page) {
|
|
670
|
+
if (!location.hostname.includes('interno.senior.com.br')) {
|
|
671
|
+
location.href = location.origin + '/gestao-relacionamento/crmx/collaborator/#/' + page;
|
|
672
|
+
}
|
|
673
|
+
};
|
|
674
|
+
CurrentCollaboratorService.prototype.removeCircularReferences = function (obj) {
|
|
675
|
+
var seen = new WeakSet();
|
|
676
|
+
return JSON.parse(JSON.stringify(obj, function (key, value) {
|
|
677
|
+
var rtn;
|
|
678
|
+
if (typeof value === 'object' && value !== null) {
|
|
679
|
+
if (!seen.has(value)) {
|
|
680
|
+
seen.add(value);
|
|
681
|
+
rtn = value;
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
return rtn;
|
|
685
|
+
}));
|
|
686
|
+
};
|
|
687
|
+
CurrentCollaboratorService.ctorParameters = function () { return [
|
|
688
|
+
{ type: http.HttpClient }
|
|
689
|
+
]; };
|
|
690
|
+
CurrentCollaboratorService = __decorate([
|
|
691
|
+
core.Injectable()
|
|
692
|
+
], CurrentCollaboratorService);
|
|
693
|
+
return CurrentCollaboratorService;
|
|
694
|
+
}());
|
|
695
|
+
|
|
696
|
+
var CurrentCollaboratorModule = /** @class */ (function () {
|
|
697
|
+
function CurrentCollaboratorModule() {
|
|
698
|
+
}
|
|
699
|
+
CurrentCollaboratorModule = __decorate([
|
|
700
|
+
core.NgModule({
|
|
701
|
+
imports: [
|
|
702
|
+
http.HttpClientModule,
|
|
703
|
+
],
|
|
704
|
+
providers: [
|
|
705
|
+
CurrentCollaboratorService
|
|
706
|
+
],
|
|
707
|
+
})
|
|
708
|
+
], CurrentCollaboratorModule);
|
|
709
|
+
return CurrentCollaboratorModule;
|
|
710
|
+
}());
|
|
711
|
+
|
|
712
|
+
exports.Branch = Branch;
|
|
713
|
+
exports.Collaborator = Collaborator;
|
|
714
|
+
exports.CollaboratorBranch = CollaboratorBranch;
|
|
715
|
+
exports.Company = Company;
|
|
716
|
+
exports.CurrentCollaboratorModule = CurrentCollaboratorModule;
|
|
717
|
+
exports.CurrentCollaboratorService = CurrentCollaboratorService;
|
|
718
|
+
exports.DateValidatorsService = DateValidatorsService;
|
|
719
|
+
exports.FormGroupValidatorsService = FormGroupValidatorsService;
|
|
720
|
+
exports.Squad = Squad;
|
|
320
721
|
exports.StorageService = StorageService;
|
|
722
|
+
exports.StringConverterService = StringConverterService;
|
|
723
|
+
exports.User = User;
|
|
321
724
|
exports.WebsocketService = WebsocketService;
|
|
322
725
|
|
|
323
726
|
Object.defineProperty(exports, '__esModule', { value: true });
|