Suppression de l'input 'refresh' et refactoring
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Component, AfterContentChecked, Input, ViewChild, OnChanges, OnDestroy, computed, Signal, WritableSignal } from '@angular/core';
|
||||
import { Component, AfterContentChecked, Input, ViewChild, OnChanges, OnDestroy } from '@angular/core';
|
||||
import { CommonModule, DecimalPipe, DatePipe } from '@angular/common';
|
||||
import { UntypedFormBuilder, UntypedFormGroup, Validators, FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||
import { Router, RouterLink } from '@angular/router';
|
||||
@@ -83,7 +83,6 @@ export class JumpTableComponent implements OnChanges, OnDestroy, AfterContentChe
|
||||
|
||||
@Input() title = '';
|
||||
@Input() limit = 0;
|
||||
@Input() refresh = false;
|
||||
@Input() showAdd = false;
|
||||
@Input() isUser = false;
|
||||
@Input()
|
||||
@@ -102,7 +101,6 @@ export class JumpTableComponent implements OnChanges, OnDestroy, AfterContentChe
|
||||
this.loading = true;
|
||||
this._query = this.config;
|
||||
this.runQuery();
|
||||
//this.refresh = false;
|
||||
console.log('ngOnChanges event in jump-table component');
|
||||
}
|
||||
|
||||
@@ -112,11 +110,6 @@ export class JumpTableComponent implements OnChanges, OnDestroy, AfterContentChe
|
||||
}
|
||||
|
||||
ngAfterContentChecked() {
|
||||
//console.log('jump-table ngAfterContentChecked', this.tableRefresh, this._jumpTableService.tableRefresh);
|
||||
/*if (this.tableRefresh != this._jumpTableService.tableRefresh) {
|
||||
this.tableRefresh = this._jumpTableService.tableRefresh;
|
||||
console.log('refresh table', this.tableRefresh, this._jumpTableService.tableRefresh);
|
||||
}*/
|
||||
if (this.jumpRefresh != this._jumpTableService.jumpRefresh) {
|
||||
this.jumpRefresh = this._jumpTableService.jumpRefresh;
|
||||
this.runQuery();
|
||||
@@ -148,8 +141,6 @@ export class JumpTableComponent implements OnChanges, OnDestroy, AfterContentChe
|
||||
this.jumps.paginator = this.paginator;
|
||||
this.jumps.sort = this.sort;
|
||||
this._resetErrors();
|
||||
//this.tableRefresh = !this.tableRefresh;
|
||||
//this._jumpTableService.updateJumpRefresh(this.tableRefresh);
|
||||
},
|
||||
error: (err) => {
|
||||
this.errors = err;
|
||||
@@ -165,19 +156,6 @@ export class JumpTableComponent implements OnChanges, OnDestroy, AfterContentChe
|
||||
});
|
||||
}
|
||||
|
||||
openAddDialog(): void {
|
||||
const dialogRef = this.dialog.open(JumpAddDialogComponent, {
|
||||
width: '70vw',
|
||||
data: this.jump
|
||||
});
|
||||
dialogRef.afterClosed().pipe(take(1))
|
||||
.subscribe(result => {
|
||||
if (result != undefined) {
|
||||
this._onEntry(result);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
openDeleteDialog(jump: Jump): void {
|
||||
const dialogRef = this.dialog.open(JumpDeleteDialogComponent, {
|
||||
width: '60vw',
|
||||
@@ -265,28 +243,6 @@ export class JumpTableComponent implements OnChanges, OnDestroy, AfterContentChe
|
||||
}
|
||||
}
|
||||
|
||||
private _onEntry(entry: NonNullable<unknown>): void {
|
||||
try {
|
||||
this.isSubmitting = true;
|
||||
Object.assign(this.jump, entry);
|
||||
this._jumpsService.save(this.jump)
|
||||
.pipe(take(1))
|
||||
.subscribe({
|
||||
next: (jump) => {
|
||||
this._openSnackBar(`Le saut n°${jump.numero} a été ajouté !`, 'OK');
|
||||
this._resetErrors();
|
||||
this.runQuery();
|
||||
},
|
||||
error: (err) => {
|
||||
this.errors = err;
|
||||
this.isSubmitting = false;
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
|
||||
private _openSnackBar(content: string, title: string) {
|
||||
this.snackBar.open(content, title, {
|
||||
horizontalPosition: <MatSnackBarHorizontalPosition>'end',
|
||||
|
||||
Reference in New Issue
Block a user