-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
38832cf
commit eca22b2
Showing
14 changed files
with
220 additions
and
177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 12 additions & 33 deletions
45
...components/chart-statistics-month-supplier/chart-statistics-month-supplier.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,12 @@ | ||
<section class="container"> | ||
<span>{{ title }}</span> | ||
<div class="styleSelect"> | ||
<select name="year" class="form-select form-select-sm" (change)="onYearChange($event)"> | ||
<option *ngFor="let year of years" [value]="year">{{year}}</option> | ||
</select> | ||
<select name="month" class="form-select form-select-sm" [(ngModel)]="selectedMonth" | ||
(change)="OnMonthChange($event)"> | ||
<option *ngFor="let month of months" [value]="month.value">{{month.name}}</option> | ||
</select> | ||
</div> | ||
<div *ngIf="suppliers.length === 0" class="alert alert-secondary mt-2 text-center"> | ||
No hay información disponible para este periodo. Seleccione un mes diferente | ||
</div> | ||
<div class="table-responsive custom-table-responsive" *ngIf="suppliers.length > 0"> | ||
<table class="table table-striped"> | ||
<thead> | ||
<tr> | ||
<th scope="col">#</th> | ||
<th scope="col">Proveedor</th> | ||
<th scope="col">Monto $</th> | ||
</tr> | ||
</thead> | ||
<tbody class="table-group-divider"> | ||
<tr *ngFor="let supplier of suppliers; let i = index"> | ||
<td scope="row">{{i + 1}}</td> | ||
<td>{{supplier.entidad}}</td> | ||
<td>{{supplier.monto | currency:'ARS':'symbol':'1.0-2'}}</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
</section> | ||
<app-chart-table-supplier | ||
[title]="title" | ||
[years]="years" | ||
[months]="months" | ||
[suppliers]="suppliers" | ||
[selectedYear]="selectedYear" | ||
[selectedMonth]="selectedMonth" | ||
[showMonthSelector]="true" | ||
(yearChange)="onYearChange($event)" | ||
(monthChange)="onMonthChange($event)"> | ||
</app-chart-table-supplier> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 9 additions & 28 deletions
37
...p/components/chart-statistics-year-supplier/chart-statistics-year-supplier.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,9 @@ | ||
<section class="container"> | ||
<span>{{ title }}</span> | ||
<select name="yearSupplier" class="form-select form-select-sm ng-pristine ng-invalid ng-touched" | ||
(change)="onYearChange($event)"> | ||
<option *ngFor="let year of years" [value]="year">{{year}}</option> | ||
</select> | ||
<div *ngIf="suppliers.length === 0" class="alert alert-secondary mt-2 text-center"> | ||
No hay información disponible para este periodo. Seleccione un mes diferente | ||
</div> | ||
<div class="table-responsive custom-table-responsive" *ngIf="suppliers.length > 0"> | ||
<table class="table table-striped"> | ||
<thead> | ||
<tr> | ||
<th scope="col">#</th> | ||
<th scope="col">Proveedor</th> | ||
<th scope="col">Monto $</th> | ||
</tr> | ||
</thead> | ||
<tbody class="table-group-divider"> | ||
<tr *ngFor="let supplier of suppliers; let i = index"> | ||
<td scope="row">{{i + 1}}</td> | ||
<td>{{supplier.entidad}}</td> | ||
<td>{{supplier.monto | currency:'ARS':'symbol':'1.0-2'}}</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
</section> | ||
<app-chart-table-supplier | ||
[dataType]="dataType" | ||
[title]="title" | ||
[years]="years" | ||
[suppliers]="suppliers" | ||
[showMonthSelector]="false" | ||
(change)="onYearChange($event)"> | ||
</app-chart-table-supplier> | ||
|
23 changes: 0 additions & 23 deletions
23
...p/components/chart-statistics-year-supplier/chart-statistics-year-supplier.component.scss
This file was deleted.
Oops, something went wrong.
43 changes: 12 additions & 31 deletions
43
...app/components/chart-statistics-year-supplier/chart-statistics-year-supplier.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,30 @@ | ||
import { Component, Input, OnInit } from '@angular/core'; | ||
import { Component, Input } from '@angular/core'; | ||
import { ChartDirectiveDirective } from 'src/app/directives/chart-directive.directive'; | ||
import { ChartService } from 'src/app/services/chart.service'; | ||
|
||
@Component({ | ||
selector: 'app-chart-statistics-year-supplier', | ||
templateUrl: './chart-statistics-year-supplier.component.html', | ||
styleUrls: ['./chart-statistics-year-supplier.component.scss'] | ||
templateUrl: './chart-statistics-year-supplier.component.html' | ||
}) | ||
export class ChartStatisticsYearSupplierComponent extends ChartDirectiveDirective { | ||
@Input() title: string; | ||
@Input() dataType: 'compras' | 'ventas'; | ||
@Input() title: string = ''; | ||
|
||
constructor(protected chartData: ChartService) { | ||
super(chartData); | ||
} | ||
} | ||
|
||
loadChartData(year: number): void { | ||
let chartDataPurchaseSaleSupplier; | ||
const chartDataPurchaseSaleSupplier = this.dataType === 'compras' ? | ||
this.chartData.getChartDataPurchaseAnnualSupplier(year) : | ||
this.chartData.getChartDataSalesAnnualSupplier(year); | ||
|
||
if (this.dataType === 'compras') { | ||
chartDataPurchaseSaleSupplier = this.chartData.getChartDataPurchaseAnnualSupplier(year) | ||
} else if (this.dataType === 'ventas') { | ||
chartDataPurchaseSaleSupplier = this.chartData.getChartDataSalesAnnualSupplier(year) | ||
} | ||
chartDataPurchaseSaleSupplier.subscribe({ | ||
next: (data) => { | ||
if (data && data.labels && data.datasets && data.datasets.length > 0) { | ||
const labels = data.labels; | ||
const datasetData = data.datasets[0].data; | ||
if (labels.length === datasetData.length) { | ||
this.suppliers = labels.map((label, index) => ({ | ||
entidad: label, | ||
monto: datasetData[index], | ||
})); | ||
this.updateChart(data, labels); | ||
} else { | ||
console.log('Desajuste en la longitud de los datos'); | ||
this.suppliers = []; | ||
} | ||
} | ||
}, | ||
error: (error) => { | ||
console.error('Error al cargar los datos', error); | ||
} | ||
next: (data) => this.handleChartData(data), | ||
error: (err) => console.log('Error al cargar datos', err), | ||
}) | ||
} | ||
|
||
isMonthOptional(): boolean { | ||
return true; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/app/components/chart-table-supplier/chart-table-supplier.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<section class="container"> | ||
<span>{{ title }}</span> | ||
<div class="styleSelect"> | ||
<select name="year" class="form-select form-select-sm" (change)="onYearChange($event)"> | ||
<option *ngFor="let year of years" [value]="year">{{year}}</option> | ||
</select> | ||
<select *ngIf="showMonthSelector" name="month" class="form-select form-select-sm" | ||
[(ngModel)]="selectedMonth" (change)="onMonthChange($event)"> | ||
<option *ngFor="let month of months" [value]="month.value">{{month.name}}</option> | ||
</select> | ||
</div> | ||
<div *ngIf="suppliers.length === 0" class="alert alert-secondary mt-2 text-center"> | ||
No hay información disponible para este periodo. Seleccione otro periodo | ||
</div> | ||
<div *ngIf="suppliers.length > 0" class="table-responsive custom-table-responsive"> | ||
<table class="table table-striped"> | ||
<thead> | ||
<tr> | ||
<th scope="col">#</th> | ||
<th scope="col">Proveedor</th> | ||
<th scope="col">Monto $</th> | ||
</tr> | ||
</thead> | ||
<tbody class="table-group-divider"> | ||
<tr *ngFor="let supplier of suppliers; let i = index"> | ||
<td scope="row">{{i + 1}}</td> | ||
<td>{{supplier.entidad}}</td> | ||
<td>{{supplier.monto | currency:'ARS':'symbol':'1.0-2'}}</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
</section> |
File renamed without changes.
42 changes: 42 additions & 0 deletions
42
src/app/components/chart-table-supplier/chart-table-supplier.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { Component, EventEmitter, Input, Output } from '@angular/core'; | ||
import { ChartInterface } from 'src/app/models/chart-interface'; | ||
|
||
|
||
@Component({ | ||
selector: 'app-chart-table-supplier', | ||
templateUrl: './chart-table-supplier.component.html', | ||
styleUrls: ['./chart-table-supplier.component.scss'] | ||
}) | ||
export class ChartTableSupplierComponent { | ||
@Input() title: string = ''; | ||
@Input() suppliers: ChartInterface[] = []; | ||
@Input() years: number[] = []; | ||
@Input() months: {value: number, name: string}[] = []; | ||
@Input() selectedYear: number | null = null; | ||
@Input() selectedMonth: number | null = null; | ||
@Input() showMonthSelector: boolean = true; | ||
|
||
@Output() yearChange = new EventEmitter<number>(); | ||
@Output() monthChange = new EventEmitter<number>(); | ||
|
||
onYearChange($event: Event): void { | ||
const target = $event.target as HTMLSelectElement; | ||
if (target && target.value) { | ||
const year = parseInt(target.value, 10); | ||
this.yearChange.emit(year); | ||
} else { | ||
console.error("Error: El evento no tiene un valor válido", $event); | ||
} | ||
} | ||
|
||
onMonthChange($event: Event): void { | ||
const target = $event.target as HTMLSelectElement; | ||
if (target && target.value) { | ||
const month = parseInt(target.value, 10); | ||
this.monthChange.emit(month); | ||
} else { | ||
console.error("Error: El evento no tiene un valor válido", $event); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.