Commit 9af2b67b authored by LAVENIER's avatar LAVENIER
Browse files

[fix] Table: When deleting a newly created row, to not propagate to dataService

parent a08911b9
import { TableDataSource, TableElement, ValidatorService } from '@e-is/ngx-material-table';
import { BehaviorSubject, Observable, Subject } from 'rxjs';
import { Entity, IEntity } from '../services/model/entity.model';
import { ErrorCodes } from '../services/errors';
import { catchError, debounceTime, map, takeUntil } from 'rxjs/operators';
import { Directive, OnDestroy } from '@angular/core';
import { SortDirection } from '@angular/material/sort';
import { CollectionViewer } from '@angular/cdk/collections';
import { TableDataSourceOptions } from '@e-is/ngx-material-table/src/app/ngx-material-table/table-data-source';
import { EntitiesServiceWatchOptions, IEntitiesService, LoadResult } from '../../shared/services/entity-service.class';
import { firstFalsePromise, firstNotNilPromise } from '../../shared/observables';
import { isNotEmptyArray, isNotNil, removeEnd, toBoolean } from '../../shared/functions';
import {TableDataSource, TableElement, ValidatorService} from '@e-is/ngx-material-table';
import {BehaviorSubject, Observable, Subject} from 'rxjs';
import {Entity, IEntity} from '../services/model/entity.model';
import {ErrorCodes} from '../services/errors';
import {catchError, debounceTime, map, takeUntil} from 'rxjs/operators';
import {Directive, OnDestroy} from '@angular/core';
import {SortDirection} from '@angular/material/sort';
import {CollectionViewer} from '@angular/cdk/collections';
import {TableDataSourceOptions} from '@e-is/ngx-material-table/src/app/ngx-material-table/table-data-source';
import {EntitiesServiceWatchOptions, IEntitiesService, LoadResult} from '../../shared/services/entity-service.class';
import {firstFalsePromise, firstNotNilPromise} from '../../shared/observables';
import {isNotEmptyArray, isNotNil, removeEnd, toBoolean} from '../../shared/functions';
export declare interface AppTableDataServiceOptions<O extends EntitiesServiceWatchOptions = EntitiesServiceWatchOptions> extends EntitiesServiceWatchOptions {
......@@ -294,6 +294,11 @@ export class EntitiesTableDataSource<
}
delete(id: number): void {
// If new row: not need to propagate to the dataService
if (id === -1) {
return super.delete(id);
}
const row = this.getRow(id);
if (!row) {
console.error(`[table-datasource] Row to delete with id=${id} not found`);
......
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 to comment