Skip to content

Commit

Permalink
Refactorizado: Página ver lista - Encabezado
Browse files Browse the repository at this point in the history
- Olvide borrar algunas propiedades que ya no se usan.
- Ahora cuando se carga la página para crear una nueva lista, siempre se mostrara el input para ingresar el nombre de la lista.
  • Loading branch information
nmarulo committed Nov 23, 2024
1 parent 4a76782 commit b77f907
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<app-header>
<ng-container header>
@if (showEdit()) {
@if (showEdit() || isNew()) {
<form class="flex-grow-1 mr-1"
[formGroup]="shoppingListForm"
(submit)="saveShoppingListEvent()">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Component, EventEmitter, input, Input, Output, signal} from '@angular/core';
import {Component, EventEmitter, input, Output, signal} from '@angular/core';
import {HeaderComponent} from '../../../../layout/header/header.component';
import {FormBuilder, FormControl, ReactiveFormsModule} from '@angular/forms';
import {FormBuilder, ReactiveFormsModule} from '@angular/forms';
import {ButtonModule} from 'primeng/button';
import {DialogModule} from 'primeng/dialog';
import {TabViewModule} from 'primeng/tabview';
Expand All @@ -21,13 +21,7 @@ import {FindByIdShoppingListRes} from '@app/models/find-by-id-shopping-list-res'
})
export class HeaderShoppingListComponent {

@Output() saveEvent = new EventEmitter<void>();

@Input() isEditOrNew = false;

@Output() nameShoppingListChange = new EventEmitter<string>();

nameShoppingListFormControl = new FormControl('', {nonNullable: true});
isNew = input<boolean>();

shoppingList = input.required<FindByIdShoppingListRes>();

Expand All @@ -41,11 +35,6 @@ export class HeaderShoppingListComponent {
});

constructor(private formBuilder: FormBuilder) {
this.nameShoppingListFormControl
.valueChanges
.subscribe(value => {
this.nameShoppingListChange.emit(value);
});
}

editEvent() {
Expand Down Expand Up @@ -73,5 +62,5 @@ export class HeaderShoppingListComponent {
this.updateShoppingList.emit(response);
this.showEdit.set(null);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
</ng-container>
<ng-container header>
<app-header-shopping-list [shoppingList]="shoppingListRes()"
(updateShoppingList)="updateShoppingListEvent($event)"/>
(updateShoppingList)="updateShoppingListEvent($event)"
[isNew]="isNew()"/>
</ng-container>
<ng-container content>

Expand Down

0 comments on commit b77f907

Please sign in to comment.