Skip to content

Commit

Permalink
feat: correcciones review
Browse files Browse the repository at this point in the history
  • Loading branch information
salcedogeiner committed Jan 3, 2022
1 parent c672837 commit e23c119
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 31 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
* {
.form-group {
width: 100%;
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,12 @@ export class ReactiveControlComponent implements OnInit {

private buildControl() {
if (this.data) {
// const [parent, value] = [this.control.parent, this.control.value];

switch (this.data.type) {
case 'autocomplete':
this.buildAutocomplete(this.data);
break;
case 'input':
this.buildInput(this.data);
break;
case 'button':
this.buildButton(this.data);
Expand All @@ -57,28 +55,23 @@ export class ReactiveControlComponent implements OnInit {
default:
break;
}
// this.control.setValue(this.control.value || this.data.defaultValue);
this.control.setValidators(this.data.validators);
// this.control.setParent(parent);
// this.control.setValue(value);
this.controlChange.emit(this.control);
}
}

buildAutocomplete(item: ReactiveFormControl) {
// const formControl = new FormControl(item.defaultValue, item.validators);
this.filterList = this.control.valueChanges.pipe(
startWith(''),
map(value => {
item.valueChanges ? item.valueChanges(this.control.parent) : null;
if (item.valueChanges) item.valueChanges(this.control.parent);
return item.optionList.elements(this.control.parent).filter(option => {
const labelKey: string = option[item.optionList.labelKey] || option;
const valueKey: string = value && typeof value === 'object' ? value[item.optionList.labelKey] : value;
const valueKey: string = ( value && typeof value === 'object' ) ? value[item.optionList.labelKey] : value;
return labelKey.toLowerCase().includes(valueKey ? valueKey.toLowerCase() : '');
});
}),
);
// return formControl;
}

focusAutocomplete() {
Expand All @@ -89,12 +82,7 @@ export class ReactiveControlComponent implements OnInit {
}

dislayAutocomplete = (value) => {
// value && typeof value === 'object' ? value[item.optionList.labelKey] : value;
return value && typeof value === 'object' ? value[this.data.optionList.labelKey] : value;
}

buildInput(item: ReactiveFormControl) {
// const formControl = new FormControl(item.defaultValue, item.validators);
return ( value && typeof value === 'object' ) ? value[this.data.optionList.labelKey] : value;
}

buildSelect(item: ReactiveFormControl) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class ArbolContableComponent implements OnInit {
const getters: NbGetters < any, any > = {
dataGetter: (node: any) => node.data || undefined,
childrenGetter: (node: any) =>
!!node.children && !!node.children.length ? node.children : [],
( !!node.children && !!node.children.length ) ? node.children : [],
expandedGetter: (node: any) => !!node.expanded,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,6 @@
</section>
</mat-grid-tile>

<!-- <mat-grid-tile colspan="5" rowspan="1">
<mat-form-field class="form-group" appearance="legacy">
<mat-label>Tercero</mat-label>
<input type="text" matInput placeholder="Tercero" [formControl]="form.controls['Tercero']">
<mat-error *ngIf="form.controls['Tercero'].errors">
{{form.controls['Tercero'].errors.msg || 'ingrese un dato valido' }}
</mat-error>
</mat-form-field>
</mat-grid-tile> -->

<mat-grid-tile colspan="2" rowspan="1">
<section class="form-group" appearance="legacy">
<mat-slide-toggle [formControl]="form.controls['Ajustable']" [color]="'primary'">Ajustable</mat-slide-toggle>
Expand Down Expand Up @@ -149,4 +139,4 @@
<button mat-flat-button color="primary" type="submit">Confirmar</button>
</form>
</nb-card-body>
</nb-card>
</nb-card>
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ export class CuentaContableComponent implements OnInit {

onSubmit() {
if (this.form.valid && this.selectorContable.form.valid) {
// this.acountService.updateNode(this.form.value.Codigo, this.form.value);
const code = `${this.prefix ? this.prefix + '-' : '' }${this.form.value.Codigo}`;
const newAccount = {
...this.form.value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ export class SelectorContableComponent implements OnInit {
public setAcount() {
if (this.account) {
const codigos = this.account.split('-');
// codigos.pop();
this.claseMinima = codigos.length;
codigos.forEach((codigo, index) => {
if (index === 0) {
Expand Down Expand Up @@ -172,7 +171,7 @@ export class SelectorContableComponent implements OnInit {
labelKey: 'Nombre',
},
valueChanges: (parent) => {
parent.get(item.child) && typeof parent.get(item.key).value !== 'object' ? parent.get(item.child).setValue('') : null;
if (parent.get(item.child) && typeof parent.get(item.key).value !== 'object') parent.get(item.child).setValue('');
}
};
}
Expand Down

0 comments on commit e23c119

Please sign in to comment.