appproject-components 1.0.45 → 1.0.47
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/karma.conf.js +44 -0
- package/ng-package.json +7 -0
- package/package.json +15 -26
- package/src/lib/appproject-components.component.spec.ts +23 -0
- package/src/lib/appproject-components.component.ts +20 -0
- package/src/lib/appproject-components.module.ts +106 -0
- package/src/lib/appproject-components.service.spec.ts +16 -0
- package/src/lib/appproject-components.service.ts +9 -0
- package/src/lib/baseComponent.scss +162 -0
- package/src/lib/baseInputComponent.ts +35 -0
- package/src/lib/buttons/baseBtnComponent.ts +38 -0
- package/src/lib/buttons/btn-action/btn-action.component.html +11 -0
- package/src/lib/buttons/btn-action/btn-action.component.scss +7 -0
- package/src/lib/buttons/btn-action/btn-action.component.spec.ts +24 -0
- package/src/lib/buttons/btn-action/btn-action.component.ts +31 -0
- package/src/lib/buttons/btn-cancelar/btn-cancelar.component.html +14 -0
- package/src/lib/buttons/btn-cancelar/btn-cancelar.component.scss +5 -0
- package/src/lib/buttons/btn-cancelar/btn-cancelar.component.spec.ts +24 -0
- package/src/lib/buttons/btn-cancelar/btn-cancelar.component.ts +19 -0
- package/src/lib/buttons/btn-excluir/btn-excluir.component.html +6 -0
- package/src/lib/buttons/btn-excluir/btn-excluir.component.scss +5 -0
- package/src/lib/buttons/btn-excluir/btn-excluir.component.spec.ts +24 -0
- package/src/lib/buttons/btn-excluir/btn-excluir.component.ts +18 -0
- package/src/lib/buttons/btn-novo/btn-novo.component.html +14 -0
- package/src/lib/buttons/btn-novo/btn-novo.component.scss +8 -0
- package/src/lib/buttons/btn-novo/btn-novo.component.spec.ts +24 -0
- package/src/lib/buttons/btn-novo/btn-novo.component.ts +20 -0
- package/src/lib/buttons/btn-salvar/btn-salvar.component.html +8 -0
- package/src/lib/buttons/btn-salvar/btn-salvar.component.scss +5 -0
- package/src/lib/buttons/btn-salvar/btn-salvar.component.spec.ts +24 -0
- package/src/lib/buttons/btn-salvar/btn-salvar.component.ts +16 -0
- package/src/lib/entity-edit/entity-edit.component.html +143 -0
- package/src/lib/entity-edit/entity-edit.component.scss +4 -0
- package/src/lib/entity-edit/entity-edit.component.spec.ts +23 -0
- package/src/lib/entity-edit/entity-edit.component.ts +43 -0
- package/src/lib/grid-view/grid-view.component.html +116 -0
- package/src/lib/grid-view/grid-view.component.scss +47 -0
- package/src/lib/grid-view/grid-view.component.spec.ts +23 -0
- package/src/lib/grid-view/grid-view.component.ts +292 -0
- package/src/lib/input-area/input-area.component.html +30 -0
- package/src/lib/input-area/input-area.component.scss +68 -0
- package/src/lib/input-area/input-area.component.spec.ts +23 -0
- package/src/lib/input-area/input-area.component.ts +69 -0
- package/src/lib/input-arquivo/input-arquivo.component.html +11 -0
- package/src/lib/input-arquivo/input-arquivo.component.scss +0 -0
- package/src/lib/input-arquivo/input-arquivo.component.spec.ts +23 -0
- package/src/lib/input-arquivo/input-arquivo.component.ts +140 -0
- package/src/lib/input-cep/input-cep.component.html +38 -0
- package/src/lib/input-cep/input-cep.component.scss +0 -0
- package/src/lib/input-cep/input-cep.component.spec.ts +23 -0
- package/src/lib/input-cep/input-cep.component.ts +186 -0
- package/src/lib/input-checkbox/input-checkbox.component.html +12 -0
- package/src/lib/input-checkbox/input-checkbox.component.scss +11 -0
- package/src/lib/input-checkbox/input-checkbox.component.spec.ts +23 -0
- package/src/lib/input-checkbox/input-checkbox.component.ts +48 -0
- package/src/lib/input-format/input-format.component.html +32 -0
- package/src/lib/input-format/input-format.component.scss +47 -0
- package/src/lib/input-format/input-format.component.spec.ts +23 -0
- package/src/lib/input-format/input-format.component.ts +139 -0
- package/src/lib/input-pesquisa/input-pesquisa.component.html +77 -0
- package/src/lib/input-pesquisa/input-pesquisa.component.scss +127 -0
- package/src/lib/input-pesquisa/input-pesquisa.component.spec.ts +23 -0
- package/src/lib/input-pesquisa/input-pesquisa.component.ts +558 -0
- package/src/lib/input-radio/input-radio.component.html +21 -0
- package/src/lib/input-radio/input-radio.component.scss +3 -0
- package/src/lib/input-radio/input-radio.component.spec.ts +23 -0
- package/src/lib/input-radio/input-radio.component.ts +49 -0
- package/src/lib/input-select/input-select.component.html +29 -0
- package/src/lib/input-select/input-select.component.scss +62 -0
- package/src/lib/input-select/input-select.component.spec.ts +23 -0
- package/src/lib/input-select/input-select.component.ts +96 -0
- package/src/lib/input-text/input-text.component.html +48 -0
- package/src/lib/input-text/input-text.component.scss +63 -0
- package/src/lib/input-text/input-text.component.spec.ts +23 -0
- package/src/lib/input-text/input-text.component.ts +78 -0
- package/src/lib/input-valor/input-valor.component.html +32 -0
- package/src/lib/input-valor/input-valor.component.scss +47 -0
- package/src/lib/input-valor/input-valor.component.spec.ts +23 -0
- package/src/lib/input-valor/input-valor.component.ts +164 -0
- package/{lib/lib-config.d.ts → src/lib/lib-config.ts} +4 -3
- package/src/lib/model-treeview/model-treeview.component.html +20 -0
- package/src/lib/model-treeview/model-treeview.component.scss +0 -0
- package/src/lib/model-treeview/model-treeview.component.spec.ts +23 -0
- package/src/lib/model-treeview/model-treeview.component.ts +152 -0
- package/src/lib/tree-view/tree-view.component.html +96 -0
- package/src/lib/tree-view/tree-view.component.scss +50 -0
- package/src/lib/tree-view/tree-view.component.spec.ts +23 -0
- package/src/lib/tree-view/tree-view.component.ts +92 -0
- package/src/lib/tree-view-nivel/tree-view-nivel.component.html +17 -0
- package/src/lib/tree-view-nivel/tree-view-nivel.component.scss +8 -0
- package/src/lib/tree-view-nivel/tree-view-nivel.component.spec.ts +23 -0
- package/src/lib/tree-view-nivel/tree-view-nivel.component.ts +43 -0
- package/{public-api.d.ts → src/public-api.ts} +30 -24
- package/src/test.ts +15 -0
- package/tsconfig.lib.json +15 -0
- package/tsconfig.lib.prod.json +10 -0
- package/tsconfig.spec.json +17 -0
- package/esm2022/appproject-components.mjs +0 -5
- package/esm2022/lib/appproject-components.component.mjs +0 -22
- package/esm2022/lib/appproject-components.module.mjs +0 -159
- package/esm2022/lib/appproject-components.service.mjs +0 -14
- package/esm2022/lib/baseInputComponent.mjs +0 -69
- package/esm2022/lib/buttons/baseBtnComponent.mjs +0 -63
- package/esm2022/lib/buttons/btn-action/btn-action.component.mjs +0 -55
- package/esm2022/lib/buttons/btn-cancelar/btn-cancelar.component.mjs +0 -25
- package/esm2022/lib/buttons/btn-excluir/btn-excluir.component.mjs +0 -29
- package/esm2022/lib/buttons/btn-novo/btn-novo.component.mjs +0 -33
- package/esm2022/lib/buttons/btn-salvar/btn-salvar.component.mjs +0 -19
- package/esm2022/lib/entity-edit/entity-edit.component.mjs +0 -53
- package/esm2022/lib/grid-view/grid-view.component.mjs +0 -275
- package/esm2022/lib/input-area/input-area.component.mjs +0 -72
- package/esm2022/lib/input-arquivo/input-arquivo.component.mjs +0 -154
- package/esm2022/lib/input-cep/input-cep.component.mjs +0 -180
- package/esm2022/lib/input-checkbox/input-checkbox.component.mjs +0 -51
- package/esm2022/lib/input-format/input-format.component.mjs +0 -138
- package/esm2022/lib/input-pesquisa/input-pesquisa.component.mjs +0 -557
- package/esm2022/lib/input-radio/input-radio.component.mjs +0 -58
- package/esm2022/lib/input-select/input-select.component.mjs +0 -110
- package/esm2022/lib/input-text/input-text.component.mjs +0 -88
- package/esm2022/lib/input-valor/input-valor.component.mjs +0 -161
- package/esm2022/lib/lib-config.mjs +0 -2
- package/esm2022/lib/model-treeview/model-treeview.component.mjs +0 -126
- package/esm2022/lib/tree-view/tree-view.component.mjs +0 -104
- package/esm2022/lib/tree-view-nivel/tree-view-nivel.component.mjs +0 -50
- package/esm2022/public-api.mjs +0 -30
- package/fesm2022/appproject-components.mjs +0 -2531
- package/fesm2022/appproject-components.mjs.map +0 -1
- package/index.d.ts +0 -5
- package/lib/appproject-components.component.d.ts +0 -8
- package/lib/appproject-components.module.d.ts +0 -36
- package/lib/appproject-components.service.d.ts +0 -6
- package/lib/baseInputComponent.d.ts +0 -28
- package/lib/buttons/baseBtnComponent.d.ts +0 -19
- package/lib/buttons/btn-action/btn-action.component.d.ts +0 -21
- package/lib/buttons/btn-cancelar/btn-cancelar.component.d.ts +0 -10
- package/lib/buttons/btn-excluir/btn-excluir.component.d.ts +0 -12
- package/lib/buttons/btn-novo/btn-novo.component.d.ts +0 -13
- package/lib/buttons/btn-salvar/btn-salvar.component.d.ts +0 -9
- package/lib/entity-edit/entity-edit.component.d.ts +0 -22
- package/lib/grid-view/grid-view.component.d.ts +0 -52
- package/lib/input-area/input-area.component.d.ts +0 -24
- package/lib/input-arquivo/input-arquivo.component.d.ts +0 -43
- package/lib/input-cep/input-cep.component.d.ts +0 -29
- package/lib/input-checkbox/input-checkbox.component.d.ts +0 -21
- package/lib/input-format/input-format.component.d.ts +0 -27
- package/lib/input-pesquisa/input-pesquisa.component.d.ts +0 -69
- package/lib/input-radio/input-radio.component.d.ts +0 -23
- package/lib/input-select/input-select.component.d.ts +0 -32
- package/lib/input-text/input-text.component.d.ts +0 -33
- package/lib/input-valor/input-valor.component.d.ts +0 -29
- package/lib/model-treeview/model-treeview.component.d.ts +0 -39
- package/lib/tree-view/tree-view.component.d.ts +0 -23
- package/lib/tree-view-nivel/tree-view-nivel.component.d.ts +0 -17
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/*
|
|
2
|
+
ion-label {
|
|
3
|
+
margin-bottom: 4px !important;
|
|
4
|
+
opacity: 1 !important;
|
|
5
|
+
}
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/*
|
|
9
|
+
ion-input {
|
|
10
|
+
padding: var(--input-padding, 4px);
|
|
11
|
+
border: 1px solid darkgray;
|
|
12
|
+
border-radius: 4px;
|
|
13
|
+
width: 100%;
|
|
14
|
+
margin-top: 2px;
|
|
15
|
+
max-height: 29px;
|
|
16
|
+
}
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/*
|
|
20
|
+
input:focus {
|
|
21
|
+
border: 1px solid lightblue !important;
|
|
22
|
+
ion-label{
|
|
23
|
+
--color: blue !important;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/*
|
|
29
|
+
.padding {
|
|
30
|
+
//inner-padding-end: auto; --padding-start: auto;
|
|
31
|
+
padding: auto;
|
|
32
|
+
|
|
33
|
+
}
|
|
34
|
+
*/
|
|
35
|
+
/*
|
|
36
|
+
.no-padding {
|
|
37
|
+
--inner-padding-end: 0px; --padding-start: 0px;
|
|
38
|
+
--padding-bottom: 0px;
|
|
39
|
+
--inner-padding-bottom: 0px;
|
|
40
|
+
height: 55px !important;
|
|
41
|
+
}
|
|
42
|
+
*/
|
|
43
|
+
|
|
44
|
+
/*
|
|
45
|
+
.no-padding-no-height {
|
|
46
|
+
--inner-padding-end: 0px; --padding-start: 0px;
|
|
47
|
+
--padding-bottom: 0px;
|
|
48
|
+
--inner-padding-bottom: 0px;
|
|
49
|
+
}
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
/*
|
|
53
|
+
.padding-top {
|
|
54
|
+
--padding-top: 0px;
|
|
55
|
+
}
|
|
56
|
+
*/
|
|
57
|
+
|
|
58
|
+
.pesquisa-select {
|
|
59
|
+
display:block;
|
|
60
|
+
position:absolute;
|
|
61
|
+
top: 58px;
|
|
62
|
+
left: 20px;
|
|
63
|
+
width: 100%;
|
|
64
|
+
z-index: 800;
|
|
65
|
+
font-size: 16px;
|
|
66
|
+
font-family: Roboto, "Helvetica Neue", sans-serif;
|
|
67
|
+
border-bottom-left-radius: 5px;
|
|
68
|
+
border-bottom-right-radius: 5px;
|
|
69
|
+
|
|
70
|
+
option {
|
|
71
|
+
overflow-y: hidden;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
option:hover, option:checked {
|
|
75
|
+
background-color: lightblue;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.pesquisa-list {
|
|
80
|
+
display:block;
|
|
81
|
+
|
|
82
|
+
//position:absolute;
|
|
83
|
+
//top: 58px;
|
|
84
|
+
//left: 20px;
|
|
85
|
+
|
|
86
|
+
position: absolute;
|
|
87
|
+
margin-left: 20px;
|
|
88
|
+
margin-top: -4px;
|
|
89
|
+
|
|
90
|
+
// width: 100%;
|
|
91
|
+
width: calc(100% - 50px);
|
|
92
|
+
z-index: 800;
|
|
93
|
+
//font-size: 16px;
|
|
94
|
+
//font-family: Roboto, "Helvetica Neue", sans-serif;
|
|
95
|
+
border: 1px lightgrey solid;
|
|
96
|
+
border-bottom-left-radius: 5px;
|
|
97
|
+
border-bottom-right-radius: 5px;
|
|
98
|
+
padding: 0px;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.pesquisa-item {
|
|
102
|
+
--inner-padding-top: 0px;
|
|
103
|
+
--inner-padding-bottom: 0px;
|
|
104
|
+
--padding-top: 0px;
|
|
105
|
+
--padding-bottom: 0px;
|
|
106
|
+
--min-height: 30px !important;
|
|
107
|
+
font-size: 12px;
|
|
108
|
+
button {
|
|
109
|
+
padding: 0px;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.selected-item {
|
|
114
|
+
background-color: lightblue;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.botao-limpar {
|
|
118
|
+
margin-top: var(--margin-botao-limpar, 25px);
|
|
119
|
+
margin-inline-start: 4px !important;
|
|
120
|
+
--padding-start:2px;
|
|
121
|
+
--padding-end: 2px;
|
|
122
|
+
margin-bottom: 2px !important;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
[hidden] {
|
|
126
|
+
display: none !important;
|
|
127
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { InputPesquisaComponent } from './input-pesquisa.component';
|
|
4
|
+
|
|
5
|
+
describe('InputPesquisaComponent', () => {
|
|
6
|
+
let component: InputPesquisaComponent;
|
|
7
|
+
let fixture: ComponentFixture<InputPesquisaComponent>;
|
|
8
|
+
|
|
9
|
+
beforeEach(async () => {
|
|
10
|
+
await TestBed.configureTestingModule({
|
|
11
|
+
declarations: [ InputPesquisaComponent ]
|
|
12
|
+
})
|
|
13
|
+
.compileComponents();
|
|
14
|
+
|
|
15
|
+
fixture = TestBed.createComponent(InputPesquisaComponent);
|
|
16
|
+
component = fixture.componentInstance;
|
|
17
|
+
fixture.detectChanges();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('should create', () => {
|
|
21
|
+
expect(component).toBeTruthy();
|
|
22
|
+
});
|
|
23
|
+
});
|
|
@@ -0,0 +1,558 @@
|
|
|
1
|
+
import { HttpClient } from '@angular/common/http';
|
|
2
|
+
import { Component, EventEmitter, Inject, Input, OnInit, Predicate, ViewChild } from '@angular/core';
|
|
3
|
+
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
4
|
+
import { IonSelect, ModalController } from '@ionic/angular';
|
|
5
|
+
import { Subject, Subscription, of } from 'rxjs';
|
|
6
|
+
import { BaseInputComponent } from '../baseInputComponent';
|
|
7
|
+
import { debounceTime, switchMap } from 'rxjs/operators'
|
|
8
|
+
import { ModelTreeviewComponent } from '../model-treeview/model-treeview.component';
|
|
9
|
+
import { LibConfig } from '../lib-config';
|
|
10
|
+
//import { LibConfig, LibConfigService } from '../appproject-components.module';
|
|
11
|
+
|
|
12
|
+
@Component({
|
|
13
|
+
selector: 'kb-input-pesquisa',
|
|
14
|
+
templateUrl: './input-pesquisa.component.html',
|
|
15
|
+
styleUrls: ['./input-pesquisa.component.scss', './../baseComponent.scss'],
|
|
16
|
+
providers: [{
|
|
17
|
+
provide: NG_VALUE_ACCESSOR,
|
|
18
|
+
useExisting: InputPesquisaComponent,
|
|
19
|
+
multi: true
|
|
20
|
+
}]
|
|
21
|
+
})
|
|
22
|
+
export class InputPesquisaComponent extends BaseInputComponent implements OnInit, ControlValueAccessor {
|
|
23
|
+
|
|
24
|
+
podePesquisar: boolean = true;
|
|
25
|
+
@Input() textoPesquisa: string = '';
|
|
26
|
+
selectElementVisivel: boolean = false;
|
|
27
|
+
listaPesquisa: any[] = [];
|
|
28
|
+
selectedItem: any;
|
|
29
|
+
@Input() override max: string = '30';
|
|
30
|
+
private pesquisaSubject: Subject<string> = new Subject();
|
|
31
|
+
|
|
32
|
+
@Input() filterFunction: Predicate<any> | null = null;
|
|
33
|
+
@Input() selectId: string = 'selectElement';
|
|
34
|
+
@Input() campoId: string = 'Id';
|
|
35
|
+
@Input() campoPaiId: string = 'PaiId';
|
|
36
|
+
@Input() campoDisplay: string = 'Descricao';
|
|
37
|
+
@Input() tipo: string = '';
|
|
38
|
+
//@ViewChild('selectElement', { read: ElementRef, static: true }) selectElement;
|
|
39
|
+
@ViewChild('selectElement', { static: false }) selectElement: IonSelect | null = null;
|
|
40
|
+
|
|
41
|
+
@Input() pesquisaChange = new EventEmitter();
|
|
42
|
+
@Input() pesquisaAction?: Function;
|
|
43
|
+
@Input() limpar?: Function;
|
|
44
|
+
//parametros para chamada API
|
|
45
|
+
//endpoint para pesquisa por digitação
|
|
46
|
+
@Input() url: string = '';
|
|
47
|
+
@Input() urlItem: string = '';
|
|
48
|
+
//endpoint para montar a arvore, se estiver vazia será usado o campo 'url'
|
|
49
|
+
@Input() urlTree: string = '';
|
|
50
|
+
@Input() empresa: number = 0;
|
|
51
|
+
@Input() loadInit: boolean = false;
|
|
52
|
+
@Input() treeTitulo: string;
|
|
53
|
+
|
|
54
|
+
//planoContas: number;
|
|
55
|
+
|
|
56
|
+
//control value acessor
|
|
57
|
+
public data: number | any;
|
|
58
|
+
private onChange: Function = (data: number) => { };
|
|
59
|
+
private onTouch: Function = () => { };
|
|
60
|
+
private disabled: boolean = false;
|
|
61
|
+
public console = console;
|
|
62
|
+
|
|
63
|
+
modelChanged: Subject<any> = new Subject<any>();
|
|
64
|
+
modelChangeSubscription?: Subscription;
|
|
65
|
+
|
|
66
|
+
writeValue(value: number | any): void {
|
|
67
|
+
//console.log('write value', value);
|
|
68
|
+
this.onChange(value);
|
|
69
|
+
this.data = value;
|
|
70
|
+
if (value == null || value == 0) {
|
|
71
|
+
this.writePesquisa('');
|
|
72
|
+
this.selectedItem = null;
|
|
73
|
+
} else {
|
|
74
|
+
if (this.loadInit == true) {
|
|
75
|
+
this.loadInit = false;
|
|
76
|
+
this.modelChanged.next(value);
|
|
77
|
+
//this.carregaItemIdParaLista(value);
|
|
78
|
+
} else {
|
|
79
|
+
//console.log(this.selectedItem);
|
|
80
|
+
if (!this.selectedItem || (this.selectedItem && this.selectedItem[this.campoId] != value)) {
|
|
81
|
+
console.log('Id diferente');
|
|
82
|
+
this.modelChanged.next(value);
|
|
83
|
+
//this.carregaItemIdParaLista(value);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
}
|
|
89
|
+
registerOnChange(fn: any): void {
|
|
90
|
+
this.onChange = fn;
|
|
91
|
+
}
|
|
92
|
+
registerOnTouched(fn: any): void {
|
|
93
|
+
this.onTouch = fn;
|
|
94
|
+
}
|
|
95
|
+
setDisabledState?(isDisabled: boolean): void {
|
|
96
|
+
this.disabled = this.disabled;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
BASE_API = this.config.apiUrl;
|
|
100
|
+
|
|
101
|
+
constructor(@Inject('LibConfigService') private config: LibConfig,
|
|
102
|
+
private httpClient: HttpClient,
|
|
103
|
+
private modalCtrl: ModalController) {
|
|
104
|
+
super();
|
|
105
|
+
|
|
106
|
+
this.modelChangeSubscription = this.modelChanged
|
|
107
|
+
.pipe(debounceTime(500)
|
|
108
|
+
)
|
|
109
|
+
.subscribe(data => {
|
|
110
|
+
this.carregaItemIdParaLista(data);
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
onBlur(event: any) {
|
|
115
|
+
console.log('blur', event);
|
|
116
|
+
//console.log(event.detail.relatedTarget);
|
|
117
|
+
if (event.detail.relatedTarget == null || event.detail.relatedTarget.id.indexOf(this.selectId + 'IonItem') == -1) {
|
|
118
|
+
//console.log("true", event.detail.relatedTarget.id);
|
|
119
|
+
//pesquisar item na lista
|
|
120
|
+
if (!this.existeNaListaTexto(this.textoPesquisa, true)) {
|
|
121
|
+
this.limparClick();
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
this.dropDownPesquisa(0);
|
|
125
|
+
if (this.form) {
|
|
126
|
+
this.form.get(this.formControlName)?.markAsTouched();
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
override ngOnInit() {
|
|
132
|
+
//tratar urls
|
|
133
|
+
this.url = this.url.startsWith('http') ? this.url : `${this.BASE_API}/${this.url}`;
|
|
134
|
+
this.urlItem = this.urlItem.startsWith('http') ? this.urlItem : `${this.BASE_API}/${this.urlItem}`;
|
|
135
|
+
|
|
136
|
+
this.pesquisaSubject.pipe(switchMap((url) => {
|
|
137
|
+
//this.console.log('subject url:', url);
|
|
138
|
+
if (!this.isEmpty(url)) {
|
|
139
|
+
return this.httpClient.get(url);
|
|
140
|
+
//return of(url);
|
|
141
|
+
}
|
|
142
|
+
else
|
|
143
|
+
return of([]);
|
|
144
|
+
}))
|
|
145
|
+
.subscribe({
|
|
146
|
+
next: (result: any) => {
|
|
147
|
+
//this.listaPesquisa = result;
|
|
148
|
+
this.console.log('subject subscribe result:', result);
|
|
149
|
+
this.listaPesquisa = [];
|
|
150
|
+
|
|
151
|
+
if (result && result.length > 0) {
|
|
152
|
+
if (this.filterFunction) {
|
|
153
|
+
result = result.filter(this.filterFunction);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
result.forEach((ent: any, index: any) => {
|
|
157
|
+
this.listaPesquisa.push({ ...ent, Index: index, Selected: false });
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
this.podePesquisar = true;
|
|
162
|
+
if (this.listaPesquisa.length > 0) {
|
|
163
|
+
this.dropDownPesquisa(this.listaPesquisa.length);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
, error: (error) => {
|
|
167
|
+
this.podePesquisar = true;
|
|
168
|
+
console.log('erro pesquisa', error);
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
writePesquisa(value: string | any): void {
|
|
174
|
+
//console.log('write pesquisa', value);
|
|
175
|
+
this.textoPesquisa = value;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
showPesquisa(e: any): void {
|
|
179
|
+
//console.log('show pesquisa', e.keyCode);
|
|
180
|
+
var self = this;
|
|
181
|
+
const index = e.target.selectionStart >= 1 ? (e.target.selectionStart - 1) : 0;
|
|
182
|
+
//console.log(index, 'valor ', event.target.value, 'char ', event.target.value.charCodeAt(index));
|
|
183
|
+
const keyAt = e.target.value.charCodeAt(index);
|
|
184
|
+
/*
|
|
185
|
+
if ((e.keyCode >= 48 && e.keyCode <= 57) ||
|
|
186
|
+
(keyAt >= 48 && keyAt <= 57) ||
|
|
187
|
+
(e.keyCode >= 65 && e.keyCode <= 90) ||
|
|
188
|
+
(e.keyCode >= 96 && e.keyCode <= 105) ||
|
|
189
|
+
(e.keyCode == 8)) {
|
|
190
|
+
*/
|
|
191
|
+
if (e.keyCode != 40 && e.keyCode != 38) {
|
|
192
|
+
if (!self.podePesquisar) {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
let filtro = self.textoPesquisa;
|
|
196
|
+
if (filtro != null && filtro != '' && filtro.length >= 2) {
|
|
197
|
+
self.pesquisarEntidade(filtro);
|
|
198
|
+
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
if (e.keyCode == 8 && !filtro) {
|
|
202
|
+
this.limparClick();
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
else {
|
|
208
|
+
if (e.keyCode == 40 || e.keyCode == 38) {
|
|
209
|
+
self.dropDownPesquisa(self.listaPesquisa.length);
|
|
210
|
+
if (self.selectElementVisivel == true) {
|
|
211
|
+
//let select = self.selectElement; //document.getElementById(self.TemplateSelect1Id());
|
|
212
|
+
|
|
213
|
+
//ion-list
|
|
214
|
+
//selecionado
|
|
215
|
+
//console.log(self.listaPesquisa);
|
|
216
|
+
let inc = e.keyCode == 40 ? 1 : -1;
|
|
217
|
+
let selected = self.listaPesquisa.find(s => s['Selected'] === true);
|
|
218
|
+
let cur = 0;
|
|
219
|
+
if (selected != null) {
|
|
220
|
+
cur = selected['Index'];
|
|
221
|
+
//desmarcar o atual
|
|
222
|
+
selected['Selected'] = false;
|
|
223
|
+
cur = cur + inc;
|
|
224
|
+
} else {
|
|
225
|
+
cur = 0;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
if (cur < 0) {
|
|
229
|
+
cur = self.listaPesquisa.length - 1;
|
|
230
|
+
} else if (cur >= self.listaPesquisa.length) {
|
|
231
|
+
cur = 0;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
let novoSelected = self.listaPesquisa.find(n => n['Index'] === cur);
|
|
235
|
+
if (novoSelected != null) {
|
|
236
|
+
novoSelected['Selected'] = true;
|
|
237
|
+
self.selectedItem = novoSelected;
|
|
238
|
+
self.textoPesquisa = novoSelected[self.campoDisplay];
|
|
239
|
+
}
|
|
240
|
+
/*
|
|
241
|
+
let select = document.getElementById(this.selectId) as any;
|
|
242
|
+
console.log('select Element', select)
|
|
243
|
+
if (select != null) {
|
|
244
|
+
let inc = e.keyCode == 40 ? 1 : -1;
|
|
245
|
+
let cur = select.selectedIndex;
|
|
246
|
+
if (cur == NaN) cur = -1;
|
|
247
|
+
select.selectedIndex = cur + inc;
|
|
248
|
+
if (select.selectedIndex >= 0 && select.selectedIndex < self.listaPesquisa.length) {
|
|
249
|
+
self.selectedItem = self.listaPesquisa[select.selectedIndex];
|
|
250
|
+
if (self.selectedItem != null) {
|
|
251
|
+
self.textoPesquisa = self.selectedItem[self.campoDisplay];
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
*/
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
} else
|
|
259
|
+
if (e.keyCode == 13) {
|
|
260
|
+
console.log('enter key', e)
|
|
261
|
+
//self.selecionarComboClick(e);
|
|
262
|
+
self.selecionarComboClick(null);
|
|
263
|
+
//return false;
|
|
264
|
+
} else if (e.keyCode == 27) {
|
|
265
|
+
//ESC
|
|
266
|
+
self.dropDownPesquisa(0);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
highlight(texto: string): string {
|
|
273
|
+
let index = texto.toLowerCase().indexOf(this.textoPesquisa.toLowerCase());
|
|
274
|
+
//console.log(index);
|
|
275
|
+
if (index >= 0) {
|
|
276
|
+
return texto.substring(0, index) + '<strong>' + texto.substring(index, index + this.textoPesquisa.length) + '</strong>' + texto.substring(index + this.textoPesquisa.length); //texto.replace(this.textoPesquisa, `<strong>${this.textoPesquisa}</strong>`);
|
|
277
|
+
} else {
|
|
278
|
+
return texto;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
selecionarComboClick(item: any) {
|
|
283
|
+
// console.log(item);
|
|
284
|
+
var self = this;
|
|
285
|
+
// console.log('combo click', self);
|
|
286
|
+
|
|
287
|
+
/*
|
|
288
|
+
let select = document.getElementById(this.selectId) as any;
|
|
289
|
+
if (select.selectedIndex >= 0) {
|
|
290
|
+
self.selectedItem = self.listaPesquisa[select.selectedIndex];
|
|
291
|
+
}
|
|
292
|
+
console.log('selected', this.selectedItem);
|
|
293
|
+
//self.selectedItem = this.listaPesquisa.find(i => i[this.campoId] == e);
|
|
294
|
+
if (self.selectedItem != null) {
|
|
295
|
+
self.textoPesquisa = self.selectedItem[self.campoDisplay];
|
|
296
|
+
self.writeValue(self.selectedItem[self.campoId]);
|
|
297
|
+
if (e != null) {
|
|
298
|
+
self.selectElementVisivel = false;
|
|
299
|
+
if (self.action != null) {
|
|
300
|
+
self.action(self.selectedItem(), e);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
else {
|
|
305
|
+
self.selectElementVisivel = false;
|
|
306
|
+
}
|
|
307
|
+
*/
|
|
308
|
+
// pesquisar selecionado
|
|
309
|
+
// console.log(this.listaPesquisa);
|
|
310
|
+
let selected = this.listaPesquisa.find(s => s['Selected'] === true);
|
|
311
|
+
|
|
312
|
+
// if (!selected) {
|
|
313
|
+
// console.log(this.campoId, item);
|
|
314
|
+
// selected = this.listaPesquisa.filter( s => s[this.campoId] == item[this.campoId]);
|
|
315
|
+
// }
|
|
316
|
+
|
|
317
|
+
//se o item form passado como parametro (click no ion-item)
|
|
318
|
+
if (item != null) {
|
|
319
|
+
if (selected != null) {
|
|
320
|
+
selected['Selected'] = false;
|
|
321
|
+
}
|
|
322
|
+
item['Selected'] = true;
|
|
323
|
+
selected = item;
|
|
324
|
+
}
|
|
325
|
+
if (selected != null) {
|
|
326
|
+
self.selectedItem = selected;
|
|
327
|
+
self.textoPesquisa = selected[self.campoDisplay];
|
|
328
|
+
self.writeValue(selected[self.campoId]);
|
|
329
|
+
self.selectElementVisivel = false;
|
|
330
|
+
//console.log('action', self.change);
|
|
331
|
+
if (self.pesquisaChange != null) {
|
|
332
|
+
self.pesquisaChange.emit(self.selectedItem);
|
|
333
|
+
}
|
|
334
|
+
} else {
|
|
335
|
+
self.selectElementVisivel = false;
|
|
336
|
+
}
|
|
337
|
+
// this.listaPesquisa.forEach( pesquisa => {
|
|
338
|
+
// console.log(pesquisa, self.data);
|
|
339
|
+
// } );
|
|
340
|
+
// console.log(this.textoPesquisa);
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
selecionarComboChange(e: any) {
|
|
344
|
+
var self = this;
|
|
345
|
+
console.log('combo change', e);
|
|
346
|
+
self.selectedItem = this.listaPesquisa.find(i => i[this.campoId] == e);
|
|
347
|
+
if (self.selectedItem != null) {
|
|
348
|
+
self.writeValue(e);
|
|
349
|
+
self.textoPesquisa = self.selectedItem[self.campoDisplay];
|
|
350
|
+
if (e != null) {
|
|
351
|
+
self.selectElementVisivel = false;
|
|
352
|
+
if (self.pesquisaChange != null) {
|
|
353
|
+
self.pesquisaChange.emit(self.selectedItem);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
else {
|
|
358
|
+
self.selectElementVisivel = false;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
dropDownPesquisa(length: number) {
|
|
363
|
+
var self = this;
|
|
364
|
+
if (self.listaPesquisa != null && self.listaPesquisa.length > 0) {
|
|
365
|
+
if (length == -1) {
|
|
366
|
+
length = self.listaPesquisa.length;
|
|
367
|
+
}
|
|
368
|
+
self.selectElementVisivel = length == 0 ? false : true;
|
|
369
|
+
|
|
370
|
+
//console.log(this.selectElement);
|
|
371
|
+
//this.selectElement.open();
|
|
372
|
+
|
|
373
|
+
/*
|
|
374
|
+
//let element = this.selectElement;
|
|
375
|
+
let element = document.getElementById(this.selectId);
|
|
376
|
+
console.log('dropDown', element);
|
|
377
|
+
(element as any).size = length + 1;
|
|
378
|
+
if (length == 0) {
|
|
379
|
+
self.selectElementVisivel = false;
|
|
380
|
+
} else {
|
|
381
|
+
self.selectElementVisivel = true;
|
|
382
|
+
}
|
|
383
|
+
*/
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
pesquisarEntidade(filtro: string) {
|
|
388
|
+
let url = this.url.replace('<<FILTRO>>', filtro).replace('<<EMPRESA>>', this.empresa.toString());
|
|
389
|
+
console.log('pesquisarEntidade url', url);
|
|
390
|
+
this.podePesquisar = false;
|
|
391
|
+
this.pesquisaSubject.next(url);
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
pesquisarEntidadeOld(filtro: string) {
|
|
395
|
+
let url = this.url.replace('<<FILTRO>>', filtro).replace('<<EMPRESA>>', this.empresa.toString());
|
|
396
|
+
console.log('pesquisarEntidade url', url);
|
|
397
|
+
this.podePesquisar = false;
|
|
398
|
+
this.httpClient.get<any>(url)
|
|
399
|
+
.subscribe({ next: (result: any) => {
|
|
400
|
+
//this.listaPesquisa = result;
|
|
401
|
+
if (this.filterFunction) {
|
|
402
|
+
result = result.filter(this.filterFunction);
|
|
403
|
+
}
|
|
404
|
+
this.listaPesquisa = [];
|
|
405
|
+
result.forEach((ent: any, index: number) => {
|
|
406
|
+
this.listaPesquisa.push({ ...ent, Index: index, Selected: false });
|
|
407
|
+
});
|
|
408
|
+
|
|
409
|
+
this.podePesquisar = true;
|
|
410
|
+
if (this.listaPesquisa.length > 0) {
|
|
411
|
+
this.dropDownPesquisa(this.listaPesquisa.length);
|
|
412
|
+
}
|
|
413
|
+
}, error: error => {
|
|
414
|
+
console.log('erro pesquisa', error);
|
|
415
|
+
this.podePesquisar = true;
|
|
416
|
+
}});
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
existeNaLista(id: number, setRegistro: boolean = false): boolean {
|
|
420
|
+
if (this.listaPesquisa && this.listaPesquisa.length > 0) {
|
|
421
|
+
let existe = this.listaPesquisa.find(l => l[this.campoId] === id);
|
|
422
|
+
if (existe) {
|
|
423
|
+
if (setRegistro) {
|
|
424
|
+
this.selectedItem = existe;
|
|
425
|
+
this.selecionarComboClick(this.selectedItem);
|
|
426
|
+
}
|
|
427
|
+
return true;
|
|
428
|
+
} else {
|
|
429
|
+
return false;
|
|
430
|
+
}
|
|
431
|
+
} else {
|
|
432
|
+
return false;
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
existeNaListaTexto(texto: string, setRegistro: boolean = false): boolean {
|
|
437
|
+
console.log("existe texto:", texto, this.campoDisplay, this.listaPesquisa);
|
|
438
|
+
if (this.listaPesquisa && this.listaPesquisa.length > 0) {
|
|
439
|
+
let existe = this.listaPesquisa.find(l => l[this.campoDisplay].toUpperCase() === texto.toUpperCase());
|
|
440
|
+
if (existe) {
|
|
441
|
+
if (setRegistro) {
|
|
442
|
+
this.selectedItem = existe;
|
|
443
|
+
this.selecionarComboClick(this.selectedItem);
|
|
444
|
+
}
|
|
445
|
+
return true;
|
|
446
|
+
} else {
|
|
447
|
+
return false;
|
|
448
|
+
}
|
|
449
|
+
} else {
|
|
450
|
+
return false;
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
validarItemSelecionado(setarRegistro: boolean = false): boolean {
|
|
455
|
+
console.log('validar selecionado');
|
|
456
|
+
//passar pela função de filtro
|
|
457
|
+
let valido = false;
|
|
458
|
+
if (this.selectedItem) {
|
|
459
|
+
if (this.filterFunction) {
|
|
460
|
+
let existe = [{ ...this.selectedItem }].filter(this.filterFunction);
|
|
461
|
+
if (existe != null && existe.length > 0) {
|
|
462
|
+
valido = true;
|
|
463
|
+
}
|
|
464
|
+
} else {
|
|
465
|
+
valido = true;
|
|
466
|
+
}
|
|
467
|
+
if (valido && setarRegistro) {
|
|
468
|
+
this.selecionarComboClick(this.selectedItem);
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
return valido;
|
|
472
|
+
} else {
|
|
473
|
+
return false;
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
carregaItemIdParaLista(id: number) {
|
|
478
|
+
let url = this.urlItem.replace('<<ID>>', id.toString());
|
|
479
|
+
console.log(this.urlItem);
|
|
480
|
+
console.log('pesquisar ID url', url);
|
|
481
|
+
this.podePesquisar = false;
|
|
482
|
+
this.httpClient.get<any>(url)
|
|
483
|
+
.subscribe({ next: (result: any) => {
|
|
484
|
+
this.listaPesquisa = [];
|
|
485
|
+
this.listaPesquisa.push({ ...result, Index: 0, Selected: true });
|
|
486
|
+
this.podePesquisar = true;
|
|
487
|
+
if (this.listaPesquisa.length > 0) {
|
|
488
|
+
this.selectedItem = this.listaPesquisa[0];
|
|
489
|
+
this.selecionarComboClick(this.selectedItem);
|
|
490
|
+
}
|
|
491
|
+
}, error: error => {
|
|
492
|
+
console.log('erro pesquisa', error);
|
|
493
|
+
this.podePesquisar = true;
|
|
494
|
+
}});
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
limparClick() {
|
|
498
|
+
this.writeValue(null);
|
|
499
|
+
this.writePesquisa(null);
|
|
500
|
+
this.listaPesquisa = [];
|
|
501
|
+
this.dropDownPesquisa(0);
|
|
502
|
+
//this.podePesquisar = true;
|
|
503
|
+
this.pesquisaSubject.next('');
|
|
504
|
+
if (this.limpar) {
|
|
505
|
+
this.limpar();
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
verificarPesquisa() {
|
|
510
|
+
//TODO: verificar se o texto corresponde com um item da lista
|
|
511
|
+
this.selecionarComboClick(null);
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
async pesquisarClick() {
|
|
515
|
+
/*
|
|
516
|
+
if (this.pesquisaAction != null) {
|
|
517
|
+
this.pesquisaAction();
|
|
518
|
+
}
|
|
519
|
+
*/
|
|
520
|
+
//pesquisaCategoria
|
|
521
|
+
console.log(this.filterFunction, this.url, this.urlTree);
|
|
522
|
+
|
|
523
|
+
const modal = await this.modalCtrl.create({
|
|
524
|
+
component: ModelTreeviewComponent,
|
|
525
|
+
componentProps: {
|
|
526
|
+
//campoId: this.campoId,
|
|
527
|
+
//campoPai: this.campoPaiId,
|
|
528
|
+
//campoLabel: this.campoDisplay,
|
|
529
|
+
textoPesquisa: this.textoPesquisa,
|
|
530
|
+
filterFunction: this.filterFunction,
|
|
531
|
+
empresaSelecionadaId: this.empresa,
|
|
532
|
+
tipo: this.tipo,
|
|
533
|
+
//especifico
|
|
534
|
+
//planoContas: this.planoContas,
|
|
535
|
+
url: this.isEmpty(this.urlTree) ? this.url : this.urlTree,
|
|
536
|
+
titulo: this.treeTitulo,
|
|
537
|
+
campoLabel: this.campoDisplay,
|
|
538
|
+
campoId: this.campoId,
|
|
539
|
+
campoPai: this.campoPaiId
|
|
540
|
+
},
|
|
541
|
+
cssClass: 'my-custom-modal-pesquisa'
|
|
542
|
+
});
|
|
543
|
+
|
|
544
|
+
modal.onDidDismiss().then(data => {
|
|
545
|
+
let result = data['data'];
|
|
546
|
+
console.log(result);
|
|
547
|
+
if (result != null && result.Id > 0) {
|
|
548
|
+
this.carregaItemIdParaLista(result.Id);
|
|
549
|
+
}
|
|
550
|
+
});
|
|
551
|
+
modal.present();
|
|
552
|
+
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
isEmpty(valor: string | any) {
|
|
556
|
+
return valor == null || valor == undefined || valor == ''
|
|
557
|
+
}
|
|
558
|
+
}
|