Skip to content

Commit

Permalink
Merge branch '3.5.x' of github.com:link-it/GovPay into 3.5.x
Browse files Browse the repository at this point in the history
  • Loading branch information
pintorig committed Nov 22, 2021
2 parents 2c5b51e + e5cc907 commit 7e977a1
Show file tree
Hide file tree
Showing 3 changed files with 162 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,70 @@
</mat-select>
</mat-form-field>
</div>
<!-- <div class="row">
<link-async-filterable-select #filterIbanAcc class="col-12" color="accent"
placeholder="IBAN accredito"
[form-group]="fGroup"
form-ctrl-name="ibanAccredito_ctrl"
[searching]="false"
[required]="true"
[options]="elencoIbanAcc"
(async-keyup)="_keyUp($event, true)"
(option-click)="_onIbanChangeSelectionFilter($event, true)">
<ng-template let-item>
<div class="d-block lh-15">
<span>{{ item.jsonP['iban'] }}</span>
<small class="d-block">{{ getSottotitolo(item) }}</small>
</div>
</ng-template>
</link-async-filterable-select>
</div>
<div class="row">
<link-async-filterable-select #filterIbanApp class="col-12" color="accent"
placeholder="IBAN appoggio"
[form-group]="fGroup"
form-ctrl-name="ibanAppoggio_ctrl"
[searching]="false"
[required]="true"
[options]="elencoIbanApp"
(async-keyup)="_keyUp($event, false)"
(option-click)="_onIbanChangeSelectionFilter($event, false)">
<ng-template let-item>
<div class="d-block lh-15">
<span>{{ item.jsonP['iban'] }}</span>
<small class="d-block">{{ getSottotitolo(item) }}</small>
</div>
</ng-template>
</link-async-filterable-select>
</div> -->
<div class="row">
<mat-form-field class="col-12" color="accent" [formGroup]="fGroup">
<mat-select #iban_acc placeholder="IBAN accredito" formControlName="ibanAccredito_ctrl" (selectionChange)="_onIbanChangeSelection(iban_acc, iban_app, true)" required>
<mat-option *ngFor="let item of ibanAccredito_items" [value]="item.jsonP['iban']">{{item.jsonP['iban']}}{{item.jsonP['postale']?' (Postale)':''}}</mat-option>
<mat-select-trigger>
<span>{{ fGroup.controls['ibanAccredito_ctrl'].value }}</span>
</mat-select-trigger>
<mat-option *ngFor="let item of ibanAccredito_items" [value]="item.jsonP['iban']">
<div class="d-block lh-15">
<span>{{ item.jsonP['iban'] }}</span>
<small class="d-block">{{ getSottotitolo(item) }}</small>
</div>
</mat-option>
</mat-select>
</mat-form-field>
</div>
<div class="row">
<mat-form-field class="col-12" color="accent" [formGroup]="fGroup">
<mat-select #iban_app placeholder="IBAN appoggio" formControlName="ibanAppoggio_ctrl" (selectionChange)="_onIbanChangeSelection(iban_acc, iban_app, false)">
<mat-select-trigger>
<span>{{ fGroup.controls['ibanAppoggio_ctrl'].value }}</span>
</mat-select-trigger>
<mat-option>Nessuno</mat-option>
<mat-option *ngFor="let item of ibanAppoggio_items" [value]="item.jsonP['iban']">{{item.jsonP['iban']}}{{item.jsonP['postale']?' (Postale)':''}}</mat-option>
<mat-option *ngFor="let item of ibanAppoggio_items" [value]="item.jsonP['iban']">
<div class="d-block lh-15">
<span>{{ item.jsonP['iban'] }}</span>
<small class="d-block">{{ getSottotitolo(item) }}</small>
</div>
</mat-option>
</mat-select>
</mat-form-field>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.mat-option {
height: 60px;
line-height: 20px;
}

.lh-15 {
line-height: 1.5;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AfterViewInit, Component, Input, OnInit } from '@angular/core';
import { AfterViewInit, Component, Input, OnInit, ViewChild } from '@angular/core';
import { FormControl, FormGroup, Validators } from '@angular/forms';
import { UtilService } from '../../../../../../services/util.service';
import { Voce } from '../../../../../../services/voce.service';
Expand All @@ -10,13 +10,16 @@ import { GovpayService } from '../../../../../../services/govpay.service';
import { Parameters } from '../../../../../../classes/parameters';
import { Standard } from '../../../../../../classes/view/standard';
import { Dato } from '../../../../../../classes/view/dato';
import { AsyncFilterableSelectComponent } from '../../../../../async-filterable-select/async-filterable-select.component';

@Component({
selector: 'link-entrata-dominio-view',
templateUrl: './entrata-dominio-view.component.html',
styleUrls: ['./entrata-dominio-view.component.scss']
})
export class EntrataDominioViewComponent implements IModalDialog, IFormComponent, OnInit, AfterViewInit {
@ViewChild('filterIbanAcc', { read: AsyncFilterableSelectComponent }) _filterIbanAcc: AsyncFilterableSelectComponent;
@ViewChild('filterIbanApp', { read: AsyncFilterableSelectComponent }) _filterIbanApp: AsyncFilterableSelectComponent;

@Input() fGroup: FormGroup;
@Input() json: any;
Expand All @@ -27,6 +30,8 @@ export class EntrataDominioViewComponent implements IModalDialog, IFormComponent
protected ibanAccredito_items: any[];
protected ibanAppoggio_items: any[];

protected elencoIbanAcc: any[];
protected elencoIbanApp: any[];

protected contabilita_items: any[];

Expand All @@ -36,8 +41,9 @@ export class EntrataDominioViewComponent implements IModalDialog, IFormComponent
}

ngOnInit() {
this.ibanAccredito_items = this.parent.iban_cc.slice(0);
this.ibanAppoggio_items = this.parent.iban_cc.slice(0);
this._getIBAN(); // Issue #422
// this.ibanAccredito_items = this.parent.iban_cc.slice(0);
// this.ibanAppoggio_items = this.parent.iban_cc.slice(0);
this.fGroup.addControl('tipoEntrata_ctrl', new FormControl('', Validators.required));
this.fGroup.addControl('ibanAccredito_ctrl', new FormControl(''));
this.fGroup.addControl('ibanAppoggio_ctrl', new FormControl({ value: '', disabled: true }));
Expand Down Expand Up @@ -102,11 +108,56 @@ export class EntrataDominioViewComponent implements IModalDialog, IFormComponent
}

protected _filteringByIbanSelection(_accreditoSelectedValue: string) {
this.ibanAppoggio_items = this.parent.iban_cc.filter((iban) => {
// this.ibanAppoggio_items = this.parent.iban_cc.filter((iban) => {
this.ibanAppoggio_items = this.ibanAccredito_items.filter((iban) => {
return (iban.jsonP.iban != _accreditoSelectedValue);
});
}

protected _onIbanChangeSelectionFilter(event: any, isAccredito: boolean) {
if (event.original.option && event.original.option.value) {
const ibanObj: any = event.original.option.value;
const ibanValue: string = ibanObj.jsonP.iban;
console.log('ibanValue', ibanValue, event);
if (event.target) {
event.target.value = ibanValue;
event.target.blur();
}
if (isAccredito) {
this._resetIban();
if (ibanValue != '') {
this._filteringByIbanSelection(ibanValue);
this.fGroup.controls['ibanAccredito_ctrl'].setValue(ibanValue);
this.fGroup.controls['ibanAppoggio_ctrl'].enable();
}
} else {
this.fGroup.controls['ibanAppoggio_ctrl'].setValue(ibanValue);
}
} else {
this._resetIban();
}
}

protected _resetIban() {
this.fGroup.controls['ibanAccredito_ctrl'].setValue('');
this.fGroup.controls['ibanAppoggio_ctrl'].setValue('');
this.fGroup.controls['ibanAppoggio_ctrl'].disable();
}

protected _keyUp(event: any, isAccredito: boolean = true) {
this.filterElencoIban(event.target.value, true);
}

protected filterElencoIban(value: string, isAccredito: boolean = true) {
const items = (isAccredito) ? this.ibanAccredito_items : this.ibanAppoggio_items;
this.elencoIbanAcc = items.filter((iban) => {
return (
(iban.jsonP.iban.indexOf(value) != -1) ||
(iban.jsonP.descrizione ? iban.jsonP.descrizione.indexOf(value) != -1 : false)
);
});
}

/**
* Filter by list and key to {label,value} object mapped list
* @param {any[]} fullList
Expand Down Expand Up @@ -143,6 +194,51 @@ export class EntrataDominioViewComponent implements IModalDialog, IFormComponent
return _hasEntry;
}

getSottotitolo(item) {
const values = [];
if (item.jsonP['postale']) {
values.push('Postale');
}
if (item.jsonP['descrizione']) {
values.push(item.jsonP['descrizione']);
}
return values.join(' - ');
}

protected _getIBAN() {
const _service = this.parent._paginatorOptions.iban.base;
this.gps.getDataService(_service).subscribe(
(_response) => {
this.gps.updateSpinner(false);
this.elencoAccreditiAppoggioIban(_response.body.risultati);
},
(error) => {
this.gps.updateSpinner(false);
this.us.onError(error);
});
}

protected elencoAccreditiAppoggioIban(jsonList: any[]) {
let p: Parameters;
const _di = jsonList.map(function (item) {
p = new Parameters();
p.jsonP = item;
p.model = this._mapNewIban(item);
return p;
}, this);
this.ibanAccredito_items = _di.slice(0);
this.ibanAppoggio_items = _di.slice(0);
this.elencoIbanAcc = _di.slice(0);
this.elencoIbanApp = _di.slice(0);
}

protected _mapNewIban(item: any): Standard {
let _std = new Standard();
_std.titolo = new Dato({ value: item.iban });
_std.sottotitolo = item.descrizione ? new Dato({ label: Voce.DESCRIZIONE + ': ', value: item.descrizione }) : new Dato();
return _std;
}

protected _getEntrate() {
let _service = UtilService.URL_ENTRATE; // TODO Chiamare la lista con i non associati
this.gps.getDataService(_service).subscribe(
Expand Down

0 comments on commit 7e977a1

Please sign in to comment.