appproject-components 0.0.1 → 0.0.2
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/esm2020/lib/appproject-components.module.mjs +25 -5
- package/esm2020/lib/input-format/input-format.component.mjs +122 -8
- package/esm2020/lib/input-pesquisa/input-pesquisa.component.mjs +531 -0
- package/esm2020/lib/input-select/input-select.component.mjs +80 -0
- package/esm2020/lib/input-valor/input-valor.component.mjs +122 -0
- package/esm2020/lib/model-treeview/model-treeview.component.mjs +14 -0
- package/esm2020/public-api.mjs +5 -1
- package/fesm2015/appproject-components.mjs +872 -11
- package/fesm2015/appproject-components.mjs.map +1 -1
- package/fesm2020/appproject-components.mjs +863 -11
- package/fesm2020/appproject-components.mjs.map +1 -1
- package/lib/appproject-components.module.d.ts +9 -5
- package/lib/input-format/input-format.component.d.ts +19 -2
- package/lib/input-pesquisa/input-pesquisa.component.d.ts +65 -0
- package/lib/input-select/input-select.component.d.ts +28 -0
- package/lib/input-valor/input-valor.component.d.ts +25 -0
- package/lib/model-treeview/model-treeview.component.d.ts +8 -0
- package/package.json +1 -1
- package/public-api.d.ts +4 -0
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { Injectable, Component, Input, InjectionToken, NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
|
2
|
+
import { Injectable, Component, Input, ViewChild, InjectionToken, NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
|
3
|
+
import * as i3 from '@angular/forms';
|
|
3
4
|
import { NG_VALUE_ACCESSOR, ReactiveFormsModule } from '@angular/forms';
|
|
4
5
|
import * as i1 from '@angular/common';
|
|
5
6
|
import { CommonModule } from '@angular/common';
|
|
6
7
|
import * as i2 from '@ionic/angular';
|
|
7
8
|
import { IonicModule } from '@ionic/angular';
|
|
9
|
+
import * as i1$1 from '@angular/common/http';
|
|
8
10
|
import { HttpClientModule } from '@angular/common/http';
|
|
11
|
+
import { Subject, of } from 'rxjs';
|
|
12
|
+
import { debounceTime, switchMap } from 'rxjs/operators';
|
|
9
13
|
|
|
10
14
|
class AppprojectComponentsService {
|
|
11
15
|
constructor() { }
|
|
@@ -159,16 +163,848 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.2", ngImpor
|
|
|
159
163
|
}], template: "<!--\n<div [formGroup]=\"form\">\n-->\n<div>\n <ion-item lines=\"none\" style=\"--background: inherited; --background-focused: transparent; padding-right: 0px;\" [class]=\"itemClass\"\n [style.opacity]=\"readonly ? '0.5' : '1'\"\n [ngClass]=\"form?.get(formControlName)?.errors && (form?.get(formControlName)?.dirty || form?.get(formControlName)?.touched) ? 'error-shake' : '' \"\n >\n <ion-label position=\"{{ labelPosition }}\" color=\"{{ labelColor }}\">{{ label }}</ion-label>\n <!-- formControlName=\"{{ campo }}\" -->\n <ion-input #inputText\n type=\"{{type}}\" \n [placeholder]=\"placeholder\" \n maxlength=\"{{ max }}\"\n (ionBlur)=\"onBlur()\"\n [value]=\"data\"\n (input)=\"writeValue(inputText.value)\" \n autocomplete=\"new-password\"\n style=\"--background:{{ inputBackgroungColor }};\"\n [disabled]=\"readonly\"></ion-input>\n <ion-button size=\"small\" slot=\"end\" *ngIf=\"botaoLimpar\" style=\"margin-top: 27px; margin-inline-start: 4px !important;\" fill=\"outline\" color=\"medium\" (click)=\"limparClick()\">\n <ion-icon name=\"close-outline\"></ion-icon>\n </ion-button>\n <ion-button size=\"small\" slot=\"end\" *ngIf=\"showSeePassword\" style=\"margin-top: 27px; margin-inline-start: 4px !important;\" fill=\"clear\" color=\"dark\" (click)=\"changeTypeOfInput()\">\n <!-- (click)=\"limparClick()\" -->\n <ion-icon [name]=\"type == 'password' ? 'eye-outline' : 'eye-off-outline' \"></ion-icon>\n </ion-button>\n </ion-item>\n \n <div class=\"validation-errors\" *ngIf=\"form\">\n \n <ng-container *ngFor=\"let validation of validation_messages\">\n <div class=\"error-message\"\n *ngIf=\"form.get(formControlName)?.hasError(validation.type) && (form.get(formControlName)?.dirty || form.get(formControlName)?.touched)\">\n • {{ validation.message }}\n </div>\n </ng-container>\n \n </div>\n </div>", styles: ["@keyframes shake{0%{transform:translate(20px)}20%{transform:translate(-20px)}40%{transform:translate(10px)}60%{transform:translate(-10px)}80%{transform:translate(4px)}to{transform:translate(0)}}ion-label{margin-bottom:4px!important;opacity:1!important}.no-padding-end{--inner-padding-end: 0}ion-item ion-label{overflow:initial!important}ion-input{padding:2px;border:1px solid darkgray;border-radius:4px;width:100%;margin-top:2px;max-height:29px;transition:.2s ease}.error-shake ion-label{color:red!important}.error-shake ion-input{animation:shake .4s 1 linear;border:1px solid red!important}.has-focus{border:1px solid var(--ion-color-bluetool)}input:focus{border:1px solid lightblue!important}input:focus ion-label{--color: blue !important}.error-message{font-size:small;color:red;margin-left:15px}.padding{padding:auto;padding-left:0}.no-padding{--inner-padding-end: 0px;--padding-start: 0px;--padding-bottom: 0px;--inner-padding-bottom: 0px;height:39px!important}.no-padding-no-height{--inner-padding-end: 0px;--padding-start: 0px;--padding-bottom: 0px;--inner-padding-bottom: 0px}.padding-top{--padding-top: 0px}.input-login{height:36px}\n"] }]
|
|
160
164
|
}], ctorParameters: function () { return []; } });
|
|
161
165
|
|
|
162
|
-
class InputFormatComponent {
|
|
163
|
-
constructor() {
|
|
164
|
-
|
|
166
|
+
class InputFormatComponent extends BaseInputComponent {
|
|
167
|
+
constructor() {
|
|
168
|
+
super();
|
|
169
|
+
this.formato = null;
|
|
170
|
+
this.keyEnter = null;
|
|
171
|
+
//control value acessor
|
|
172
|
+
this.data = null;
|
|
173
|
+
this.onChange = (data) => { };
|
|
174
|
+
this.onTouch = () => { };
|
|
175
|
+
this.disabled = false;
|
|
176
|
+
this.console = console;
|
|
177
|
+
}
|
|
178
|
+
writeValue(value) {
|
|
179
|
+
//console.log('write value', value);
|
|
180
|
+
this.onChange(value);
|
|
181
|
+
this.data = value;
|
|
182
|
+
}
|
|
183
|
+
registerOnChange(fn) {
|
|
184
|
+
this.onChange = fn;
|
|
185
|
+
}
|
|
186
|
+
registerOnTouched(fn) {
|
|
187
|
+
this.onTouch = fn;
|
|
188
|
+
}
|
|
189
|
+
setDisabledState(isDisabled) {
|
|
190
|
+
this.disabled = this.disabled;
|
|
191
|
+
}
|
|
192
|
+
ngOnInit() { }
|
|
193
|
+
digitarFormatado(event) {
|
|
194
|
+
console.log(event);
|
|
195
|
+
if ((event.keyCode >= 48 && event.keyCode <= 57)
|
|
196
|
+
|| (event.keyCode >= 96 && event.keyCode <= 105)
|
|
197
|
+
|| (event.keyCode == 8)
|
|
198
|
+
|| (event.keyCode == 9)
|
|
199
|
+
|| (event.keyCode == 39)
|
|
200
|
+
|| (event.keyCode == 37)) {
|
|
201
|
+
//console.log(this.formControlName, this.form.get(this.formControlName).value);
|
|
202
|
+
setTimeout(() => {
|
|
203
|
+
if (this.form) {
|
|
204
|
+
this.form.patchValue({
|
|
205
|
+
[this.formControlName]: this.formataCampoValor(this.form.get(this.formControlName)?.value, this.formato ?? '', event)
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
this.data = this.formataCampoValor(this.data ?? '', this.formato ?? '', event);
|
|
210
|
+
this.writeValue(this.data);
|
|
211
|
+
}
|
|
212
|
+
}, 100);
|
|
213
|
+
return true;
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
return false;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
onKeyEnter() {
|
|
220
|
+
if (this.keyEnter != null) {
|
|
221
|
+
this.keyEnter();
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
onBlur() {
|
|
225
|
+
if (this.form) {
|
|
226
|
+
this.form.get(this.formControlName)?.markAsTouched();
|
|
227
|
+
}
|
|
228
|
+
if (this.blur) {
|
|
229
|
+
this.blur(this.blurArgs);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
formataCampoValor(valor, Mascara, evento) {
|
|
233
|
+
console.log(valor);
|
|
234
|
+
if (!valor)
|
|
235
|
+
return null;
|
|
236
|
+
//console.log(evento);
|
|
237
|
+
//if (!this.keypressInteiro(evento))
|
|
238
|
+
// return;
|
|
239
|
+
var boleanoMascara;
|
|
240
|
+
var Digitato = evento != null ? evento.keyCode : 0;
|
|
241
|
+
let exp = /\-|\.|\/|\(|\)| /g;
|
|
242
|
+
let campoSoNumeros = valor.replace(exp, "");
|
|
243
|
+
var posicaoCampo = 0;
|
|
244
|
+
var NovoValorCampo = "";
|
|
245
|
+
var TamanhoMascara = campoSoNumeros.length;
|
|
246
|
+
;
|
|
247
|
+
if (Digitato != 8) { // backspace
|
|
248
|
+
for (let i = 0; i <= TamanhoMascara; i++) {
|
|
249
|
+
boleanoMascara = ((Mascara.charAt(i) == "-") || (Mascara.charAt(i) == ".")
|
|
250
|
+
|| (Mascara.charAt(i) == "/"));
|
|
251
|
+
boleanoMascara = boleanoMascara || ((Mascara.charAt(i) == "(")
|
|
252
|
+
|| (Mascara.charAt(i) == ")") || (Mascara.charAt(i) == " "));
|
|
253
|
+
if (boleanoMascara) {
|
|
254
|
+
NovoValorCampo += Mascara.charAt(i);
|
|
255
|
+
TamanhoMascara++;
|
|
256
|
+
}
|
|
257
|
+
else {
|
|
258
|
+
NovoValorCampo += campoSoNumeros.charAt(posicaoCampo);
|
|
259
|
+
posicaoCampo++;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
return NovoValorCampo;
|
|
263
|
+
}
|
|
264
|
+
else {
|
|
265
|
+
return valor;
|
|
266
|
+
}
|
|
165
267
|
}
|
|
166
268
|
}
|
|
167
269
|
InputFormatComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.2", ngImport: i0, type: InputFormatComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
168
|
-
InputFormatComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.1.2", type: InputFormatComponent, selector: "kb-input-format",
|
|
270
|
+
InputFormatComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.1.2", type: InputFormatComponent, selector: "kb-input-format", inputs: { formato: "formato", keyEnter: "keyEnter" }, providers: [{
|
|
271
|
+
provide: NG_VALUE_ACCESSOR,
|
|
272
|
+
useExisting: InputFormatComponent,
|
|
273
|
+
multi: true
|
|
274
|
+
}], usesInheritance: true, ngImport: i0, template: "<!--\n<div [formGroup]=\"form\">\n-->\n<!--comando --inner-padding-end: utilizado pra remover padding desnecess\u00E1rios-->\n<div>\n <ion-item lines=\"none\" style=\"--background: inherited;--background-focused: transparent;--inner-padding-end: 0px;\"\n [ngClass]=\"form?.get(formControlName)?.errors && (form?.get(formControlName)?.dirty || form?.get(formControlName)?.touched) ? 'error-shake' : '' \"\n >\n <ion-label [position]=\"labelPosition\">{{ label }}</ion-label>\n <!-- formControlName={{formControlName}} -->\n <ion-input #inputFormat\n type=\"tel\" \n [placeholder]=\"placeholder\"\n maxlength=\"{{ max }}\" \n (keydown)=\"digitarFormatado($event)\" \n (keyup.enter)=\"onKeyEnter()\"\n (ionBlur)=\"onBlur()\"\n [value]=\"data\"\n (input)=\"writeValue(inputFormat.value)\"\n [disabled]=\"readonly\"></ion-input>\n \n </ion-item>\n \n <div class=\"validation-errors\" *ngIf=\"form\">\n <ng-container *ngFor=\"let validation of validation_messages\">\n <div class=\"error-message\"\n *ngIf=\"form && form.get(formControlName)?.hasError(validation.type) && (form.get(formControlName)?.dirty || form.get(formControlName)?.touched)\">\n • {{ validation.message }}\n </div>\n </ng-container>\n </div>\n </div>", styles: ["@keyframes shake{0%{transform:translate(20px)}20%{transform:translate(-20px)}40%{transform:translate(10px)}60%{transform:translate(-10px)}80%{transform:translate(4px)}to{transform:translate(0)}}.error-shake ion-label{color:red!important}.error-shake ion-input{animation:shake .4s 1 linear;border:1px solid red!important}.has-focus{border:1px solid var(--ion-color-bluetool)}ion-label{margin-bottom:4px!important}ion-input{padding:4px;border:1px solid darkgray;border-radius:4px;width:100%;margin-top:2px;max-height:29px}.error-message{font-size:small;color:red;margin-left:15px}.item-inner{padding-right:0!important}\n"], dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i2.IonInput, selector: "ion-input", inputs: ["accept", "autocapitalize", "autocomplete", "autocorrect", "autofocus", "clearInput", "clearOnEdit", "color", "debounce", "disabled", "enterkeyhint", "inputmode", "max", "maxlength", "min", "minlength", "mode", "multiple", "name", "pattern", "placeholder", "readonly", "required", "size", "spellcheck", "step", "type", "value"] }, { kind: "component", type: i2.IonItem, selector: "ion-item", inputs: ["button", "color", "counter", "counterFormatter", "detail", "detailIcon", "disabled", "download", "fill", "href", "lines", "mode", "rel", "routerAnimation", "routerDirection", "shape", "target", "type"] }, { kind: "component", type: i2.IonLabel, selector: "ion-label", inputs: ["color", "mode", "position"] }, { kind: "directive", type: i2.TextValueAccessor, selector: "ion-input:not([type=number]),ion-textarea,ion-searchbar" }] });
|
|
169
275
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.2", ngImport: i0, type: InputFormatComponent, decorators: [{
|
|
170
276
|
type: Component,
|
|
171
|
-
args: [{ selector: 'kb-input-format',
|
|
277
|
+
args: [{ selector: 'kb-input-format', providers: [{
|
|
278
|
+
provide: NG_VALUE_ACCESSOR,
|
|
279
|
+
useExisting: InputFormatComponent,
|
|
280
|
+
multi: true
|
|
281
|
+
}], template: "<!--\n<div [formGroup]=\"form\">\n-->\n<!--comando --inner-padding-end: utilizado pra remover padding desnecess\u00E1rios-->\n<div>\n <ion-item lines=\"none\" style=\"--background: inherited;--background-focused: transparent;--inner-padding-end: 0px;\"\n [ngClass]=\"form?.get(formControlName)?.errors && (form?.get(formControlName)?.dirty || form?.get(formControlName)?.touched) ? 'error-shake' : '' \"\n >\n <ion-label [position]=\"labelPosition\">{{ label }}</ion-label>\n <!-- formControlName={{formControlName}} -->\n <ion-input #inputFormat\n type=\"tel\" \n [placeholder]=\"placeholder\"\n maxlength=\"{{ max }}\" \n (keydown)=\"digitarFormatado($event)\" \n (keyup.enter)=\"onKeyEnter()\"\n (ionBlur)=\"onBlur()\"\n [value]=\"data\"\n (input)=\"writeValue(inputFormat.value)\"\n [disabled]=\"readonly\"></ion-input>\n \n </ion-item>\n \n <div class=\"validation-errors\" *ngIf=\"form\">\n <ng-container *ngFor=\"let validation of validation_messages\">\n <div class=\"error-message\"\n *ngIf=\"form && form.get(formControlName)?.hasError(validation.type) && (form.get(formControlName)?.dirty || form.get(formControlName)?.touched)\">\n • {{ validation.message }}\n </div>\n </ng-container>\n </div>\n </div>", styles: ["@keyframes shake{0%{transform:translate(20px)}20%{transform:translate(-20px)}40%{transform:translate(10px)}60%{transform:translate(-10px)}80%{transform:translate(4px)}to{transform:translate(0)}}.error-shake ion-label{color:red!important}.error-shake ion-input{animation:shake .4s 1 linear;border:1px solid red!important}.has-focus{border:1px solid var(--ion-color-bluetool)}ion-label{margin-bottom:4px!important}ion-input{padding:4px;border:1px solid darkgray;border-radius:4px;width:100%;margin-top:2px;max-height:29px}.error-message{font-size:small;color:red;margin-left:15px}.item-inner{padding-right:0!important}\n"] }]
|
|
282
|
+
}], ctorParameters: function () { return []; }, propDecorators: { formato: [{
|
|
283
|
+
type: Input
|
|
284
|
+
}], keyEnter: [{
|
|
285
|
+
type: Input
|
|
286
|
+
}] } });
|
|
287
|
+
|
|
288
|
+
class InputSelectComponent extends BaseInputComponent {
|
|
289
|
+
constructor() {
|
|
290
|
+
super();
|
|
291
|
+
this.change = null;
|
|
292
|
+
this.itens = [];
|
|
293
|
+
this.itemId = "Id";
|
|
294
|
+
this.itemNome = "Nome";
|
|
295
|
+
this.showNovo = false;
|
|
296
|
+
this.itemNull = true;
|
|
297
|
+
this.opcaoDefault = 'Selecionar';
|
|
298
|
+
this.onChange = (data) => { };
|
|
299
|
+
this.onTouch = () => { };
|
|
300
|
+
this.disabled = false;
|
|
301
|
+
this.console = console;
|
|
302
|
+
}
|
|
303
|
+
writeValue(value) {
|
|
304
|
+
//console.log('write value select', value);
|
|
305
|
+
this.onChange(value);
|
|
306
|
+
this.data = value;
|
|
307
|
+
}
|
|
308
|
+
registerOnChange(fn) {
|
|
309
|
+
this.onChange = fn;
|
|
310
|
+
}
|
|
311
|
+
registerOnTouched(fn) {
|
|
312
|
+
this.onTouch = fn;
|
|
313
|
+
}
|
|
314
|
+
setDisabledState(isDisabled) {
|
|
315
|
+
this.disabled = this.disabled;
|
|
316
|
+
}
|
|
317
|
+
ngOnInit() {
|
|
318
|
+
}
|
|
319
|
+
onSelectChange(value) {
|
|
320
|
+
this.writeValue(value);
|
|
321
|
+
if (this.change != null) {
|
|
322
|
+
this.change();
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
onBlur() {
|
|
326
|
+
//console.log('input select blur')
|
|
327
|
+
if (this.form) {
|
|
328
|
+
this.form.get(this.formControlName)?.markAsTouched();
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
InputSelectComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.2", ngImport: i0, type: InputSelectComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
333
|
+
InputSelectComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.1.2", type: InputSelectComponent, selector: "kb-input-select", inputs: { change: "change", itens: "itens", itemId: "itemId", itemNome: "itemNome", showNovo: "showNovo", itemNull: "itemNull", opcaoDefault: "opcaoDefault" }, providers: [{
|
|
334
|
+
provide: NG_VALUE_ACCESSOR,
|
|
335
|
+
useExisting: InputSelectComponent,
|
|
336
|
+
multi: true
|
|
337
|
+
}], usesInheritance: true, ngImport: i0, template: "<!--\n<div [formGroup]=\"form\">\n-->\n<div>\n <ion-item lines=\"none\" style=\"--background: inherited; --background-focused: transparent;\" [class]=\"itemClass\"\n [ngClass]=\"form?.get(formControlName)?.errors && (form?.get(formControlName)?.dirty || form?.get(formControlName)?.touched) ? 'error-shake' : '' \"\n >\n <ion-label *ngIf=\"label\" [position]=\"labelPosition\">{{ label }}</ion-label>\n <!-- formControlName=\"{{ formControlName }}\" -->\n <select #inputSelect\n style=\"width: 100%;\" (change)=\"onSelectChange(inputSelect.value)\"\n (blur)=\"onBlur()\" [disabled]=\"readonly\">\n <option *ngIf=\"itemNull\" [value]=\"''\" selected>{{ opcaoDefault }}</option>\n <option *ngFor=\"let item of itens\" [value]=\"item[itemId]\" [selected]=\"item[itemId] == data\">{{ item[itemNome] }}\n </option>\n </select> \n </ion-item>\n \n \n <div class=\"validation-errors\" *ngIf=\"form\">\n <ng-container *ngFor=\"let validation of validation_messages\">\n <div class=\"error-message\"\n *ngIf=\"form && form.get(formControlName)?.hasError(validation.type) && (form.get(formControlName)?.touched)\">\n • {{ validation.message }}\n </div>\n </ng-container>\n </div>\n \n </div>", styles: ["@keyframes shake{0%{transform:translate(20px)}20%{transform:translate(-20px)}40%{transform:translate(10px)}60%{transform:translate(-10px)}80%{transform:translate(4px)}to{transform:translate(0)}}.error-shake ion-label{color:red!important}.error-shake select{animation:shake .4s 1 linear;border:1px solid red!important}.has-focus{border:1px solid var(--ion-color-bluetool)}ion-label{margin-bottom:4px!important}select{padding:4px;border:1px solid darkgray;border-radius:4px;width:100%;margin-top:0;height:28px;margin-left:0}.error-message{font-size:small;color:red;margin-left:15px}.padding{padding:auto}.no-padding{--inner-padding-end: 0px;--padding-start: 0px;--padding-bottom: 0px;--inner-padding-bottom: 0px;height:42px!important}.no-padding-no-height{--inner-padding-end: 0px;--padding-start: 0px;--padding-bottom: 0px;--inner-padding-bottom: 0px}.padding-top{--padding-top: 0px}\n"], dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i2.IonItem, selector: "ion-item", inputs: ["button", "color", "counter", "counterFormatter", "detail", "detailIcon", "disabled", "download", "fill", "href", "lines", "mode", "rel", "routerAnimation", "routerDirection", "shape", "target", "type"] }, { kind: "component", type: i2.IonLabel, selector: "ion-label", inputs: ["color", "mode", "position"] }, { kind: "directive", type: i3.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i3.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }] });
|
|
338
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.2", ngImport: i0, type: InputSelectComponent, decorators: [{
|
|
339
|
+
type: Component,
|
|
340
|
+
args: [{ selector: 'kb-input-select', providers: [{
|
|
341
|
+
provide: NG_VALUE_ACCESSOR,
|
|
342
|
+
useExisting: InputSelectComponent,
|
|
343
|
+
multi: true
|
|
344
|
+
}], template: "<!--\n<div [formGroup]=\"form\">\n-->\n<div>\n <ion-item lines=\"none\" style=\"--background: inherited; --background-focused: transparent;\" [class]=\"itemClass\"\n [ngClass]=\"form?.get(formControlName)?.errors && (form?.get(formControlName)?.dirty || form?.get(formControlName)?.touched) ? 'error-shake' : '' \"\n >\n <ion-label *ngIf=\"label\" [position]=\"labelPosition\">{{ label }}</ion-label>\n <!-- formControlName=\"{{ formControlName }}\" -->\n <select #inputSelect\n style=\"width: 100%;\" (change)=\"onSelectChange(inputSelect.value)\"\n (blur)=\"onBlur()\" [disabled]=\"readonly\">\n <option *ngIf=\"itemNull\" [value]=\"''\" selected>{{ opcaoDefault }}</option>\n <option *ngFor=\"let item of itens\" [value]=\"item[itemId]\" [selected]=\"item[itemId] == data\">{{ item[itemNome] }}\n </option>\n </select> \n </ion-item>\n \n \n <div class=\"validation-errors\" *ngIf=\"form\">\n <ng-container *ngFor=\"let validation of validation_messages\">\n <div class=\"error-message\"\n *ngIf=\"form && form.get(formControlName)?.hasError(validation.type) && (form.get(formControlName)?.touched)\">\n • {{ validation.message }}\n </div>\n </ng-container>\n </div>\n \n </div>", styles: ["@keyframes shake{0%{transform:translate(20px)}20%{transform:translate(-20px)}40%{transform:translate(10px)}60%{transform:translate(-10px)}80%{transform:translate(4px)}to{transform:translate(0)}}.error-shake ion-label{color:red!important}.error-shake select{animation:shake .4s 1 linear;border:1px solid red!important}.has-focus{border:1px solid var(--ion-color-bluetool)}ion-label{margin-bottom:4px!important}select{padding:4px;border:1px solid darkgray;border-radius:4px;width:100%;margin-top:0;height:28px;margin-left:0}.error-message{font-size:small;color:red;margin-left:15px}.padding{padding:auto}.no-padding{--inner-padding-end: 0px;--padding-start: 0px;--padding-bottom: 0px;--inner-padding-bottom: 0px;height:42px!important}.no-padding-no-height{--inner-padding-end: 0px;--padding-start: 0px;--padding-bottom: 0px;--inner-padding-bottom: 0px}.padding-top{--padding-top: 0px}\n"] }]
|
|
345
|
+
}], ctorParameters: function () { return []; }, propDecorators: { change: [{
|
|
346
|
+
type: Input
|
|
347
|
+
}], itens: [{
|
|
348
|
+
type: Input
|
|
349
|
+
}], itemId: [{
|
|
350
|
+
type: Input
|
|
351
|
+
}], itemNome: [{
|
|
352
|
+
type: Input
|
|
353
|
+
}], showNovo: [{
|
|
354
|
+
type: Input
|
|
355
|
+
}], itemNull: [{
|
|
356
|
+
type: Input
|
|
357
|
+
}], opcaoDefault: [{
|
|
358
|
+
type: Input
|
|
359
|
+
}] } });
|
|
360
|
+
|
|
361
|
+
class ModelTreeviewComponent {
|
|
362
|
+
constructor() { }
|
|
363
|
+
ngOnInit() {
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
ModelTreeviewComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.2", ngImport: i0, type: ModelTreeviewComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
367
|
+
ModelTreeviewComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.1.2", type: ModelTreeviewComponent, selector: "kb-model-treeview", ngImport: i0, template: "<p>model-treeview works!</p>\n", styles: [""] });
|
|
368
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.2", ngImport: i0, type: ModelTreeviewComponent, decorators: [{
|
|
369
|
+
type: Component,
|
|
370
|
+
args: [{ selector: 'kb-model-treeview', template: "<p>model-treeview works!</p>\n" }]
|
|
371
|
+
}], ctorParameters: function () { return []; } });
|
|
372
|
+
|
|
373
|
+
class InputPesquisaComponent extends BaseInputComponent {
|
|
374
|
+
constructor(httpClient, modalCtrl) {
|
|
375
|
+
super();
|
|
376
|
+
this.httpClient = httpClient;
|
|
377
|
+
this.modalCtrl = modalCtrl;
|
|
378
|
+
this.podePesquisar = true;
|
|
379
|
+
this.textoPesquisa = '';
|
|
380
|
+
this.selectElementVisivel = false;
|
|
381
|
+
this.listaPesquisa = [];
|
|
382
|
+
this.max = '30';
|
|
383
|
+
this.pesquisaSubject = new Subject();
|
|
384
|
+
this.filterFunction = null;
|
|
385
|
+
this.selectId = 'selectElement';
|
|
386
|
+
this.campoId = 'Id';
|
|
387
|
+
this.campoPaiId = 'PaiId';
|
|
388
|
+
this.campoDisplay = 'Descricao';
|
|
389
|
+
this.tipo = '';
|
|
390
|
+
//@ViewChild('selectElement', { read: ElementRef, static: true }) selectElement;
|
|
391
|
+
this.selectElement = null;
|
|
392
|
+
//parametros para chamada API
|
|
393
|
+
//endpoint para pesquisa por digitação
|
|
394
|
+
this.url = '';
|
|
395
|
+
this.urlItem = '';
|
|
396
|
+
//endpoint para montar a arvore, se estiver vazia será usado o campo 'url'
|
|
397
|
+
this.urlTree = '';
|
|
398
|
+
this.empresa = 0;
|
|
399
|
+
this.loadInit = false;
|
|
400
|
+
this.onChange = (data) => { };
|
|
401
|
+
this.onTouch = () => { };
|
|
402
|
+
this.disabled = false;
|
|
403
|
+
this.console = console;
|
|
404
|
+
this.modelChanged = new Subject();
|
|
405
|
+
this.modelChangeSubscription = this.modelChanged
|
|
406
|
+
.pipe(debounceTime(500))
|
|
407
|
+
.subscribe(data => {
|
|
408
|
+
this.carregaItemIdParaLista(data);
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
writeValue(value) {
|
|
412
|
+
//console.log('write value', value);
|
|
413
|
+
this.onChange(value);
|
|
414
|
+
this.data = value;
|
|
415
|
+
if (value == null || value == 0) {
|
|
416
|
+
this.writePesquisa('');
|
|
417
|
+
this.selectedItem = null;
|
|
418
|
+
}
|
|
419
|
+
else {
|
|
420
|
+
if (this.loadInit == true) {
|
|
421
|
+
this.loadInit = false;
|
|
422
|
+
this.modelChanged.next(value);
|
|
423
|
+
//this.carregaItemIdParaLista(value);
|
|
424
|
+
}
|
|
425
|
+
else {
|
|
426
|
+
//console.log(this.selectedItem);
|
|
427
|
+
if (!this.selectedItem || (this.selectedItem && this.selectedItem[this.campoId] != value)) {
|
|
428
|
+
console.log('Id diferente');
|
|
429
|
+
this.modelChanged.next(value);
|
|
430
|
+
//this.carregaItemIdParaLista(value);
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
registerOnChange(fn) {
|
|
436
|
+
this.onChange = fn;
|
|
437
|
+
}
|
|
438
|
+
registerOnTouched(fn) {
|
|
439
|
+
this.onTouch = fn;
|
|
440
|
+
}
|
|
441
|
+
setDisabledState(isDisabled) {
|
|
442
|
+
this.disabled = this.disabled;
|
|
443
|
+
}
|
|
444
|
+
onBlur(event) {
|
|
445
|
+
console.log('blur', event);
|
|
446
|
+
console.log(event.detail.relatedTarget);
|
|
447
|
+
if (event.detail.relatedTarget == null || event.detail.relatedTarget.id.indexOf(this.selectId + 'IonItem') == -1) {
|
|
448
|
+
console.log("true", event.detail.relatedTarget.id);
|
|
449
|
+
//pesquisar item na lista
|
|
450
|
+
if (!this.existeNaListaTexto(this.textoPesquisa, true)) {
|
|
451
|
+
this.limparClick();
|
|
452
|
+
}
|
|
453
|
+
this.dropDownPesquisa(0);
|
|
454
|
+
if (this.form) {
|
|
455
|
+
this.form.get(this.formControlName)?.markAsTouched();
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
ngOnInit() {
|
|
460
|
+
this.pesquisaSubject.pipe(switchMap((url) => {
|
|
461
|
+
this.console.log('subject url:', url);
|
|
462
|
+
if (!this.isEmpty(url))
|
|
463
|
+
return this.httpClient.get(url);
|
|
464
|
+
else
|
|
465
|
+
return of([]);
|
|
466
|
+
}))
|
|
467
|
+
.subscribe({
|
|
468
|
+
next: (result) => {
|
|
469
|
+
//this.listaPesquisa = result;
|
|
470
|
+
this.console.log('subject subscribe result:', result);
|
|
471
|
+
this.listaPesquisa = [];
|
|
472
|
+
if (result && result.length > 0) {
|
|
473
|
+
if (this.filterFunction) {
|
|
474
|
+
result = result.filter(this.filterFunction);
|
|
475
|
+
}
|
|
476
|
+
result.forEach((ent, index) => {
|
|
477
|
+
this.listaPesquisa.push({ ...ent, Index: index, Selected: false });
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
this.podePesquisar = true;
|
|
481
|
+
if (this.listaPesquisa.length > 0) {
|
|
482
|
+
this.dropDownPesquisa(this.listaPesquisa.length);
|
|
483
|
+
}
|
|
484
|
+
},
|
|
485
|
+
error: (error) => {
|
|
486
|
+
this.podePesquisar = true;
|
|
487
|
+
console.log('erro pesquisa', error);
|
|
488
|
+
}
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
writePesquisa(value) {
|
|
492
|
+
//console.log('write pesquisa', value);
|
|
493
|
+
this.textoPesquisa = value;
|
|
494
|
+
}
|
|
495
|
+
showPesquisa(e) {
|
|
496
|
+
//console.log('show pesquisa', e.keyCode);
|
|
497
|
+
var self = this;
|
|
498
|
+
if ((e.keyCode >= 48 && e.keyCode <= 57) ||
|
|
499
|
+
(e.keyCode >= 65 && e.keyCode <= 90) ||
|
|
500
|
+
(e.keyCode >= 96 && e.keyCode <= 105) ||
|
|
501
|
+
(e.keyCode == 8)) {
|
|
502
|
+
if (!self.podePesquisar) {
|
|
503
|
+
return;
|
|
504
|
+
}
|
|
505
|
+
let filtro = self.textoPesquisa;
|
|
506
|
+
if (filtro != null && filtro != '' && filtro.length >= 2) {
|
|
507
|
+
self.pesquisarEntidade(filtro);
|
|
508
|
+
}
|
|
509
|
+
else {
|
|
510
|
+
if (e.keyCode == 8 && !filtro) {
|
|
511
|
+
this.limparClick();
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
else {
|
|
516
|
+
if (e.keyCode == 40 || e.keyCode == 38) {
|
|
517
|
+
self.dropDownPesquisa(self.listaPesquisa.length);
|
|
518
|
+
if (self.selectElementVisivel == true) {
|
|
519
|
+
//let select = self.selectElement; //document.getElementById(self.TemplateSelect1Id());
|
|
520
|
+
//ion-list
|
|
521
|
+
//selecionado
|
|
522
|
+
//console.log(self.listaPesquisa);
|
|
523
|
+
let inc = e.keyCode == 40 ? 1 : -1;
|
|
524
|
+
let selected = self.listaPesquisa.find(s => s['Selected'] === true);
|
|
525
|
+
let cur = 0;
|
|
526
|
+
if (selected != null) {
|
|
527
|
+
cur = selected['Index'];
|
|
528
|
+
//desmarcar o atual
|
|
529
|
+
selected['Selected'] = false;
|
|
530
|
+
cur = cur + inc;
|
|
531
|
+
}
|
|
532
|
+
else {
|
|
533
|
+
cur = 0;
|
|
534
|
+
}
|
|
535
|
+
if (cur < 0) {
|
|
536
|
+
cur = self.listaPesquisa.length - 1;
|
|
537
|
+
}
|
|
538
|
+
else if (cur >= self.listaPesquisa.length) {
|
|
539
|
+
cur = 0;
|
|
540
|
+
}
|
|
541
|
+
let novoSelected = self.listaPesquisa.find(n => n['Index'] === cur);
|
|
542
|
+
if (novoSelected != null) {
|
|
543
|
+
novoSelected['Selected'] = true;
|
|
544
|
+
self.selectedItem = novoSelected;
|
|
545
|
+
self.textoPesquisa = novoSelected[self.campoDisplay];
|
|
546
|
+
}
|
|
547
|
+
/*
|
|
548
|
+
let select = document.getElementById(this.selectId) as any;
|
|
549
|
+
console.log('select Element', select)
|
|
550
|
+
if (select != null) {
|
|
551
|
+
let inc = e.keyCode == 40 ? 1 : -1;
|
|
552
|
+
let cur = select.selectedIndex;
|
|
553
|
+
if (cur == NaN) cur = -1;
|
|
554
|
+
select.selectedIndex = cur + inc;
|
|
555
|
+
if (select.selectedIndex >= 0 && select.selectedIndex < self.listaPesquisa.length) {
|
|
556
|
+
self.selectedItem = self.listaPesquisa[select.selectedIndex];
|
|
557
|
+
if (self.selectedItem != null) {
|
|
558
|
+
self.textoPesquisa = self.selectedItem[self.campoDisplay];
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
*/
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
else if (e.keyCode == 13) {
|
|
566
|
+
console.log('enter key', e);
|
|
567
|
+
//self.selecionarComboClick(e);
|
|
568
|
+
self.selecionarComboClick(null);
|
|
569
|
+
//return false;
|
|
570
|
+
}
|
|
571
|
+
else if (e.keyCode == 27) {
|
|
572
|
+
//ESC
|
|
573
|
+
self.dropDownPesquisa(0);
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
highlight(texto) {
|
|
578
|
+
let index = texto.toLowerCase().indexOf(this.textoPesquisa.toLowerCase());
|
|
579
|
+
//console.log(index);
|
|
580
|
+
if (index >= 0) {
|
|
581
|
+
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>`);
|
|
582
|
+
}
|
|
583
|
+
else {
|
|
584
|
+
return texto;
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
selecionarComboClick(item) {
|
|
588
|
+
// console.log(item);
|
|
589
|
+
var self = this;
|
|
590
|
+
// console.log('combo click', self);
|
|
591
|
+
/*
|
|
592
|
+
let select = document.getElementById(this.selectId) as any;
|
|
593
|
+
if (select.selectedIndex >= 0) {
|
|
594
|
+
self.selectedItem = self.listaPesquisa[select.selectedIndex];
|
|
595
|
+
}
|
|
596
|
+
console.log('selected', this.selectedItem);
|
|
597
|
+
//self.selectedItem = this.listaPesquisa.find(i => i[this.campoId] == e);
|
|
598
|
+
if (self.selectedItem != null) {
|
|
599
|
+
self.textoPesquisa = self.selectedItem[self.campoDisplay];
|
|
600
|
+
self.writeValue(self.selectedItem[self.campoId]);
|
|
601
|
+
if (e != null) {
|
|
602
|
+
self.selectElementVisivel = false;
|
|
603
|
+
if (self.action != null) {
|
|
604
|
+
self.action(self.selectedItem(), e);
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
else {
|
|
609
|
+
self.selectElementVisivel = false;
|
|
610
|
+
}
|
|
611
|
+
*/
|
|
612
|
+
// pesquisar selecionado
|
|
613
|
+
// console.log(this.listaPesquisa);
|
|
614
|
+
let selected = this.listaPesquisa.find(s => s['Selected'] === true);
|
|
615
|
+
// if (!selected) {
|
|
616
|
+
// console.log(this.campoId, item);
|
|
617
|
+
// selected = this.listaPesquisa.filter( s => s[this.campoId] == item[this.campoId]);
|
|
618
|
+
// }
|
|
619
|
+
//se o item form passado como parametro (click no ion-item)
|
|
620
|
+
if (item != null) {
|
|
621
|
+
if (selected != null) {
|
|
622
|
+
selected['Selected'] = false;
|
|
623
|
+
}
|
|
624
|
+
item['Selected'] = true;
|
|
625
|
+
selected = item;
|
|
626
|
+
}
|
|
627
|
+
if (selected != null) {
|
|
628
|
+
self.selectedItem = selected;
|
|
629
|
+
self.textoPesquisa = selected[self.campoDisplay];
|
|
630
|
+
self.writeValue(selected[self.campoId]);
|
|
631
|
+
self.selectElementVisivel = false;
|
|
632
|
+
console.log('action', self.change);
|
|
633
|
+
if (self.change != null) {
|
|
634
|
+
self.change(self.selectedItem);
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
else {
|
|
638
|
+
self.selectElementVisivel = false;
|
|
639
|
+
}
|
|
640
|
+
// this.listaPesquisa.forEach( pesquisa => {
|
|
641
|
+
// console.log(pesquisa, self.data);
|
|
642
|
+
// } );
|
|
643
|
+
// console.log(this.textoPesquisa);
|
|
644
|
+
}
|
|
645
|
+
selecionarComboChange(e) {
|
|
646
|
+
var self = this;
|
|
647
|
+
console.log('combo change', e);
|
|
648
|
+
self.selectedItem = this.listaPesquisa.find(i => i[this.campoId] == e);
|
|
649
|
+
if (self.selectedItem != null) {
|
|
650
|
+
self.writeValue(e);
|
|
651
|
+
self.textoPesquisa = self.selectedItem[self.campoDisplay];
|
|
652
|
+
if (e != null) {
|
|
653
|
+
self.selectElementVisivel = false;
|
|
654
|
+
if (self.change != null) {
|
|
655
|
+
self.change(self.selectedItem, e);
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
else {
|
|
660
|
+
self.selectElementVisivel = false;
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
dropDownPesquisa(length) {
|
|
664
|
+
var self = this;
|
|
665
|
+
if (self.listaPesquisa != null && self.listaPesquisa.length > 0) {
|
|
666
|
+
if (length == -1) {
|
|
667
|
+
length = self.listaPesquisa.length;
|
|
668
|
+
}
|
|
669
|
+
self.selectElementVisivel = length == 0 ? false : true;
|
|
670
|
+
//console.log(this.selectElement);
|
|
671
|
+
//this.selectElement.open();
|
|
672
|
+
/*
|
|
673
|
+
//let element = this.selectElement;
|
|
674
|
+
let element = document.getElementById(this.selectId);
|
|
675
|
+
console.log('dropDown', element);
|
|
676
|
+
(element as any).size = length + 1;
|
|
677
|
+
if (length == 0) {
|
|
678
|
+
self.selectElementVisivel = false;
|
|
679
|
+
} else {
|
|
680
|
+
self.selectElementVisivel = true;
|
|
681
|
+
}
|
|
682
|
+
*/
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
pesquisarEntidade(filtro) {
|
|
686
|
+
let url = this.url.replace('<<FILTRO>>', filtro).replace('<<EMPRESA>>', this.empresa.toString());
|
|
687
|
+
console.log('pesquisarEntidade url', url);
|
|
688
|
+
this.podePesquisar = false;
|
|
689
|
+
this.pesquisaSubject.next(url);
|
|
690
|
+
}
|
|
691
|
+
pesquisarEntidadeOld(filtro) {
|
|
692
|
+
let url = this.url.replace('<<FILTRO>>', filtro).replace('<<EMPRESA>>', this.empresa.toString());
|
|
693
|
+
console.log('pesquisarEntidade url', url);
|
|
694
|
+
this.podePesquisar = false;
|
|
695
|
+
this.httpClient.get(url)
|
|
696
|
+
.subscribe({ next: (result) => {
|
|
697
|
+
//this.listaPesquisa = result;
|
|
698
|
+
if (this.filterFunction) {
|
|
699
|
+
result = result.filter(this.filterFunction);
|
|
700
|
+
}
|
|
701
|
+
this.listaPesquisa = [];
|
|
702
|
+
result.forEach((ent, index) => {
|
|
703
|
+
this.listaPesquisa.push({ ...ent, Index: index, Selected: false });
|
|
704
|
+
});
|
|
705
|
+
this.podePesquisar = true;
|
|
706
|
+
if (this.listaPesquisa.length > 0) {
|
|
707
|
+
this.dropDownPesquisa(this.listaPesquisa.length);
|
|
708
|
+
}
|
|
709
|
+
}, error: error => {
|
|
710
|
+
console.log('erro pesquisa', error);
|
|
711
|
+
this.podePesquisar = true;
|
|
712
|
+
} });
|
|
713
|
+
}
|
|
714
|
+
existeNaLista(id, setRegistro = false) {
|
|
715
|
+
if (this.listaPesquisa && this.listaPesquisa.length > 0) {
|
|
716
|
+
let existe = this.listaPesquisa.find(l => l[this.campoId] === id);
|
|
717
|
+
if (existe) {
|
|
718
|
+
if (setRegistro) {
|
|
719
|
+
this.selectedItem = existe;
|
|
720
|
+
this.selecionarComboClick(this.selectedItem);
|
|
721
|
+
}
|
|
722
|
+
return true;
|
|
723
|
+
}
|
|
724
|
+
else {
|
|
725
|
+
return false;
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
else {
|
|
729
|
+
return false;
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
existeNaListaTexto(texto, setRegistro = false) {
|
|
733
|
+
console.log("existe texto:", texto, this.campoDisplay, this.listaPesquisa);
|
|
734
|
+
if (this.listaPesquisa && this.listaPesquisa.length > 0) {
|
|
735
|
+
let existe = this.listaPesquisa.find(l => l[this.campoDisplay].toUpperCase() === texto.toUpperCase());
|
|
736
|
+
if (existe) {
|
|
737
|
+
if (setRegistro) {
|
|
738
|
+
this.selectedItem = existe;
|
|
739
|
+
this.selecionarComboClick(this.selectedItem);
|
|
740
|
+
}
|
|
741
|
+
return true;
|
|
742
|
+
}
|
|
743
|
+
else {
|
|
744
|
+
return false;
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
else {
|
|
748
|
+
return false;
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
validarItemSelecionado(setarRegistro = false) {
|
|
752
|
+
console.log('validar selecionado');
|
|
753
|
+
//passar pela função de filtro
|
|
754
|
+
let valido = false;
|
|
755
|
+
if (this.selectedItem) {
|
|
756
|
+
if (this.filterFunction) {
|
|
757
|
+
let existe = [{ ...this.selectedItem }].filter(this.filterFunction);
|
|
758
|
+
if (existe != null && existe.length > 0) {
|
|
759
|
+
valido = true;
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
else {
|
|
763
|
+
valido = true;
|
|
764
|
+
}
|
|
765
|
+
if (valido && setarRegistro) {
|
|
766
|
+
this.selecionarComboClick(this.selectedItem);
|
|
767
|
+
}
|
|
768
|
+
return valido;
|
|
769
|
+
}
|
|
770
|
+
else {
|
|
771
|
+
return false;
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
carregaItemIdParaLista(id) {
|
|
775
|
+
let url = this.urlItem.replace('<<ID>>', id.toString());
|
|
776
|
+
console.log(this.urlItem);
|
|
777
|
+
console.log('pesquisar ID url', url);
|
|
778
|
+
this.podePesquisar = false;
|
|
779
|
+
this.httpClient.get(url)
|
|
780
|
+
.subscribe({ next: (result) => {
|
|
781
|
+
this.listaPesquisa = [];
|
|
782
|
+
this.listaPesquisa.push({ ...result, Index: 0, Selected: true });
|
|
783
|
+
this.podePesquisar = true;
|
|
784
|
+
if (this.listaPesquisa.length > 0) {
|
|
785
|
+
this.selectedItem = this.listaPesquisa[0];
|
|
786
|
+
this.selecionarComboClick(this.selectedItem);
|
|
787
|
+
}
|
|
788
|
+
}, error: error => {
|
|
789
|
+
console.log('erro pesquisa', error);
|
|
790
|
+
this.podePesquisar = true;
|
|
791
|
+
} });
|
|
792
|
+
}
|
|
793
|
+
limparClick() {
|
|
794
|
+
this.writeValue(null);
|
|
795
|
+
this.writePesquisa(null);
|
|
796
|
+
this.listaPesquisa = [];
|
|
797
|
+
this.dropDownPesquisa(0);
|
|
798
|
+
//this.podePesquisar = true;
|
|
799
|
+
this.pesquisaSubject.next('');
|
|
800
|
+
if (this.limpar) {
|
|
801
|
+
this.limpar();
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
verificarPesquisa() {
|
|
805
|
+
//TODO: verificar se o texto corresponde com um item da lista
|
|
806
|
+
this.selecionarComboClick(null);
|
|
807
|
+
}
|
|
808
|
+
async pesquisarClick() {
|
|
809
|
+
/*
|
|
810
|
+
if (this.pesquisaAction != null) {
|
|
811
|
+
this.pesquisaAction();
|
|
812
|
+
}
|
|
813
|
+
*/
|
|
814
|
+
//pesquisaCategoria
|
|
815
|
+
console.log(this.filterFunction, this.url, this.urlTree);
|
|
816
|
+
const modal = await this.modalCtrl.create({
|
|
817
|
+
component: ModelTreeviewComponent,
|
|
818
|
+
componentProps: {
|
|
819
|
+
//campoId: this.campoId,
|
|
820
|
+
//campoPai: this.campoPaiId,
|
|
821
|
+
//campoLabel: this.campoDisplay,
|
|
822
|
+
filterFunction: this.filterFunction,
|
|
823
|
+
empresaSelecionadaId: this.empresa,
|
|
824
|
+
tipo: this.tipo,
|
|
825
|
+
//especifico
|
|
826
|
+
//planoContas: this.planoContas,
|
|
827
|
+
url: this.isEmpty(this.urlTree) ? this.url : this.urlTree
|
|
828
|
+
},
|
|
829
|
+
cssClass: 'my-custom-modal-pesquisa'
|
|
830
|
+
});
|
|
831
|
+
modal.onDidDismiss().then(data => {
|
|
832
|
+
let result = data['data'];
|
|
833
|
+
console.log(result);
|
|
834
|
+
if (result != null && result.Id > 0) {
|
|
835
|
+
this.carregaItemIdParaLista(result.Id);
|
|
836
|
+
}
|
|
837
|
+
});
|
|
838
|
+
modal.present();
|
|
839
|
+
}
|
|
840
|
+
isEmpty(valor) {
|
|
841
|
+
return valor == null || valor == undefined || valor == '';
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
InputPesquisaComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.2", ngImport: i0, type: InputPesquisaComponent, deps: [{ token: i1$1.HttpClient }, { token: i2.ModalController }], target: i0.ɵɵFactoryTarget.Component });
|
|
845
|
+
InputPesquisaComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.1.2", type: InputPesquisaComponent, selector: "kb-input-pesquisa", inputs: { textoPesquisa: "textoPesquisa", max: "max", filterFunction: "filterFunction", selectId: "selectId", campoId: "campoId", campoPaiId: "campoPaiId", campoDisplay: "campoDisplay", tipo: "tipo", change: "change", pesquisaAction: "pesquisaAction", limpar: "limpar", url: "url", urlItem: "urlItem", urlTree: "urlTree", empresa: "empresa", loadInit: "loadInit" }, providers: [{
|
|
846
|
+
provide: NG_VALUE_ACCESSOR,
|
|
847
|
+
useExisting: InputPesquisaComponent,
|
|
848
|
+
multi: true
|
|
849
|
+
}], viewQueries: [{ propertyName: "selectElement", first: true, predicate: ["selectElement"], descendants: true }], usesInheritance: true, ngImport: i0, template: "<div style=\"padding-inline-end: 0px;\">\n <ion-item lines=\"none\" style=\"--background: inherited; --background-focused: transparent; margin-top: 2px;\" [class]=\"itemClass\">\n <ion-label position=\"{{ labelPosition }}\" color=\"{{ labelColor }}\">{{ label }}</ion-label>\n <!-- formControlName=\"{{ campo }}\" -->\n <ion-spinner *ngIf=\"!podePesquisar\"\n style=\"--min-height: 0px !important; margin-inline-end: 5px !important; margin-top: 16px;\" \n slot=\"start\" name=\"lines\"></ion-spinner>\n <!-- (ionBlur)=\"verificarPesquisa()\" -->\n <!-- conflito com click da lista -->\n <ion-input #inputPesquisa\n type=\"{{type}}\" \n [placeholder]=\"placeholder\" \n maxlength=\"{{ max }}\" \n (ionBlur)=\"onBlur($event)\"\n [value]=\"textoPesquisa\" (input)=\"writePesquisa(inputPesquisa.value)\" \n (keyup)=\"showPesquisa($event)\"\n autocomplete=\"off\" style=\"--background:{{ inputBackgroungColor }};\"\n (click)=\"dropDownPesquisa(-1)\"\n [disabled]=\"readonly\" debounce=\"500\"></ion-input>\n <ion-button size=\"small\" slot=\"end\" tabindex=\"-1\"\n style=\"margin-top: 25px; margin-inline-start: 4px !important; --padding-start:2px; --padding-end: 2px;\" fill=\"clear\" color=\"medium\"\n (click)=\"limparClick()\">\n <ion-icon name=\"close-outline\"></ion-icon>\n </ion-button>\n \n <ion-button size=\"small\" slot=\"end\" tabindex=\"-1\"\n style=\"margin-top: 25px; margin-inline-start: 4px !important; --padding-start:2px; --padding-end: 2px;\" fill=\"clear\" color=\"medium\"\n (click)=\"pesquisarClick()\">\n <ion-icon color=\"primary\" name=\"search\"></ion-icon>\n </ion-button>\n \n </ion-item>\n \n <ion-list tabindex=\"-1\" [hidden]=\"!selectElementVisivel || !listaPesquisa || listaPesquisa.length == 0\" class=\"pesquisa-list\" style=\"max-height: 250px; overflow-y: auto;\">\n \n <ion-item tabindex=\"-1\" button *ngFor=\"let item of listaPesquisa\" \n (click)=\"selecionarComboClick(item)\" [id]=\"selectId + 'IonItem' + item['Index']\"\n class=\"pesquisa-item\">\n <!-- {{ item | json}} -->\n <span [class]=\"{'selected-item': item['Selected'] === true}\" [innerHTML]=\"highlight(item[campoDisplay])\"></span>\n </ion-item>\n \n </ion-list>\n \n <!--\n <ion-select interface=\"popover\" #selectElement tabindex=\"-1\" [hidden]=\"!selectElementVisivel\"\n (ionChange)=\"selecionarComboChange($event.target.value)\">\n <ion-select-option *ngFor=\"let item of listaPesquisa\" [value]=\"item[campoId]\" (click)=\"selecionarComboClick(item[campoId])\">\n {{ item[campoDisplay] }}\n </ion-select-option>\n </ion-select>\n -->\n \n <!--\n <select [id]=\"selectId\" #selectElement tabindex=\"-1\" [hidden]=\"!selectElementVisivel\"\n (change)=\"selecionarComboChange($event.target.value)\" class=\"pesquisa-select\">\n <option *ngFor=\"let item of listaPesquisa\" [value]=\"item[campoId]\" (click)=\"selecionarComboClick(item[campoId])\">\n {{ item[campoDisplay] }}\n </option>\n \n </select>\n -->\n \n <div class=\"validation-errors\" *ngIf=\"form\">\n \n <ng-container *ngFor=\"let validation of validation_messages\">\n <div class=\"error-message\"\n *ngIf=\"form.get(formControlName)?.hasError(validation.type) && (form.get(formControlName)?.dirty || form.get(formControlName)?.touched)\">\n • {{ validation.message }}\n </div>\n </ng-container>\n \n </div>\n </div>", styles: ["ion-label{margin-bottom:4px!important;opacity:1!important}ion-input{padding:4px;border:1px solid darkgray;border-radius:4px;width:100%;margin-top:2px;max-height:29px}input:focus{border:1px solid lightblue!important}input:focus ion-label{--color: blue !important}.error-message{font-size:small;color:red;margin-left:15px}.padding{padding:auto}.no-padding{--inner-padding-end: 0px;--padding-start: 0px;--padding-bottom: 0px;--inner-padding-bottom: 0px;height:55px!important}.no-padding-no-height{--inner-padding-end: 0px;--padding-start: 0px;--padding-bottom: 0px;--inner-padding-bottom: 0px}.padding-top{--padding-top: 0px}.pesquisa-select{display:block;position:absolute;top:58px;left:20px;width:100%;z-index:800;font-size:16px;font-family:Roboto,Helvetica Neue,sans-serif;border-bottom-left-radius:5px;border-bottom-right-radius:5px}.pesquisa-select option{overflow-y:hidden}.pesquisa-select option:hover,.pesquisa-select option:checked{background-color:#add8e6}.pesquisa-list{display:block;position:absolute;top:58px;left:20px;width:calc(100% - 50px);z-index:800;border:1px lightgrey solid;border-bottom-left-radius:5px;border-bottom-right-radius:5px;padding:0}.pesquisa-item{--inner-padding-top: 0px;--inner-padding-bottom: 0px;--padding-top: 0px;--padding-bottom: 0px;--min-height: 30px !important;font-size:12px}.pesquisa-item button{padding:0}.selected-item{background-color:#add8e6}\n"], dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i2.IonButton, selector: "ion-button", inputs: ["buttonType", "color", "disabled", "download", "expand", "fill", "href", "mode", "rel", "routerAnimation", "routerDirection", "shape", "size", "strong", "target", "type"] }, { kind: "component", type: i2.IonIcon, selector: "ion-icon", inputs: ["color", "flipRtl", "icon", "ios", "lazy", "md", "mode", "name", "sanitize", "size", "src"] }, { kind: "component", type: i2.IonInput, selector: "ion-input", inputs: ["accept", "autocapitalize", "autocomplete", "autocorrect", "autofocus", "clearInput", "clearOnEdit", "color", "debounce", "disabled", "enterkeyhint", "inputmode", "max", "maxlength", "min", "minlength", "mode", "multiple", "name", "pattern", "placeholder", "readonly", "required", "size", "spellcheck", "step", "type", "value"] }, { kind: "component", type: i2.IonItem, selector: "ion-item", inputs: ["button", "color", "counter", "counterFormatter", "detail", "detailIcon", "disabled", "download", "fill", "href", "lines", "mode", "rel", "routerAnimation", "routerDirection", "shape", "target", "type"] }, { kind: "component", type: i2.IonLabel, selector: "ion-label", inputs: ["color", "mode", "position"] }, { kind: "component", type: i2.IonList, selector: "ion-list", inputs: ["inset", "lines", "mode"] }, { kind: "component", type: i2.IonSpinner, selector: "ion-spinner", inputs: ["color", "duration", "name", "paused"] }, { kind: "directive", type: i2.TextValueAccessor, selector: "ion-input:not([type=number]),ion-textarea,ion-searchbar" }] });
|
|
850
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.2", ngImport: i0, type: InputPesquisaComponent, decorators: [{
|
|
851
|
+
type: Component,
|
|
852
|
+
args: [{ selector: 'kb-input-pesquisa', providers: [{
|
|
853
|
+
provide: NG_VALUE_ACCESSOR,
|
|
854
|
+
useExisting: InputPesquisaComponent,
|
|
855
|
+
multi: true
|
|
856
|
+
}], template: "<div style=\"padding-inline-end: 0px;\">\n <ion-item lines=\"none\" style=\"--background: inherited; --background-focused: transparent; margin-top: 2px;\" [class]=\"itemClass\">\n <ion-label position=\"{{ labelPosition }}\" color=\"{{ labelColor }}\">{{ label }}</ion-label>\n <!-- formControlName=\"{{ campo }}\" -->\n <ion-spinner *ngIf=\"!podePesquisar\"\n style=\"--min-height: 0px !important; margin-inline-end: 5px !important; margin-top: 16px;\" \n slot=\"start\" name=\"lines\"></ion-spinner>\n <!-- (ionBlur)=\"verificarPesquisa()\" -->\n <!-- conflito com click da lista -->\n <ion-input #inputPesquisa\n type=\"{{type}}\" \n [placeholder]=\"placeholder\" \n maxlength=\"{{ max }}\" \n (ionBlur)=\"onBlur($event)\"\n [value]=\"textoPesquisa\" (input)=\"writePesquisa(inputPesquisa.value)\" \n (keyup)=\"showPesquisa($event)\"\n autocomplete=\"off\" style=\"--background:{{ inputBackgroungColor }};\"\n (click)=\"dropDownPesquisa(-1)\"\n [disabled]=\"readonly\" debounce=\"500\"></ion-input>\n <ion-button size=\"small\" slot=\"end\" tabindex=\"-1\"\n style=\"margin-top: 25px; margin-inline-start: 4px !important; --padding-start:2px; --padding-end: 2px;\" fill=\"clear\" color=\"medium\"\n (click)=\"limparClick()\">\n <ion-icon name=\"close-outline\"></ion-icon>\n </ion-button>\n \n <ion-button size=\"small\" slot=\"end\" tabindex=\"-1\"\n style=\"margin-top: 25px; margin-inline-start: 4px !important; --padding-start:2px; --padding-end: 2px;\" fill=\"clear\" color=\"medium\"\n (click)=\"pesquisarClick()\">\n <ion-icon color=\"primary\" name=\"search\"></ion-icon>\n </ion-button>\n \n </ion-item>\n \n <ion-list tabindex=\"-1\" [hidden]=\"!selectElementVisivel || !listaPesquisa || listaPesquisa.length == 0\" class=\"pesquisa-list\" style=\"max-height: 250px; overflow-y: auto;\">\n \n <ion-item tabindex=\"-1\" button *ngFor=\"let item of listaPesquisa\" \n (click)=\"selecionarComboClick(item)\" [id]=\"selectId + 'IonItem' + item['Index']\"\n class=\"pesquisa-item\">\n <!-- {{ item | json}} -->\n <span [class]=\"{'selected-item': item['Selected'] === true}\" [innerHTML]=\"highlight(item[campoDisplay])\"></span>\n </ion-item>\n \n </ion-list>\n \n <!--\n <ion-select interface=\"popover\" #selectElement tabindex=\"-1\" [hidden]=\"!selectElementVisivel\"\n (ionChange)=\"selecionarComboChange($event.target.value)\">\n <ion-select-option *ngFor=\"let item of listaPesquisa\" [value]=\"item[campoId]\" (click)=\"selecionarComboClick(item[campoId])\">\n {{ item[campoDisplay] }}\n </ion-select-option>\n </ion-select>\n -->\n \n <!--\n <select [id]=\"selectId\" #selectElement tabindex=\"-1\" [hidden]=\"!selectElementVisivel\"\n (change)=\"selecionarComboChange($event.target.value)\" class=\"pesquisa-select\">\n <option *ngFor=\"let item of listaPesquisa\" [value]=\"item[campoId]\" (click)=\"selecionarComboClick(item[campoId])\">\n {{ item[campoDisplay] }}\n </option>\n \n </select>\n -->\n \n <div class=\"validation-errors\" *ngIf=\"form\">\n \n <ng-container *ngFor=\"let validation of validation_messages\">\n <div class=\"error-message\"\n *ngIf=\"form.get(formControlName)?.hasError(validation.type) && (form.get(formControlName)?.dirty || form.get(formControlName)?.touched)\">\n • {{ validation.message }}\n </div>\n </ng-container>\n \n </div>\n </div>", styles: ["ion-label{margin-bottom:4px!important;opacity:1!important}ion-input{padding:4px;border:1px solid darkgray;border-radius:4px;width:100%;margin-top:2px;max-height:29px}input:focus{border:1px solid lightblue!important}input:focus ion-label{--color: blue !important}.error-message{font-size:small;color:red;margin-left:15px}.padding{padding:auto}.no-padding{--inner-padding-end: 0px;--padding-start: 0px;--padding-bottom: 0px;--inner-padding-bottom: 0px;height:55px!important}.no-padding-no-height{--inner-padding-end: 0px;--padding-start: 0px;--padding-bottom: 0px;--inner-padding-bottom: 0px}.padding-top{--padding-top: 0px}.pesquisa-select{display:block;position:absolute;top:58px;left:20px;width:100%;z-index:800;font-size:16px;font-family:Roboto,Helvetica Neue,sans-serif;border-bottom-left-radius:5px;border-bottom-right-radius:5px}.pesquisa-select option{overflow-y:hidden}.pesquisa-select option:hover,.pesquisa-select option:checked{background-color:#add8e6}.pesquisa-list{display:block;position:absolute;top:58px;left:20px;width:calc(100% - 50px);z-index:800;border:1px lightgrey solid;border-bottom-left-radius:5px;border-bottom-right-radius:5px;padding:0}.pesquisa-item{--inner-padding-top: 0px;--inner-padding-bottom: 0px;--padding-top: 0px;--padding-bottom: 0px;--min-height: 30px !important;font-size:12px}.pesquisa-item button{padding:0}.selected-item{background-color:#add8e6}\n"] }]
|
|
857
|
+
}], ctorParameters: function () { return [{ type: i1$1.HttpClient }, { type: i2.ModalController }]; }, propDecorators: { textoPesquisa: [{
|
|
858
|
+
type: Input
|
|
859
|
+
}], max: [{
|
|
860
|
+
type: Input
|
|
861
|
+
}], filterFunction: [{
|
|
862
|
+
type: Input
|
|
863
|
+
}], selectId: [{
|
|
864
|
+
type: Input
|
|
865
|
+
}], campoId: [{
|
|
866
|
+
type: Input
|
|
867
|
+
}], campoPaiId: [{
|
|
868
|
+
type: Input
|
|
869
|
+
}], campoDisplay: [{
|
|
870
|
+
type: Input
|
|
871
|
+
}], tipo: [{
|
|
872
|
+
type: Input
|
|
873
|
+
}], selectElement: [{
|
|
874
|
+
type: ViewChild,
|
|
875
|
+
args: ['selectElement', { static: false }]
|
|
876
|
+
}], change: [{
|
|
877
|
+
type: Input
|
|
878
|
+
}], pesquisaAction: [{
|
|
879
|
+
type: Input
|
|
880
|
+
}], limpar: [{
|
|
881
|
+
type: Input
|
|
882
|
+
}], url: [{
|
|
883
|
+
type: Input
|
|
884
|
+
}], urlItem: [{
|
|
885
|
+
type: Input
|
|
886
|
+
}], urlTree: [{
|
|
887
|
+
type: Input
|
|
888
|
+
}], empresa: [{
|
|
889
|
+
type: Input
|
|
890
|
+
}], loadInit: [{
|
|
891
|
+
type: Input
|
|
892
|
+
}] } });
|
|
893
|
+
|
|
894
|
+
class InputValorComponent extends BaseInputComponent {
|
|
895
|
+
constructor() {
|
|
896
|
+
super();
|
|
897
|
+
this.onChange = (data) => { };
|
|
898
|
+
this.onTouch = () => { };
|
|
899
|
+
this.disabled = false;
|
|
900
|
+
this.console = console;
|
|
901
|
+
}
|
|
902
|
+
writeValue(value) {
|
|
903
|
+
//console.log('write value', value);
|
|
904
|
+
this.onChange(value);
|
|
905
|
+
this.data = value;
|
|
906
|
+
}
|
|
907
|
+
registerOnChange(fn) {
|
|
908
|
+
this.onChange = fn;
|
|
909
|
+
}
|
|
910
|
+
registerOnTouched(fn) {
|
|
911
|
+
this.onTouch = fn;
|
|
912
|
+
}
|
|
913
|
+
setDisabledState(isDisabled) {
|
|
914
|
+
this.disabled = this.disabled;
|
|
915
|
+
}
|
|
916
|
+
ngOnInit() { }
|
|
917
|
+
onBlur() {
|
|
918
|
+
if (this.form) {
|
|
919
|
+
this.form.get(this.formControlName)?.markAsTouched();
|
|
920
|
+
}
|
|
921
|
+
if (this.blur) {
|
|
922
|
+
this.blur(this.blurArgs);
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
digitarValor(event) {
|
|
926
|
+
//this.item.vendaunitario = this.utils.converterValorDecimal(this.item.vendaunitario);
|
|
927
|
+
setTimeout(() => {
|
|
928
|
+
if (this.form) {
|
|
929
|
+
this.form.patchValue({
|
|
930
|
+
[this.formControlName]: this.converterValorDecimalMil(this.form.get(this.formControlName)?.value)
|
|
931
|
+
});
|
|
932
|
+
}
|
|
933
|
+
else {
|
|
934
|
+
this.data = this.converterValorDecimalMil(this.data);
|
|
935
|
+
this.writeValue(this.data);
|
|
936
|
+
}
|
|
937
|
+
}, 100);
|
|
938
|
+
return true;
|
|
939
|
+
}
|
|
940
|
+
isEmpty(str) {
|
|
941
|
+
return str == null || str == undefined || str == '';
|
|
942
|
+
}
|
|
943
|
+
converterValorDecimalMil(campo, casas = 2) {
|
|
944
|
+
if (!this.isEmpty(campo)) {
|
|
945
|
+
//console.log('converterValorDecimal');
|
|
946
|
+
//console.log('campo:', campo, ' replaced: ', campo.replace(',', '').replace('.', ''));
|
|
947
|
+
if (campo == '-') {
|
|
948
|
+
return campo;
|
|
949
|
+
}
|
|
950
|
+
let valor = parseFloat(campo.replace(',', '').replace('.', '').replace('.', '').replace('.', ''));
|
|
951
|
+
let valordiv = parseInt("1" + this.stringOfChar("0", casas));
|
|
952
|
+
//valor /= 100;
|
|
953
|
+
console.log(valor, '/', valordiv);
|
|
954
|
+
valor /= valordiv;
|
|
955
|
+
console.log('=', valor);
|
|
956
|
+
return this.decimalToStringMil(valor);
|
|
957
|
+
/*
|
|
958
|
+
var str = valor.toString().replace('.', ',');
|
|
959
|
+
var aStr = str.split(',');
|
|
960
|
+
if (aStr.length == 1) {
|
|
961
|
+
//str += ',00';
|
|
962
|
+
str += ',' + this.stringOfChar('0', casas);
|
|
963
|
+
}
|
|
964
|
+
else {
|
|
965
|
+
//str += this.stringOfChar('0', 2 - aStr[1].length);
|
|
966
|
+
str += this.stringOfChar('0', casas - aStr[1].length);
|
|
967
|
+
}
|
|
968
|
+
return str;
|
|
969
|
+
*/
|
|
970
|
+
}
|
|
971
|
+
else
|
|
972
|
+
return campo;
|
|
973
|
+
}
|
|
974
|
+
decimalToStringMil(number) {
|
|
975
|
+
if (number != null) {
|
|
976
|
+
if (number == 0 || number == '0') {
|
|
977
|
+
return '0,00';
|
|
978
|
+
}
|
|
979
|
+
//console.log(number);
|
|
980
|
+
let numero = number.toFixed(2).split('.');
|
|
981
|
+
numero[0] = numero[0].split(/(?=(?:...)*$)/).join('.');
|
|
982
|
+
return numero.join(',').replace('-.', '-');
|
|
983
|
+
}
|
|
984
|
+
else
|
|
985
|
+
return '';
|
|
986
|
+
}
|
|
987
|
+
stringOfChar(str, tam) {
|
|
988
|
+
var res = '';
|
|
989
|
+
for (var i = 0; i < tam; i++) {
|
|
990
|
+
res += str;
|
|
991
|
+
}
|
|
992
|
+
return res;
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
InputValorComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.2", ngImport: i0, type: InputValorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
996
|
+
InputValorComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.1.2", type: InputValorComponent, selector: "kb-input-valor", providers: [{
|
|
997
|
+
provide: NG_VALUE_ACCESSOR,
|
|
998
|
+
useExisting: InputValorComponent,
|
|
999
|
+
multi: true
|
|
1000
|
+
}], usesInheritance: true, ngImport: i0, template: "<!--\n<div [formGroup]=\"form\">\n-->\n<div>\n <ion-item lines=\"none\" style=\"--background-focused: transparent;\" [class]=\"itemClass\"\n [ngClass]=\"form?.get(formControlName)?.errors && (form?.get(formControlName)?.dirty || form?.get(formControlName)?.touched) ? 'error-shake' : '' \"\n >\n <ion-label position=\"{{ labelPosition }}\">{{ label }}</ion-label>\n <!-- formControlName=\"{{ formControlName }}\" -->\n <ion-input #inputValor\n type=\"text\" \n [placeholder]=\"placeholder\" \n maxlength=\"{{ max }}\"\n (ionBlur)=\"onBlur()\"\n [value]=\"data\"\n (input)=\"writeValue(inputValor.value)\" \n (keypress)=\"digitarValor($event)\"\n [disabled]=\"readonly\"></ion-input>\n </ion-item>\n \n <div class=\"validation-errors\" *ngIf=\"form\">\n \n <ng-container *ngFor=\"let validation of validation_messages\">\n <div class=\"error-message\"\n *ngIf=\"form.get(formControlName)?.hasError(validation.type) && (form.get(formControlName)?.dirty || form.get(formControlName)?.touched)\">\n • {{ validation.message }}\n </div>\n </ng-container>\n \n </div>\n </div>", styles: ["@keyframes shake{0%{transform:translate(20px)}20%{transform:translate(-20px)}40%{transform:translate(10px)}60%{transform:translate(-10px)}80%{transform:translate(4px)}to{transform:translate(0)}}.error-shake ion-label{color:red!important}.error-shake ion-input{animation:shake .4s 1 linear;border:1px solid red!important}.has-focus{border:1px solid var(--ion-color-bluetool)}ion-label{margin-bottom:4px!important;opacity:1!important;overflow:initial!important}ion-input{padding:4px;border:1px solid darkgray;border-radius:4px;width:100%;max-height:27px;text-align:right}.error-message{font-size:small;color:red;margin-left:15px}.item-inner{padding-right:0!important}.no-padding{--inner-padding-end: 0px;--padding-start: 0px;--padding-bottom: 0px;--inner-padding-bottom: 0px;height:39px!important}.label-right ion-label{transform-origin:right top;align-self:flex-end;margin-bottom:4%!important}.align-to-right ion-label{position:relative;left:25%;text-align:end}\n"], dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i2.IonInput, selector: "ion-input", inputs: ["accept", "autocapitalize", "autocomplete", "autocorrect", "autofocus", "clearInput", "clearOnEdit", "color", "debounce", "disabled", "enterkeyhint", "inputmode", "max", "maxlength", "min", "minlength", "mode", "multiple", "name", "pattern", "placeholder", "readonly", "required", "size", "spellcheck", "step", "type", "value"] }, { kind: "component", type: i2.IonItem, selector: "ion-item", inputs: ["button", "color", "counter", "counterFormatter", "detail", "detailIcon", "disabled", "download", "fill", "href", "lines", "mode", "rel", "routerAnimation", "routerDirection", "shape", "target", "type"] }, { kind: "component", type: i2.IonLabel, selector: "ion-label", inputs: ["color", "mode", "position"] }, { kind: "directive", type: i2.TextValueAccessor, selector: "ion-input:not([type=number]),ion-textarea,ion-searchbar" }] });
|
|
1001
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.2", ngImport: i0, type: InputValorComponent, decorators: [{
|
|
1002
|
+
type: Component,
|
|
1003
|
+
args: [{ selector: 'kb-input-valor', providers: [{
|
|
1004
|
+
provide: NG_VALUE_ACCESSOR,
|
|
1005
|
+
useExisting: InputValorComponent,
|
|
1006
|
+
multi: true
|
|
1007
|
+
}], template: "<!--\n<div [formGroup]=\"form\">\n-->\n<div>\n <ion-item lines=\"none\" style=\"--background-focused: transparent;\" [class]=\"itemClass\"\n [ngClass]=\"form?.get(formControlName)?.errors && (form?.get(formControlName)?.dirty || form?.get(formControlName)?.touched) ? 'error-shake' : '' \"\n >\n <ion-label position=\"{{ labelPosition }}\">{{ label }}</ion-label>\n <!-- formControlName=\"{{ formControlName }}\" -->\n <ion-input #inputValor\n type=\"text\" \n [placeholder]=\"placeholder\" \n maxlength=\"{{ max }}\"\n (ionBlur)=\"onBlur()\"\n [value]=\"data\"\n (input)=\"writeValue(inputValor.value)\" \n (keypress)=\"digitarValor($event)\"\n [disabled]=\"readonly\"></ion-input>\n </ion-item>\n \n <div class=\"validation-errors\" *ngIf=\"form\">\n \n <ng-container *ngFor=\"let validation of validation_messages\">\n <div class=\"error-message\"\n *ngIf=\"form.get(formControlName)?.hasError(validation.type) && (form.get(formControlName)?.dirty || form.get(formControlName)?.touched)\">\n • {{ validation.message }}\n </div>\n </ng-container>\n \n </div>\n </div>", styles: ["@keyframes shake{0%{transform:translate(20px)}20%{transform:translate(-20px)}40%{transform:translate(10px)}60%{transform:translate(-10px)}80%{transform:translate(4px)}to{transform:translate(0)}}.error-shake ion-label{color:red!important}.error-shake ion-input{animation:shake .4s 1 linear;border:1px solid red!important}.has-focus{border:1px solid var(--ion-color-bluetool)}ion-label{margin-bottom:4px!important;opacity:1!important;overflow:initial!important}ion-input{padding:4px;border:1px solid darkgray;border-radius:4px;width:100%;max-height:27px;text-align:right}.error-message{font-size:small;color:red;margin-left:15px}.item-inner{padding-right:0!important}.no-padding{--inner-padding-end: 0px;--padding-start: 0px;--padding-bottom: 0px;--inner-padding-bottom: 0px;height:39px!important}.label-right ion-label{transform-origin:right top;align-self:flex-end;margin-bottom:4%!important}.align-to-right ion-label{position:relative;left:25%;text-align:end}\n"] }]
|
|
172
1008
|
}], ctorParameters: function () { return []; } });
|
|
173
1009
|
|
|
174
1010
|
const LibConfigService = new InjectionToken('LibConfig');
|
|
@@ -189,12 +1025,20 @@ class AppprojectComponentsModule {
|
|
|
189
1025
|
AppprojectComponentsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.2", ngImport: i0, type: AppprojectComponentsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
190
1026
|
AppprojectComponentsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.1.2", ngImport: i0, type: AppprojectComponentsModule, declarations: [AppprojectComponentsComponent,
|
|
191
1027
|
InputTextComponent,
|
|
192
|
-
InputFormatComponent
|
|
1028
|
+
InputFormatComponent,
|
|
1029
|
+
InputSelectComponent,
|
|
1030
|
+
InputPesquisaComponent,
|
|
1031
|
+
ModelTreeviewComponent,
|
|
1032
|
+
InputValorComponent], imports: [CommonModule,
|
|
193
1033
|
HttpClientModule,
|
|
194
1034
|
IonicModule,
|
|
195
1035
|
ReactiveFormsModule], exports: [AppprojectComponentsComponent,
|
|
196
1036
|
InputTextComponent,
|
|
197
|
-
InputFormatComponent
|
|
1037
|
+
InputFormatComponent,
|
|
1038
|
+
InputSelectComponent,
|
|
1039
|
+
InputPesquisaComponent,
|
|
1040
|
+
ModelTreeviewComponent,
|
|
1041
|
+
InputValorComponent] });
|
|
198
1042
|
AppprojectComponentsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.1.2", ngImport: i0, type: AppprojectComponentsModule, imports: [CommonModule,
|
|
199
1043
|
HttpClientModule,
|
|
200
1044
|
IonicModule,
|
|
@@ -205,7 +1049,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.2", ngImpor
|
|
|
205
1049
|
declarations: [
|
|
206
1050
|
AppprojectComponentsComponent,
|
|
207
1051
|
InputTextComponent,
|
|
208
|
-
InputFormatComponent
|
|
1052
|
+
InputFormatComponent,
|
|
1053
|
+
InputSelectComponent,
|
|
1054
|
+
InputPesquisaComponent,
|
|
1055
|
+
ModelTreeviewComponent,
|
|
1056
|
+
InputValorComponent
|
|
209
1057
|
],
|
|
210
1058
|
imports: [
|
|
211
1059
|
CommonModule,
|
|
@@ -216,7 +1064,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.2", ngImpor
|
|
|
216
1064
|
exports: [
|
|
217
1065
|
AppprojectComponentsComponent,
|
|
218
1066
|
InputTextComponent,
|
|
219
|
-
InputFormatComponent
|
|
1067
|
+
InputFormatComponent,
|
|
1068
|
+
InputSelectComponent,
|
|
1069
|
+
InputPesquisaComponent,
|
|
1070
|
+
ModelTreeviewComponent,
|
|
1071
|
+
InputValorComponent
|
|
220
1072
|
],
|
|
221
1073
|
schemas: [CUSTOM_ELEMENTS_SCHEMA]
|
|
222
1074
|
}]
|
|
@@ -230,5 +1082,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.2", ngImpor
|
|
|
230
1082
|
* Generated bundle index. Do not edit.
|
|
231
1083
|
*/
|
|
232
1084
|
|
|
233
|
-
export { AppprojectComponentsComponent, AppprojectComponentsModule, AppprojectComponentsService, InputFormatComponent, InputTextComponent, LibConfigService };
|
|
1085
|
+
export { AppprojectComponentsComponent, AppprojectComponentsModule, AppprojectComponentsService, InputFormatComponent, InputPesquisaComponent, InputSelectComponent, InputTextComponent, InputValorComponent, LibConfigService, ModelTreeviewComponent };
|
|
234
1086
|
//# sourceMappingURL=appproject-components.mjs.map
|