dts-backoffice-util 19.5.0 → 19.6.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/README.md CHANGED
@@ -12,9 +12,9 @@ Segue abaixo as últimas versões da Biblioteca, conforme a versão do PO-UI e A
12
12
 
13
13
  | PO-UI | Angular | Versão dtsBackofficeUtil |
14
14
  |-|-|-|
15
- | v19 | v19 | 19.5.0 |
15
+ | v19 | v19 | 19.6.1 |
16
16
  | v18 | v18 | 18.3.0 |
17
- | v17 | v17 | 17.1.0 |
17
+ | v17 | v17 | 17.2.0 |
18
18
  | v16 | v16 | 16.1.0 |
19
19
  | v15 | v15 | 15.4.1 |
20
20
  | v14 | v14 | 14.4.1 |
@@ -1,9 +1,9 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { Injectable, EventEmitter, Output, Input, ViewChild, Component, ViewChildren, Pipe, NgModule } from '@angular/core';
3
3
  import { of, forkJoin, map as map$1, lastValueFrom } from 'rxjs';
4
- import { map } from 'rxjs/operators';
5
4
  import * as i1 from '@angular/common/http';
6
5
  import { HttpErrorResponse, provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
6
+ import { map } from 'rxjs/operators';
7
7
  import * as i1$1 from '@po-ui/ng-components';
8
8
  import { PoModule } from '@po-ui/ng-components';
9
9
  import * as i3 from '@angular/common';
@@ -14,23 +14,15 @@ import { FormsModule } from '@angular/forms';
14
14
  class UserLoginService {
15
15
  constructor(http) {
16
16
  this.http = http;
17
- this.apiUrl = '/totvs-menu/rest/getSessionInfo';
18
- this.userLogin = undefined;
19
17
  }
20
18
  getUserLogin() {
19
+ if (sessionStorage.getItem('username')) {
20
+ return of(sessionStorage.getItem('username'));
21
+ }
21
22
  if (localStorage.getItem('username')) {
22
23
  return of(localStorage.getItem('username'));
23
24
  }
24
- if (this.userLogin) {
25
- return of(this.userLogin);
26
- }
27
- else {
28
- return this.http.get(`${this.apiUrl}`)
29
- .pipe(map((response) => {
30
- this.userLogin = response.userName;
31
- return response.userName;
32
- }));
33
- }
25
+ return of(undefined);
34
26
  }
35
27
  /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: UserLoginService, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
36
28
  /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: UserLoginService, providedIn: 'root' }); }
@@ -272,6 +264,15 @@ class MenuDatasulService {
272
264
  this.openHTMLProgram('THF1', externalName, params, parent);
273
265
  }
274
266
  openHTMLProgram(type, HTMLProgram, params, parent) {
267
+ const backendType = sessionStorage.getItem('totvs.product.backend.type');
268
+ if (backendType === 'DSS') {
269
+ this.openOnDSS(type, HTMLProgram, params, parent);
270
+ }
271
+ else {
272
+ this.openOnDTS4THF(type, HTMLProgram, params, parent);
273
+ }
274
+ }
275
+ openOnDTS4THF(type, HTMLProgram, params, parent) {
275
276
  const datasulPath = document.referrer.indexOf('totvs-menu') > 0 ? 'totvs-menu' : 'menu-html';
276
277
  HTMLProgram = HTMLProgram.replace(/\\/g, '/');
277
278
  if (HTMLProgram.charAt(0) === '/') {
@@ -291,8 +292,33 @@ class MenuDatasulService {
291
292
  if (baseUrl.charAt(baseUrl.length - 1) === '/') {
292
293
  baseUrl = baseUrl.slice(0, -1);
293
294
  }
294
- baseUrl = `${baseUrl}/#/${params}`;
295
+ if (type === 'THF2') {
296
+ baseUrl = `${baseUrl}/#`;
297
+ }
298
+ baseUrl = `${baseUrl}/${params}`;
295
299
  }
300
+ this.openWindow(baseUrl, parent);
301
+ }
302
+ openOnDSS(type, HTMLProgram, params, parent) {
303
+ let baseUrl = `${HTMLProgram}`;
304
+ if (params) {
305
+ baseUrl = `${baseUrl}/${params}`;
306
+ }
307
+ try {
308
+ if (window.top && typeof window.top.navigateSmartX === 'function') {
309
+ window.top.navigateSmartX(baseUrl);
310
+ }
311
+ else {
312
+ // Se falhar e precisar do window.open, a barra na frente e o smart-x
313
+ // são necessários para o navegador não emendar na URL atual do iframe
314
+ this.openWindow(`/smart-x/${baseUrl}`, parent);
315
+ }
316
+ }
317
+ catch (e) {
318
+ this.openWindow(`/smart-x/${baseUrl}`, parent);
319
+ }
320
+ }
321
+ openWindow(baseUrl, parent) {
296
322
  if (parent) {
297
323
  window.open(baseUrl, '_parent');
298
324
  }
@@ -319,7 +345,7 @@ class MenuDatasulService {
319
345
  }
320
346
  const aRequest = [];
321
347
  programList.forEach(programSearch => {
322
- aRequest.push(this.http.post(this.urlMenuPrograms, { search: programSearch }));
348
+ aRequest.push(this.http.post(this.urlMenuPrograms, this.getPayloadSearchProg(programSearch)));
323
349
  });
324
350
  return forkJoin(aRequest).pipe(map$1((response) => {
325
351
  if (!response) {
@@ -349,6 +375,9 @@ class MenuDatasulService {
349
375
  return responseReturn;
350
376
  }));
351
377
  }
378
+ getPayloadSearchProg(programSearch) {
379
+ return { 'codModul': null, 'search': programSearch, 'typeProg': '4,3,1,2', 'groupAplicat': [] };
380
+ }
352
381
  /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: MenuDatasulService, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
353
382
  /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: MenuDatasulService }); }
354
383
  }