Commit f4d14751 by Alex

Funciona el resalte y las coordenadas

parent cfa881d2
...@@ -3,11 +3,11 @@ ...@@ -3,11 +3,11 @@
<div class="seleccion"> <div class="seleccion">
<div class="puntos"> <div class="puntos">
<div class="punto-recogida"> <div class="punto-recogida">
<div>Punto de recogida</div> <div>Punto de recogida: Casilla ({{ puntoDeRecogida?.row }}, {{ puntoDeRecogida?.col }})</div>
<img *ngIf="puntoDeRecogida" [src]="getImagePath(puntoDeRecogida)" /> <img *ngIf="puntoDeRecogida" [src]="getImagePath(puntoDeRecogida)" />
</div> </div>
<div class="punto-entrega"> <div class="punto-entrega">
<div>Punto de entrega</div> <div>Punto de entrega: Casilla ({{ puntoDeEntrega?.row }}, {{ puntoDeEntrega?.col }})</div>
<img *ngIf="puntoDeEntrega" [src]="getImagePath(puntoDeEntrega)" /> <img *ngIf="puntoDeEntrega" [src]="getImagePath(puntoDeEntrega)" />
</div> </div>
</div> </div>
......
...@@ -6,24 +6,26 @@ import { Component } from '@angular/core'; ...@@ -6,24 +6,26 @@ import { Component } from '@angular/core';
styleUrls: ['./crear-pedido-dialog.component.css'] styleUrls: ['./crear-pedido-dialog.component.css']
}) })
export class CrearPedidoDialogComponent { export class CrearPedidoDialogComponent {
puntoDeRecogida: string | null = null; puntoDeRecogida: {id: string, row: number, col: number} | null = null;
puntoDeEntrega: string | null = null; puntoDeEntrega: {id: string, row: number, col: number} | null = null;
highlightedBlock: string | null = null; // Nuevo estado para el bloque resaltado
onBlockSelected(blockId: string): void { onBlockSelected(event: {id: string, row: number, col: number}): void {
if (!this.puntoDeRecogida) { if (!this.puntoDeRecogida) {
this.puntoDeRecogida = blockId; this.puntoDeRecogida = event;
this.highlightedBlock = blockId; // Resaltar el bloque seleccionado como punto de recogida // Actualiza los estilos de resaltado aquí si es necesario
} else if (!this.puntoDeEntrega && this.puntoDeRecogida !== blockId) { } else if (!this.puntoDeEntrega && (this.puntoDeRecogida.row !== event.row || this.puntoDeRecogida.col !== event.col)) {
this.puntoDeEntrega = blockId; this.puntoDeEntrega = event;
// No es necesario resaltar el punto de entrega ya que se confirmará el pedido // Actualiza los estilos de resaltado aquí si es necesario
}
} }
}
getImagePath(id: string): string { // Actualiza getImagePath para trabajar con las coordenadas
// Esta función debe devolver la ruta correcta para tus imágenes basadas en el ID getImagePath(block: {id: string, row: number, col: number}): string {
return `assets/${id}.png`; // Esta función debe devolver la ruta correcta para tus imágenes basadas en el ID
} return `assets/${block.id}.png`;
}
highlightedBlock: string | null = null; // Nuevo estado para el bloque resaltado
resetSelection(): void { resetSelection(): void {
this.puntoDeRecogida = null; this.puntoDeRecogida = null;
...@@ -39,7 +41,7 @@ export class CrearPedidoDialogComponent { ...@@ -39,7 +41,7 @@ export class CrearPedidoDialogComponent {
this.resetSelection(); // Resetear selección tras confirmar el pedido this.resetSelection(); // Resetear selección tras confirmar el pedido
} }
} }
/*
highlightBlock(blockId: string): void { highlightBlock(blockId: string): void {
if (!this.puntoDeRecogida || (this.puntoDeRecogida && blockId !== this.puntoDeRecogida)) { if (!this.puntoDeRecogida || (this.puntoDeRecogida && blockId !== this.puntoDeRecogida)) {
this.highlightedBlock = blockId; this.highlightedBlock = blockId;
...@@ -51,4 +53,5 @@ export class CrearPedidoDialogComponent { ...@@ -51,4 +53,5 @@ export class CrearPedidoDialogComponent {
this.highlightedBlock = null; this.highlightedBlock = null;
} }
} }
*/
} }
<div class="map-container"> <div class="map-container">
<div *ngFor="let row of mapMatrix; let rowIndex = index" class="map-row"> <div *ngFor="let row of mapMatrix; let rowIndex = index" class="map-row">
<div *ngFor="let blockId of row; let colIndex = index" class="map-block" <div *ngFor="let blockId of row; let colIndex = index" class="map-block"
(click)="onBlockClick(blockId)" (click)="onBlockClick(blockId, rowIndex, colIndex)"
(mouseover)="onBlockMouseOver(blockId)" (mouseover)="onBlockMouseOver(blockId)"
(mouseleave)="onBlockMouseLeave(blockId)" (mouseleave)="onBlockMouseLeave(blockId)"
[class.selected-pickup]="selectedPickupId === blockId" [class.selected-pickup]="selectedPickupId === blockId"
[class.selected-delivery]="selectedDeliveryId === blockId"> [class.selected-delivery]="selectedDeliveryId === blockId">
<img [src]="'assets/' + getBlockImagePath(blockId)" [alt]="'Bloque ' + blockId"> <img [src]="'assets/' + getBlockImagePath(blockId)" [alt]="'Bloque ' + blockId">
</div> </div>
</div> </div>
</div> </div>
...@@ -8,7 +8,7 @@ import { Component, OnInit, Output, EventEmitter } from '@angular/core'; ...@@ -8,7 +8,7 @@ import { Component, OnInit, Output, EventEmitter } from '@angular/core';
styleUrls: ['./mapa.component.css'] styleUrls: ['./mapa.component.css']
}) })
export class MapaComponent implements OnInit { export class MapaComponent implements OnInit {
@Output() blockSelected = new EventEmitter<string>(); // Emisor de eventos para la selección de un bloque @Output() blockSelected = new EventEmitter<{id: string, row: number, col: number}>();
mapMatrix: string[][] = []; mapMatrix: string[][] = [];
mapStr: string = "0202000105030705000200041109060110031000000200080101100110000106010701"; mapStr: string = "0202000105030705000200041109060110031000000200080101100110000106010701";
...@@ -31,16 +31,6 @@ export class MapaComponent implements OnInit { ...@@ -31,16 +31,6 @@ export class MapaComponent implements OnInit {
selectedPickupId: string | null = null; selectedPickupId: string | null = null;
selectedDeliveryId: string | null = null; selectedDeliveryId: string | null = null;
// Añade métodos para manejar el evento click
selectPickup(blockId: string): void {
this.selectedPickupId = blockId;
this.blockSelected.emit(blockId);
}
selectDelivery(blockId: string): void {
this.selectedDeliveryId = blockId;
this.blockSelected.emit(blockId);
}
onBlockMouseOver(blockId: string): void { onBlockMouseOver(blockId: string): void {
// Esta función será llamada cuando el mouse pase por encima de un bloque // Esta función será llamada cuando el mouse pase por encima de un bloque
this.blockHovered.emit(blockId); this.blockHovered.emit(blockId);
...@@ -51,15 +41,9 @@ export class MapaComponent implements OnInit { ...@@ -51,15 +41,9 @@ export class MapaComponent implements OnInit {
this.blockUnhovered.emit(blockId); this.blockUnhovered.emit(blockId);
} }
onBlockClick(blockId: string): void { onBlockClick(blockId: string, row: number, col: number): void {
// Esta función será llamada cuando se haga clic en un bloque // Emitir también la fila y la columna
if (!this.selectedPickupId) { this.blockSelected.emit({id: blockId, row, col});
this.selectedPickupId = blockId;
this.selectedDeliveryId = null; // Resetea la selección de entrega si es que se hace clic en otro bloque para recogida
} else if (!this.selectedDeliveryId && this.selectedPickupId !== blockId) {
this.selectedDeliveryId = blockId;
}
this.blockSelected.emit(blockId);
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment