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,164 @@
|
|
|
1
|
+
import { Component, ElementRef, Input, OnInit, ViewChild } from '@angular/core';
|
|
2
|
+
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
3
|
+
import { BaseInputComponent } from '../baseInputComponent';
|
|
4
|
+
|
|
5
|
+
@Component({
|
|
6
|
+
selector: 'kb-input-valor',
|
|
7
|
+
templateUrl: './input-valor.component.html',
|
|
8
|
+
styleUrls: ['./input-valor.component.scss', './../baseComponent.scss'],
|
|
9
|
+
providers: [{
|
|
10
|
+
provide: NG_VALUE_ACCESSOR,
|
|
11
|
+
useExisting: InputValorComponent,
|
|
12
|
+
multi: true
|
|
13
|
+
}]
|
|
14
|
+
})
|
|
15
|
+
export class InputValorComponent extends BaseInputComponent implements OnInit, ControlValueAccessor {
|
|
16
|
+
@Input() maxValor: number = null;
|
|
17
|
+
@ViewChild('inputValor', { read: ElementRef, static: true}) inputValorEdit;
|
|
18
|
+
//control value acessor
|
|
19
|
+
public data: string | any;
|
|
20
|
+
private onChange: Function = (data: string) => { };
|
|
21
|
+
private onTouch: Function = () => { };
|
|
22
|
+
private disabled: boolean = false;
|
|
23
|
+
public console = console;
|
|
24
|
+
|
|
25
|
+
writeValue(value: string | any): void {
|
|
26
|
+
//console.log('write value', value);
|
|
27
|
+
this.onChange(value);
|
|
28
|
+
this.data = value;
|
|
29
|
+
}
|
|
30
|
+
registerOnChange(fn: any): void {
|
|
31
|
+
this.onChange = fn;
|
|
32
|
+
}
|
|
33
|
+
registerOnTouched(fn: any): void {
|
|
34
|
+
this.onTouch = fn;
|
|
35
|
+
}
|
|
36
|
+
setDisabledState?(isDisabled: boolean): void {
|
|
37
|
+
this.disabled = this.disabled;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
constructor() {
|
|
41
|
+
super();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
override ngOnInit() { }
|
|
45
|
+
|
|
46
|
+
onBlur() {
|
|
47
|
+
if (this.form) {
|
|
48
|
+
this.form.get(this.formControlName)?.markAsTouched();
|
|
49
|
+
}
|
|
50
|
+
//verificar o valor
|
|
51
|
+
if (this.maxValor) {
|
|
52
|
+
if (this.form) {
|
|
53
|
+
//console.log(this.form.get(this.formControlName).value);
|
|
54
|
+
let valor = this.strToFloatZero(this.form.get(this.formControlName).value);
|
|
55
|
+
if (valor > this.maxValor) {
|
|
56
|
+
this.form.patchValue({
|
|
57
|
+
[this.formControlName]: this.converterValorDecimalMil((this.maxValor * 100).toString())
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
} else {
|
|
61
|
+
let valor = this.strToFloatZero(this.data);
|
|
62
|
+
if (valor > this.maxValor) {
|
|
63
|
+
this.data = this.converterValorDecimalMil((this.maxValor * 100).toString());
|
|
64
|
+
this.writeValue(this.data);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (this.blur) {
|
|
69
|
+
this.blur.emit(this.blurArgs);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
digitarValor(event: any) {
|
|
74
|
+
//this.item.vendaunitario = this.utils.converterValorDecimal(this.item.vendaunitario);
|
|
75
|
+
setTimeout(() => {
|
|
76
|
+
if (this.form) {
|
|
77
|
+
this.form.patchValue({
|
|
78
|
+
[this.formControlName]: this.converterValorDecimalMil(this.form.get(this.formControlName)?.value)
|
|
79
|
+
});
|
|
80
|
+
} else {
|
|
81
|
+
this.data = this.converterValorDecimalMil(this.data);
|
|
82
|
+
this.writeValue(this.data);
|
|
83
|
+
}
|
|
84
|
+
}, 100);
|
|
85
|
+
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
isEmpty(str: string | any): boolean {
|
|
90
|
+
return str == null || str == undefined || str == '';
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
converterValorDecimalMil(campo: string, casas: number = 2): string {
|
|
94
|
+
if (!this.isEmpty(campo)) {
|
|
95
|
+
//console.log('converterValorDecimal');
|
|
96
|
+
//console.log('campo:', campo, ' replaced: ', campo.replace(',', '').replace('.', ''));
|
|
97
|
+
if (campo == '-') {
|
|
98
|
+
return campo;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
let valor = parseFloat(campo.replace(',', '').replace('.', '').replace('.', '').replace('.', ''));
|
|
102
|
+
|
|
103
|
+
if (isNaN(valor)) {
|
|
104
|
+
return '';
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
let valordiv = parseInt("1" + this.stringOfChar("0", casas));
|
|
108
|
+
//valor /= 100;
|
|
109
|
+
console.log(valor, '/', valordiv);
|
|
110
|
+
valor /= valordiv;
|
|
111
|
+
console.log('=', valor);
|
|
112
|
+
return this.decimalToStringMil(valor);
|
|
113
|
+
/*
|
|
114
|
+
var str = valor.toString().replace('.', ',');
|
|
115
|
+
var aStr = str.split(',');
|
|
116
|
+
if (aStr.length == 1) {
|
|
117
|
+
//str += ',00';
|
|
118
|
+
str += ',' + this.stringOfChar('0', casas);
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
//str += this.stringOfChar('0', 2 - aStr[1].length);
|
|
122
|
+
str += this.stringOfChar('0', casas - aStr[1].length);
|
|
123
|
+
}
|
|
124
|
+
return str;
|
|
125
|
+
*/
|
|
126
|
+
}
|
|
127
|
+
else
|
|
128
|
+
return campo;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
decimalToStringMil(number?: any) {
|
|
132
|
+
if (number != null) {
|
|
133
|
+
if (number == 0 || number == '0') {
|
|
134
|
+
return '0,00';
|
|
135
|
+
}
|
|
136
|
+
//console.log(number);
|
|
137
|
+
let numero = number.toFixed(2).split('.');
|
|
138
|
+
numero[0] = numero[0].split(/(?=(?:...)*$)/).join('.');
|
|
139
|
+
return numero.join(',').replace('-.', '-');
|
|
140
|
+
} else
|
|
141
|
+
return '';
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
stringOfChar(str: string, tam: number): string {
|
|
145
|
+
var res = '';
|
|
146
|
+
for (var i = 0; i < tam; i++) {
|
|
147
|
+
res += str;
|
|
148
|
+
}
|
|
149
|
+
return res;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
strToFloatZero(str): number {
|
|
153
|
+
if (Number.isFinite(str))
|
|
154
|
+
return str;
|
|
155
|
+
if (this.isEmpty(str))
|
|
156
|
+
return 0;
|
|
157
|
+
else
|
|
158
|
+
return parseFloat(str.replace('.', '').replace(',', '.'));
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
setFocus() {
|
|
162
|
+
this.inputValorEdit.nativeElement.setFocus();
|
|
163
|
+
}
|
|
164
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export interface LibConfig {
|
|
2
|
-
apiUrl: string;
|
|
3
|
-
}
|
|
1
|
+
export interface LibConfig {
|
|
2
|
+
apiUrl: string;
|
|
3
|
+
}
|
|
4
|
+
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<ion-header>
|
|
2
|
+
<ion-toolbar color="secondary">
|
|
3
|
+
<ion-title>{{ titulo }}</ion-title>
|
|
4
|
+
<ion-buttons slot="end">
|
|
5
|
+
<ion-button (click)="atualizaArvoreEntidade(tipo)">
|
|
6
|
+
<ion-icon slot="icon-only" name="refresh"></ion-icon>
|
|
7
|
+
</ion-button>
|
|
8
|
+
<ion-button (click)="modalCtrl.dismiss()">Fechar</ion-button>
|
|
9
|
+
</ion-buttons>
|
|
10
|
+
</ion-toolbar>
|
|
11
|
+
</ion-header>
|
|
12
|
+
|
|
13
|
+
<ion-content>
|
|
14
|
+
<ion-item>
|
|
15
|
+
<ion-button style="box-shadow: #4c8dff 0px 2px 2px 0.05px;" fill="outline" (click)="expandir()">
|
|
16
|
+
<ion-icon name="expand-outline"></ion-icon>
|
|
17
|
+
</ion-button>
|
|
18
|
+
</ion-item>
|
|
19
|
+
<kb-tree-view #treeViewComp [campoId]="campoId" [campoPai]="campoPai" [campoLabel]="'LabelTree'" (selecionarRegistro)="clickRegistro($event)"></kb-tree-view>
|
|
20
|
+
</ion-content>
|
|
File without changes
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { ModelTreeviewComponent } from './model-treeview.component';
|
|
4
|
+
|
|
5
|
+
describe('ModelTreeviewComponent', () => {
|
|
6
|
+
let component: ModelTreeviewComponent;
|
|
7
|
+
let fixture: ComponentFixture<ModelTreeviewComponent>;
|
|
8
|
+
|
|
9
|
+
beforeEach(async () => {
|
|
10
|
+
await TestBed.configureTestingModule({
|
|
11
|
+
declarations: [ ModelTreeviewComponent ]
|
|
12
|
+
})
|
|
13
|
+
.compileComponents();
|
|
14
|
+
|
|
15
|
+
fixture = TestBed.createComponent(ModelTreeviewComponent);
|
|
16
|
+
component = fixture.componentInstance;
|
|
17
|
+
fixture.detectChanges();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('should create', () => {
|
|
21
|
+
expect(component).toBeTruthy();
|
|
22
|
+
});
|
|
23
|
+
});
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { Component, Inject, Input, OnInit, Predicate, ViewChild } from '@angular/core';
|
|
2
|
+
import { Subscription } from 'rxjs';
|
|
3
|
+
import { TreeViewComponent } from '../tree-view/tree-view.component';
|
|
4
|
+
import { LoadingController, ModalController } from '@ionic/angular';
|
|
5
|
+
import { LibConfig } from '../lib-config';
|
|
6
|
+
import { HttpClient } from '@angular/common/http';
|
|
7
|
+
@Component({
|
|
8
|
+
selector: 'kb-model-treeview',
|
|
9
|
+
templateUrl: './model-treeview.component.html',
|
|
10
|
+
styleUrls: ['./model-treeview.component.scss']
|
|
11
|
+
})
|
|
12
|
+
export class ModelTreeviewComponent implements OnInit {
|
|
13
|
+
titulo: string = "Selecionar";
|
|
14
|
+
campoId: string;
|
|
15
|
+
campoPai: string;
|
|
16
|
+
campoLabel: string;
|
|
17
|
+
@Input() textoPesquisa: string = "";
|
|
18
|
+
empresaSelecionadaId: number;
|
|
19
|
+
empresaContabilidadeId: number;
|
|
20
|
+
listaArvore: any[];
|
|
21
|
+
tipo: string;
|
|
22
|
+
//url da API para pesquisar os itens
|
|
23
|
+
url: string;
|
|
24
|
+
subscriptionClick: Subscription;
|
|
25
|
+
subscribeId: string;
|
|
26
|
+
//função para filtrar registros que podem ser clicados
|
|
27
|
+
filterFunction: Predicate<any>;
|
|
28
|
+
//especificos
|
|
29
|
+
planoContas: number;
|
|
30
|
+
maximizar: boolean = false;
|
|
31
|
+
@ViewChild("treeViewComp") treeView: TreeViewComponent;
|
|
32
|
+
|
|
33
|
+
BASE_API = this.config.apiUrl;
|
|
34
|
+
constructor(@Inject('LibConfigService') private config: LibConfig,
|
|
35
|
+
public modalCtrl: ModalController,
|
|
36
|
+
private httpClient: HttpClient,
|
|
37
|
+
private loadingCtrl: LoadingController) { }
|
|
38
|
+
|
|
39
|
+
ngOnInit(): void {
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
ionViewDidEnter() {
|
|
43
|
+
this.atualizaArvoreEntidade(this.tipo);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async atualizaArvoreEntidade(tipo: string) {
|
|
47
|
+
let subscriptionC: Subscription;
|
|
48
|
+
this.treeView.cadastro = this.subscribeId;
|
|
49
|
+
let loading = await this.showLoading("Pesquisando...", true);
|
|
50
|
+
loading.onDidDismiss().then(() => {
|
|
51
|
+
subscriptionC?.unsubscribe();
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
this.url = this.url.startsWith('http') ? this.url : `${this.BASE_API}/${this.url}`;
|
|
55
|
+
|
|
56
|
+
var url = this.url.replace('<<EMPRESA>>', this.empresaSelecionadaId.toString());
|
|
57
|
+
var url = this.url.replace('<<FILTRO>>', '');
|
|
58
|
+
// if (this.textoPesquisa) {
|
|
59
|
+
// url += `?filtro=${this.textoPesquisa}`;
|
|
60
|
+
// }
|
|
61
|
+
|
|
62
|
+
subscriptionC = this.httpClient.get(url).subscribe({
|
|
63
|
+
next: (result: any[]) => {
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
/*
|
|
67
|
+
empresaContato.forEach((ec) => {
|
|
68
|
+
ec.LabelTree = ec.Nome;
|
|
69
|
+
ec.EmpresaContatoPaiId = null; //campo ficticio para montar arvore
|
|
70
|
+
ec.ClicableTree = true;
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
this.treeView.campoId = "EmpresaContatoId";
|
|
74
|
+
this.treeView.campoPai = "EmpresaContatoPaiId";
|
|
75
|
+
this.treeView.campoLabel = "LabelTree";
|
|
76
|
+
this.treeView.itens = empresaContato;
|
|
77
|
+
this.treeView.arvoreClick(false);
|
|
78
|
+
*/
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
if (!this.campoPai) {
|
|
82
|
+
this.campoPai = `${this.campoId}Pai`;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
result.forEach((cc) => {
|
|
87
|
+
cc.LabelTree = cc[this.campoLabel];
|
|
88
|
+
if (!cc[this.campoPai]) {
|
|
89
|
+
cc[this.campoPai] = null;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (this.filterFunction != null) {
|
|
93
|
+
const clicable = [{ ...cc }].find(this.filterFunction);
|
|
94
|
+
if (clicable != null && cc.ClicableTree == null) {
|
|
95
|
+
cc.ClicableTree = true;
|
|
96
|
+
} else {
|
|
97
|
+
cc.ClicableTree = false;
|
|
98
|
+
}
|
|
99
|
+
} else {
|
|
100
|
+
cc.ClicableTree = true;
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
console.log('tree result', result);
|
|
105
|
+
|
|
106
|
+
this.treeView.campoId = this.campoId;
|
|
107
|
+
this.treeView.campoPai = this.campoPai;
|
|
108
|
+
this.treeView.campoLabel = this.campoLabel;
|
|
109
|
+
this.treeView.itens = result;
|
|
110
|
+
this.treeView.arvoreClick(false);
|
|
111
|
+
|
|
112
|
+
loading.dismiss();
|
|
113
|
+
},
|
|
114
|
+
error: (error) => {
|
|
115
|
+
loading.dismiss();
|
|
116
|
+
console.log("Erro ao carregar os registros.<br>Tente mais tarde.");
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
clickRegistro(evento) {
|
|
123
|
+
if (evento.Id > 0) {
|
|
124
|
+
this.modalCtrl.dismiss({ Id: evento.Id });
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
expandir() {
|
|
129
|
+
this.treeView.expandir();
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
//utils
|
|
133
|
+
async showLoading(msg: string, cancelable: boolean = false): Promise<HTMLIonLoadingElement> {
|
|
134
|
+
const loading = await this.loadingCtrl.create({
|
|
135
|
+
message: msg,
|
|
136
|
+
backdropDismiss: cancelable
|
|
137
|
+
//duration: 2000
|
|
138
|
+
});
|
|
139
|
+
/*
|
|
140
|
+
loading.onDidDismiss().then(() => {
|
|
141
|
+
console.log('loading dissmissed', request);
|
|
142
|
+
if (request.subscription) {
|
|
143
|
+
request.subscription.unsubscribe();
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
*/
|
|
147
|
+
await loading.present();
|
|
148
|
+
return loading;
|
|
149
|
+
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
<div style="position: relative; height: auto; padding-left: 2%; background-color: white;">
|
|
2
|
+
|
|
3
|
+
<div *ngIf="arvore" [class]="caixaClass" style="padding-left: 6px; font-size: 12px;">
|
|
4
|
+
<!-- raiz -->
|
|
5
|
+
<div *ngFor="let raiz of arvore" class="coluna">
|
|
6
|
+
<kb-tree-view-nivel [nivel]="0" [node]="raiz" [currentSearch]="currentSearch" (nivelClick)="raiz.Clicable === true ? carregarRegistro(raiz) : null">
|
|
7
|
+
</kb-tree-view-nivel>
|
|
8
|
+
|
|
9
|
+
<div *ngIf="raiz.Expandido" class="filho">
|
|
10
|
+
<div *ngFor="let nivel1 of raiz.Filhos" draggable="true">
|
|
11
|
+
<kb-tree-view-nivel [nivel]="1" [node]="nivel1" [currentSearch]="currentSearch" (nivelClick)="nivel1.Clicable === true ? carregarRegistro(nivel1): null">
|
|
12
|
+
</kb-tree-view-nivel>
|
|
13
|
+
|
|
14
|
+
<div *ngIf="nivel1 && nivel1.Expandido" class="filho">
|
|
15
|
+
<div *ngFor="let nivel2 of nivel1.Filhos">
|
|
16
|
+
<kb-tree-view-nivel [nivel]="2" [node]="nivel2" [currentSearch]="currentSearch" (nivelClick)="nivel2.Clicable === true ? carregarRegistro(nivel2): null">
|
|
17
|
+
</kb-tree-view-nivel>
|
|
18
|
+
|
|
19
|
+
<div *ngIf="nivel2 && nivel2.Expandido" class="filho">
|
|
20
|
+
<div *ngFor="let nivel3 of nivel2.Filhos">
|
|
21
|
+
<kb-tree-view-nivel [nivel]="3" [node]="nivel3" [currentSearch]="currentSearch" (nivelClick)="nivel3.Clicable === true ? carregarRegistro(nivel3): null">
|
|
22
|
+
</kb-tree-view-nivel>
|
|
23
|
+
|
|
24
|
+
<div *ngIf="nivel3 && nivel3.Expandido" class="filho">
|
|
25
|
+
<div *ngFor="let nivel4 of nivel3.Filhos">
|
|
26
|
+
<kb-tree-view-nivel [nivel]="4" [node]="nivel4" [currentSearch]="currentSearch" (nivelClick)="nivel4.Clicable === true ? carregarRegistro(nivel4): null">
|
|
27
|
+
</kb-tree-view-nivel>
|
|
28
|
+
|
|
29
|
+
<div *ngIf="nivel4 && nivel4.Expandido" class="filho">
|
|
30
|
+
<div *ngFor="let nivel5 of nivel4.Filhos">
|
|
31
|
+
<kb-tree-view-nivel [nivel]="5" [node]="nivel5" [currentSearch]="currentSearch"
|
|
32
|
+
(nivelClick)="nivel5.Clicable === true ? carregarRegistro(nivel5): null"></kb-tree-view-nivel>
|
|
33
|
+
|
|
34
|
+
<div *ngIf="nivel5 && nivel5.Expandido" class="filho">
|
|
35
|
+
<div *ngFor="let nivel6 of nivel5.Filhos">
|
|
36
|
+
<kb-tree-view-nivel [nivel]="6" [node]="nivel6" [currentSearch]="currentSearch"
|
|
37
|
+
(nivelClick)="nivel6.Clicable === true ? carregarRegistro(nivel6): null"></kb-tree-view-nivel>
|
|
38
|
+
|
|
39
|
+
<div *ngIf="nivel6 && nivel6.Expandido" class="filho">
|
|
40
|
+
<div *ngFor="let nivel7 of nivel6.Filhos">
|
|
41
|
+
<kb-tree-view-nivel [nivel]="7" [node]="nivel7" [currentSearch]="currentSearch"
|
|
42
|
+
(nivelClick)="nivel7.Clicable === true ? carregarRegistro(nivel7): null"></kb-tree-view-nivel>
|
|
43
|
+
|
|
44
|
+
<div *ngIf="nivel7 && nivel7.Expandido" class="filho">
|
|
45
|
+
<div *ngFor="let nivel8 of nivel7.Filhos">
|
|
46
|
+
<kb-tree-view-nivel [nivel]="8" [node]="nivel8"
|
|
47
|
+
(nivelClick)="nivel8.Clicable === true ? carregarRegistro(nivel8): null"></kb-tree-view-nivel>
|
|
48
|
+
|
|
49
|
+
<div *ngIf="nivel8 && nivel8.Expandido" class="filho">
|
|
50
|
+
<div *ngFor="let nivel9 of nivel8.Filhos">
|
|
51
|
+
<kb-tree-view-nivel [nivel]="9" [node]="nivel9" [currentSearch]="currentSearch"
|
|
52
|
+
(nivelClick)="nivel9.Clicable === true ? carregarRegistro(nivel9): null"></kb-tree-view-nivel>
|
|
53
|
+
|
|
54
|
+
<div *ngIf="nivel9 && nivel9.Expandido" class="filho">
|
|
55
|
+
<div *ngFor="let nivel10 of nivel9.Filhos">
|
|
56
|
+
<kb-tree-view-nivel [nivel]="10" [node]="nivel10" [currentSearch]="currentSearch"
|
|
57
|
+
(nivelClick)="nivel10.Clicable === true ? carregarRegistro(nivel10): null"></kb-tree-view-nivel>
|
|
58
|
+
|
|
59
|
+
</div>
|
|
60
|
+
|
|
61
|
+
</div>
|
|
62
|
+
</div>
|
|
63
|
+
|
|
64
|
+
</div>
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
</div>
|
|
68
|
+
|
|
69
|
+
</div>
|
|
70
|
+
</div>
|
|
71
|
+
|
|
72
|
+
</div>
|
|
73
|
+
</div>
|
|
74
|
+
|
|
75
|
+
</div>
|
|
76
|
+
</div>
|
|
77
|
+
|
|
78
|
+
</div>
|
|
79
|
+
</div>
|
|
80
|
+
|
|
81
|
+
</div>
|
|
82
|
+
</div>
|
|
83
|
+
|
|
84
|
+
</div>
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
</div>
|
|
89
|
+
|
|
90
|
+
</div>
|
|
91
|
+
|
|
92
|
+
</div>
|
|
93
|
+
|
|
94
|
+
</div>
|
|
95
|
+
</div>
|
|
96
|
+
</div>
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
.boxSeta {
|
|
2
|
+
margin: 2px;
|
|
3
|
+
font-size: large;
|
|
4
|
+
color: rgb(9, 69, 158);
|
|
5
|
+
cursor: pointer;
|
|
6
|
+
}
|
|
7
|
+
.caixa{
|
|
8
|
+
border: 2px transparent solid;
|
|
9
|
+
padding: 3px;
|
|
10
|
+
//height: 560px;
|
|
11
|
+
width: 100%;
|
|
12
|
+
position: relative;
|
|
13
|
+
overflow-y: auto;
|
|
14
|
+
background-color: white;
|
|
15
|
+
border-radius: 5px;
|
|
16
|
+
height: 100%;
|
|
17
|
+
}
|
|
18
|
+
.coluna{
|
|
19
|
+
padding-bottom: 10px;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.filho{
|
|
23
|
+
padding-top: 6px;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.node-link {
|
|
27
|
+
cursor: pointer;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.caixa-agrupado{
|
|
31
|
+
border: 2px transparent solid;
|
|
32
|
+
padding: 3px;
|
|
33
|
+
height: 701px;
|
|
34
|
+
width: 100%;
|
|
35
|
+
position: relative;
|
|
36
|
+
overflow-y: auto;
|
|
37
|
+
border-radius: 5px;
|
|
38
|
+
background-color: white;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.caixa-empresa{
|
|
42
|
+
border: 2px transparent solid;
|
|
43
|
+
padding: 3px;
|
|
44
|
+
height: 340px;
|
|
45
|
+
width: 100%;
|
|
46
|
+
position: relative;
|
|
47
|
+
overflow-y: auto;
|
|
48
|
+
border-radius: 5px;
|
|
49
|
+
background-color: white;
|
|
50
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { TreeViewComponent } from './tree-view.component';
|
|
4
|
+
|
|
5
|
+
describe('TreeViewComponent', () => {
|
|
6
|
+
let component: TreeViewComponent;
|
|
7
|
+
let fixture: ComponentFixture<TreeViewComponent>;
|
|
8
|
+
|
|
9
|
+
beforeEach(async () => {
|
|
10
|
+
await TestBed.configureTestingModule({
|
|
11
|
+
imports: [TreeViewComponent]
|
|
12
|
+
})
|
|
13
|
+
.compileComponents();
|
|
14
|
+
|
|
15
|
+
fixture = TestBed.createComponent(TreeViewComponent);
|
|
16
|
+
component = fixture.componentInstance;
|
|
17
|
+
fixture.detectChanges();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('should create', () => {
|
|
21
|
+
expect(component).toBeTruthy();
|
|
22
|
+
});
|
|
23
|
+
});
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
|
2
|
+
import { Tree } from 'appproject-lib';
|
|
3
|
+
|
|
4
|
+
@Component({
|
|
5
|
+
selector: 'kb-tree-view',
|
|
6
|
+
templateUrl: './tree-view.component.html',
|
|
7
|
+
styleUrl: './tree-view.component.scss'
|
|
8
|
+
})
|
|
9
|
+
export class TreeViewComponent implements OnInit{
|
|
10
|
+
@Input() itens: any[] = [];
|
|
11
|
+
@Input() campoId: string;
|
|
12
|
+
@Input() campoPai: string;
|
|
13
|
+
@Input() campoLabel: string;
|
|
14
|
+
@Input() cadastro: string;
|
|
15
|
+
//sera o nome da chamada put, ex: [endpoint: CentroCustoPai]/id/pai
|
|
16
|
+
@Input() endpoint: string;
|
|
17
|
+
@Input() caixaClass: string = 'caixa';
|
|
18
|
+
@Output() beforeUpdate = new EventEmitter();
|
|
19
|
+
@Input() currentSearch: string;
|
|
20
|
+
@Output() selecionarRegistro = new EventEmitter();
|
|
21
|
+
|
|
22
|
+
arvore: Tree[] = [];
|
|
23
|
+
|
|
24
|
+
ngOnInit(): void {
|
|
25
|
+
//throw new Error('Method not implemented.');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
montaArvore(pai: number, arvore: Tree[]): number {
|
|
29
|
+
if (arvore && arvore.length > 0) {
|
|
30
|
+
//procurar os filhos de cada no
|
|
31
|
+
arvore.forEach(f => {
|
|
32
|
+
//console.log('no atual:', f, );
|
|
33
|
+
let filhos = this.itens.filter(i => i[this.campoPai] == f.Id);
|
|
34
|
+
//console.log('filhos atual:', filhos);
|
|
35
|
+
f.Filhos = [];
|
|
36
|
+
filhos.forEach(fi => {
|
|
37
|
+
f.Filhos.push({ Id: fi[this.campoId], Pai: f.Id, Label: fi[this.campoLabel], Filhos: [], Expandido: false, Clicable: (fi['ClicableTree'] == null || fi['ClicableTree'] === true) });
|
|
38
|
+
});
|
|
39
|
+
return this.montaArvore(0, f.Filhos);
|
|
40
|
+
});
|
|
41
|
+
return 0;
|
|
42
|
+
} else {
|
|
43
|
+
//console.log('sem filhos');
|
|
44
|
+
return 0;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
arvoreClick(before: boolean = true) {
|
|
49
|
+
if (this.beforeUpdate && before) {
|
|
50
|
+
this.beforeUpdate.emit();
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
this.arvore = [];
|
|
54
|
+
//console.log('tree itens', this.itens);
|
|
55
|
+
if (this.itens && this.itens.length > 0) {
|
|
56
|
+
//montar arvore pais
|
|
57
|
+
this.itens.forEach(it => {
|
|
58
|
+
if (it[this.campoPai] == null) {
|
|
59
|
+
//é pai
|
|
60
|
+
this.arvore.push({ Id: it[this.campoId], Pai: null, Label: it[this.campoLabel], Filhos: [], Expandido: false, Clicable: (it['ClicableTree'] == null || it['ClicableTree'] === true) });
|
|
61
|
+
|
|
62
|
+
}
|
|
63
|
+
})
|
|
64
|
+
this.montaArvore(0, this.arvore);
|
|
65
|
+
|
|
66
|
+
console.log('arvore', this.arvore);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
expandir(arvore: Tree[] = null): number {
|
|
71
|
+
if (arvore == null) {
|
|
72
|
+
arvore = this.arvore;
|
|
73
|
+
}
|
|
74
|
+
if (arvore && arvore.length > 0) {
|
|
75
|
+
//procurar os filhos de cada no
|
|
76
|
+
arvore.forEach(f => {
|
|
77
|
+
//expandir
|
|
78
|
+
f.Expandido = true;
|
|
79
|
+
return this.expandir(f.Filhos);
|
|
80
|
+
});
|
|
81
|
+
return 0;
|
|
82
|
+
} else {
|
|
83
|
+
//console.log('sem filhos');
|
|
84
|
+
return 0;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
carregarRegistro(node: Tree) {
|
|
89
|
+
console.log('carrega registro', node);
|
|
90
|
+
this.selecionarRegistro.next({ Cadastro: this.cadastro, Id: node.Id });
|
|
91
|
+
}
|
|
92
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<span [innerHtml]="identacao" class="node-link"></span>
|
|
2
|
+
<!-- mostrar a seta se tiver filhos ou se for raiz (nivel = 0)-->
|
|
3
|
+
<span class="node-link" *ngIf="!node.Expandido && (node.Filhos.length > 0 || nivel == 0)" (click)="node.Expandido = !node.Expandido"
|
|
4
|
+
class="boxSeta">
|
|
5
|
+
<ion-icon name="chevron-forward-outline"></ion-icon>
|
|
6
|
+
</span>
|
|
7
|
+
<span class="node-link" *ngIf="node.Expandido" (click)="node.Expandido = !node.Expandido" class="boxSeta">
|
|
8
|
+
<ion-icon name="chevron-down-outline"></ion-icon>
|
|
9
|
+
</span>
|
|
10
|
+
<!--
|
|
11
|
+
<span *ngIf="!node.Expandido"> </span>
|
|
12
|
+
-->
|
|
13
|
+
|
|
14
|
+
<!--
|
|
15
|
+
<span [class]="{ 'node-link' : node.Clicable === true, 'node-disabled': node.Clicable === false }" (click)="nodeClick()" title="{{ node.Label }}"> {{ node.Label }}</span>
|
|
16
|
+
-->
|
|
17
|
+
<span [class]="{ 'node-link' : node.Clicable === true, 'node-disabled': node.Clicable === false }" (click)="nodeClick()" title="{{ node.Label }}" [innerHTML]="highlight(node.Label)"></span>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { TreeViewNivelComponent } from './tree-view-nivel.component';
|
|
4
|
+
|
|
5
|
+
describe('TreeViewNivelComponent', () => {
|
|
6
|
+
let component: TreeViewNivelComponent;
|
|
7
|
+
let fixture: ComponentFixture<TreeViewNivelComponent>;
|
|
8
|
+
|
|
9
|
+
beforeEach(async () => {
|
|
10
|
+
await TestBed.configureTestingModule({
|
|
11
|
+
imports: [TreeViewNivelComponent]
|
|
12
|
+
})
|
|
13
|
+
.compileComponents();
|
|
14
|
+
|
|
15
|
+
fixture = TestBed.createComponent(TreeViewNivelComponent);
|
|
16
|
+
component = fixture.componentInstance;
|
|
17
|
+
fixture.detectChanges();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('should create', () => {
|
|
21
|
+
expect(component).toBeTruthy();
|
|
22
|
+
});
|
|
23
|
+
});
|