diff --git a/frontend/app/class/monitoring-object.ts b/frontend/app/class/monitoring-object.ts index b05388154..2ac6e7356 100644 --- a/frontend/app/class/monitoring-object.ts +++ b/frontend/app/class/monitoring-object.ts @@ -84,9 +84,9 @@ export class MonitoringObject extends MonitoringObjectBase { .getObject(this.moduleCode, this.objectType, this.id, depth); }), mergeMap((postData) => { - if (!bFromCache) { - this._objService.setCache(this, postData); - } + // if (!bFromCache) { + // this._objService.setCache(this, postData); + // } return this.init(postData); }) ); diff --git a/frontend/app/components/monitoring-datatable/monitoring-datatable.component.html b/frontend/app/components/monitoring-datatable/monitoring-datatable.component.html index 022b91733..2c2db3942 100644 --- a/frontend/app/components/monitoring-datatable/monitoring-datatable.component.html +++ b/frontend/app/components/monitoring-datatable/monitoring-datatable.component.html @@ -59,7 +59,7 @@

Attention

class="nav-link link cell-link" (click)="canCreateChild ? child0.navigateToAddChildren(null, row.id, obj.siteId) : null" [matTooltip]=" - canCreateChild ? 'Ajouter' + child0.child0().labelArtUndef(true) : toolTipNotAllowed + canCreateChild ? 'Ajouter ' + child0.child0().labelArtUndef(true) : toolTipNotAllowed " > Attention class="nav-link link cell-link" (click)="row.cruved['U'] ? child0.navigateToDetail(row.id, true) : null" [matTooltip]=" - row.cruved['U'] ? 'Editer' + child0.template.label_art_def : toolTipNotAllowed + row.cruved['U'] ? 'Editer ' + child0.template.label_art_def : toolTipNotAllowed " > Attention class="nav-link link cell-link" (click)="row.cruved['D'] ? alertMessage(row) : null" [matTooltip]=" - row.cruved['D'] ? 'Supprimer' + child0.template.label_art_def : toolTipNotAllowed + row.cruved['D'] ? 'Supprimer ' + child0.template.label_art_def : toolTipNotAllowed " > (); + @Output() onDeleteRow = new EventEmitter(); @Output() bEditChanged = new EventEmitter(); @@ -243,12 +243,18 @@ export class MonitoringDatatableComponent implements OnInit { } onDelete(row) { - this._commonService.regularToaster('info', this.msgToaster('Suppression')); - this._objectService.changeDisplayingDeleteModal(this.bDeleteModal); - this._objectService.changeSelectRow({ rowSelected: row, objectType: this.child0.objectType }); - this._objectService.currentDeleteModal.subscribe( - (deletedModal) => (this.bDeleteModal = deletedModal) - ); + this._monitoring + .dataMonitoringObjectService() + .deleteObject(this.obj.moduleCode, this.child0.objectType, row.id) + .subscribe(() => { + this._commonService.regularToaster('info', this.msgToaster('Suppression')); + + this.onDeleteRow.emit({ + rowSelected: row, + objectType: this.child0.objectType, + }); + this.bDeleteModal = false; + }); } alertMessage(row) { diff --git a/frontend/app/components/monitoring-lists/monitoring-lists.component.html b/frontend/app/components/monitoring-lists/monitoring-lists.component.html index 64824234d..0df60da33 100644 --- a/frontend/app/components/monitoring-lists/monitoring-lists.component.html +++ b/frontend/app/components/monitoring-lists/monitoring-lists.component.html @@ -48,15 +48,16 @@
diff --git a/frontend/app/components/monitoring-lists/monitoring-lists.component.ts b/frontend/app/components/monitoring-lists/monitoring-lists.component.ts index fbd6fb21e..d8736fa58 100644 --- a/frontend/app/components/monitoring-lists/monitoring-lists.component.ts +++ b/frontend/app/components/monitoring-lists/monitoring-lists.component.ts @@ -21,12 +21,18 @@ export class MonitoringListComponent implements OnInit { @Input() currentUser; @Input() filters; @Output() filtersChange: EventEmitter = new EventEmitter(); + + @Input() forceReload; + @Output() forceReloadChange = new EventEmitter(); + @Input() objectListType: string; @Output() objectListTypeChange: EventEmitter = new EventEmitter(); @Input() selectedObject; @Output() selectedObjectChange: EventEmitter = new EventEmitter(); + @Output() onDeleteRow: EventEmitter = new EventEmitter(); + activetab: string; nbVisibleRows: Record = {}; frontendModuleMonitoringUrl; @@ -104,6 +110,10 @@ export class MonitoringListComponent implements OnInit { this.nbVisibleRows[type] = nb_row; } + onDeleteRowChange(event) { + this.onDeleteRow.emit(event); + } + changeActiveTab(typeObject, tab) { this.activetab = this.children0Array[typeObject['index']]; // Réinitialisation des données selectés @@ -135,6 +145,13 @@ export class MonitoringListComponent implements OnInit { case 'obj': this.initDataTable(); break; + case 'forceReload': + if (cur == true) { + this.initDataTable(); + this.forceReload = false; + this.forceReloadChange.emit(false); + } + break; } } } diff --git a/frontend/app/components/monitoring-object/monitoring-object.component.html b/frontend/app/components/monitoring-object/monitoring-object.component.html index 0b398cd0b..3e44ad963 100644 --- a/frontend/app/components/monitoring-object/monitoring-object.component.html +++ b/frontend/app/components/monitoring-object/monitoring-object.component.html @@ -32,9 +32,11 @@

Chargement en cours

- diff --git a/frontend/app/components/monitoring-object/monitoring-object.component.ts b/frontend/app/components/monitoring-object/monitoring-object.component.ts index 4550300e8..93c45eab2 100644 --- a/frontend/app/components/monitoring-object/monitoring-object.component.ts +++ b/frontend/app/components/monitoring-object/monitoring-object.component.ts @@ -42,6 +42,7 @@ export class MonitoringObjectComponent implements OnInit { pre_filters: Object = {}; selectedObject: Object = undefined; objectListType: string; + forceReload: boolean = false; backendUrl: string; frontendModuleMonitoringUrl: string; @@ -125,7 +126,6 @@ export class MonitoringObjectComponent implements OnInit { (!this.obj.id && !!this.obj.parentId); this.bLoadingModal = false; // fermeture du modal this.obj.bIsInitialized = true; // obj initialisé - this.evenListnerTable(); }); } @@ -279,37 +279,10 @@ export class MonitoringObjectComponent implements OnInit { this.getModuleSet().subscribe(); } - onDeleteFromTable(event) { - return this._objService - .dataMonitoringObjectService() - .deleteObject(this.obj.moduleCode, event.objectType, event.rowSelected.id); - } - - evenListnerTable() { - const $displayModal = this._evtObjService.currentDeleteModal; - const $rowSelected = this._evtObjService.currentRowSelected; - $displayModal - .pipe( - distinctUntilChanged((prev, curr) => prev === curr), - tap((displayModal) => { - this.bDeleteModal = displayModal; - }), - concatMap(() => { - return $rowSelected; - }), - concatMap((rowSelected) => { - return this.onDeleteFromTable(rowSelected).pipe( - distinctUntilChanged((prev, curr) => prev.rowSelected === curr.rowSelected) - ); - }), - catchError((err) => { - console.log(err); - this._evtObjService.changeDisplayingDeleteModal(false); - return of(null); - }) - ) - .subscribe((deletedObj) => { - this._evtObjService.changeDisplayingDeleteModal(false); - }); + onDeleteRowChange(event) { + this.getDataObject().subscribe((obj) => { + this.forceReload = true; + this.onObjChanged(obj); + }); } } diff --git a/frontend/app/services/data-monitoring-object.service.ts b/frontend/app/services/data-monitoring-object.service.ts index 7b73bc433..23c1ab7ad 100644 --- a/frontend/app/services/data-monitoring-object.service.ts +++ b/frontend/app/services/data-monitoring-object.service.ts @@ -109,8 +109,9 @@ export class DataMonitoringObjectService { * @param objectType le type de l'objet (site, visit, observation, ...) * @param id l'identifiant de l'objet */ - deleteObject(moduleCode, objectType, id) { + deleteObject(moduleCode, objectType, id): Observable { const url = this.urlMonitoring('object', moduleCode, objectType, id); + return this._cacheService.request('delete', url); } diff --git a/frontend/app/services/object.service.ts b/frontend/app/services/object.service.ts index 119b2b73d..1647cf9ba 100644 --- a/frontend/app/services/object.service.ts +++ b/frontend/app/services/object.service.ts @@ -25,12 +25,6 @@ export class ObjectService { private dataListOption = new ReplaySubject(1); currentListOption = this.dataListOption.asObservable(); - private rowSelected = new ReplaySubject(1); - currentRowSelected = this.rowSelected.asObservable(); - - private deleteModal = new ReplaySubject(1); - currentDeleteModal = this.deleteModal.asObservable(); - constructor() { let storedObjectType = localStorage.getItem('storedObjectType'); let storedObjectTypeParent = localStorage.getItem('storedObjectTypeParent'); @@ -85,12 +79,4 @@ export class ObjectService { changeListOption(newListOption: SelectObject[]) { this.dataListOption.next(newListOption); } - - changeSelectRow(rowSelected) { - this.rowSelected.next(rowSelected); - } - - changeDisplayingDeleteModal(isModal: boolean) { - this.deleteModal.next(isModal); - } }