dts-backoffice-util 21.1.0 → 21.2.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
- | v21 | v21 | 21.1.0 |
16
- | v20 | v20 | 20.1.0 |
17
- | v19 | v19 | 19.5.0 |
15
+ | v21 | v21 | 21.2.1 |
16
+ | v20 | v20 | 20.2.1 |
17
+ | v19 | v19 | 19.6.1 |
18
18
  | v18 | v18 | 18.3.0 |
19
19
  | v17 | v17 | 17.2.0 |
20
20
  | v16 | v16 | 16.1.0 |
@@ -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/forms';
@@ -13,23 +13,15 @@ import { CommonModule } from '@angular/common';
13
13
  class UserLoginService {
14
14
  constructor(http) {
15
15
  this.http = http;
16
- this.apiUrl = '/totvs-menu/rest/getSessionInfo';
17
- this.userLogin = undefined;
18
16
  }
19
17
  getUserLogin() {
18
+ if (sessionStorage.getItem('username')) {
19
+ return of(sessionStorage.getItem('username'));
20
+ }
20
21
  if (localStorage.getItem('username')) {
21
22
  return of(localStorage.getItem('username'));
22
23
  }
23
- if (this.userLogin) {
24
- return of(this.userLogin);
25
- }
26
- else {
27
- return this.http.get(`${this.apiUrl}`)
28
- .pipe(map((response) => {
29
- this.userLogin = response.userName;
30
- return response.userName;
31
- }));
32
- }
24
+ return of(undefined);
33
25
  }
34
26
  /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: UserLoginService, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
35
27
  /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: UserLoginService, providedIn: 'root' }); }
@@ -271,6 +263,15 @@ class MenuDatasulService {
271
263
  this.openHTMLProgram('THF1', externalName, params, parent);
272
264
  }
273
265
  openHTMLProgram(type, HTMLProgram, params, parent) {
266
+ const backendType = sessionStorage.getItem('totvs.product.backend.type');
267
+ if (backendType === 'DSS') {
268
+ this.openOnDSS(type, HTMLProgram, params, parent);
269
+ }
270
+ else {
271
+ this.openOnDTS4THF(type, HTMLProgram, params, parent);
272
+ }
273
+ }
274
+ openOnDTS4THF(type, HTMLProgram, params, parent) {
274
275
  const datasulPath = document.referrer.indexOf('totvs-menu') > 0 ? 'totvs-menu' : 'menu-html';
275
276
  HTMLProgram = HTMLProgram.replace(/\\/g, '/');
276
277
  if (HTMLProgram.charAt(0) === '/') {
@@ -290,8 +291,33 @@ class MenuDatasulService {
290
291
  if (baseUrl.charAt(baseUrl.length - 1) === '/') {
291
292
  baseUrl = baseUrl.slice(0, -1);
292
293
  }
293
- baseUrl = `${baseUrl}/#/${params}`;
294
+ if (type === 'THF2') {
295
+ baseUrl = `${baseUrl}/#`;
296
+ }
297
+ baseUrl = `${baseUrl}/${params}`;
294
298
  }
299
+ this.openWindow(baseUrl, parent);
300
+ }
301
+ openOnDSS(type, HTMLProgram, params, parent) {
302
+ let baseUrl = `${HTMLProgram}`;
303
+ if (params) {
304
+ baseUrl = `${baseUrl}/${params}`;
305
+ }
306
+ try {
307
+ if (window.top && typeof window.top.navigateSmartX === 'function') {
308
+ window.top.navigateSmartX(baseUrl);
309
+ }
310
+ else {
311
+ // Se falhar e precisar do window.open, a barra na frente e o smart-x
312
+ // são necessários para o navegador não emendar na URL atual do iframe
313
+ this.openWindow(`/smart-x/${baseUrl}`, parent);
314
+ }
315
+ }
316
+ catch (e) {
317
+ this.openWindow(`/smart-x/${baseUrl}`, parent);
318
+ }
319
+ }
320
+ openWindow(baseUrl, parent) {
295
321
  if (parent) {
296
322
  window.open(baseUrl, '_parent');
297
323
  }
@@ -318,7 +344,7 @@ class MenuDatasulService {
318
344
  }
319
345
  const aRequest = [];
320
346
  programList.forEach(programSearch => {
321
- aRequest.push(this.http.post(this.urlMenuPrograms, { search: programSearch }));
347
+ aRequest.push(this.http.post(this.urlMenuPrograms, this.getPayloadSearchProg(programSearch)));
322
348
  });
323
349
  return forkJoin(aRequest).pipe(map$1((response) => {
324
350
  if (!response) {
@@ -348,6 +374,9 @@ class MenuDatasulService {
348
374
  return responseReturn;
349
375
  }));
350
376
  }
377
+ getPayloadSearchProg(programSearch) {
378
+ return { 'codModul': null, 'search': programSearch, 'typeProg': '4,3,1,2', 'groupAplicat': [] };
379
+ }
351
380
  /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: MenuDatasulService, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
352
381
  /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: MenuDatasulService }); }
353
382
  }