Edit and delete
This commit is contained in:
parent
5f7968a756
commit
ac266e77ce
@ -4,6 +4,7 @@ import {FormsModule} from '@angular/forms';
|
||||
import {ShowService} from '../../services/show.service';
|
||||
import {Observable} from 'rxjs';
|
||||
import {AsyncPipe} from '@angular/common';
|
||||
import {deleteDoc, doc, Firestore, updateDoc} from '@angular/fire/firestore';
|
||||
|
||||
@Component({
|
||||
selector: 'app-show-list',
|
||||
@ -17,6 +18,8 @@ import {AsyncPipe} from '@angular/common';
|
||||
})
|
||||
export class ShowListComponent {
|
||||
showService: ShowService = inject(ShowService);
|
||||
fireStore: Firestore = inject(Firestore);
|
||||
private seriesCollection = 'table_show';
|
||||
shows: Observable<Show[]> = this.showService.getShows();
|
||||
|
||||
@Output() selectedShow = new EventEmitter<Show>();
|
||||
@ -37,13 +40,13 @@ export class ShowListComponent {
|
||||
}
|
||||
|
||||
updateShow(show: Show) {
|
||||
// this.shows = this.shows.filter(s => s !== show);
|
||||
// this.shows.push(show);
|
||||
// this.shows.sort((a, b) => (a.uid ?? 0) - (b.uid ?? 0));
|
||||
const showDocRef = doc(this.fireStore, `${this.seriesCollection}/${show.uid}`);
|
||||
updateDoc(showDocRef, {id: show.uid, title: show.title,});
|
||||
}
|
||||
|
||||
delete(show: Show) {
|
||||
// this.shows = this.shows.filter(s => s !== show);
|
||||
const showDocRef = doc(this.fireStore, `${this.seriesCollection}/${show.uid}`);
|
||||
deleteDoc(showDocRef);
|
||||
}
|
||||
|
||||
isToEdit(show: Show): boolean {
|
||||
|
Reference in New Issue
Block a user