Skip to content

Commit

Permalink
feat(4ps): inline edit
Browse files Browse the repository at this point in the history
  • Loading branch information
develite98 committed Jan 3, 2024
1 parent cb071e0 commit d6c73d2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@
[rowDragManaged]="true"
[rowSelection]="'multiple'"
[suppressMoveWhenRowDragging]="true"
(cellValueChanged)="cellValueChanged($event)"
(gridReady)="onGridReady($event)"
(selectionChanged)="onSelectionChanged()"
style="width: 100%; height: 100%">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@ import { TuiReorderModule, TuiTableModule } from '@taiga-ui/addon-table';
import { TuiDestroyService } from '@taiga-ui/cdk';
import { TuiCheckboxModule, TuiPaginationModule } from '@taiga-ui/kit';
import { AgGridModule } from 'ag-grid-angular';
import { ColDef, GridApi, GridReadyEvent } from 'ag-grid-community';
import {
CellValueChangedEvent,
ColDef,
GridApi,
GridReadyEvent,
} from 'ag-grid-community';
import {
Observable,
Subject,
Expand Down Expand Up @@ -115,6 +120,7 @@ export class DatabaseDataComponent
sortable: false,
headerCheckboxSelection: true,
checkboxSelection: true,
editable: true,
headerComponentParams: {
displayName: '',
columnType: 'check',
Expand All @@ -136,6 +142,7 @@ export class DatabaseDataComponent
public readonly defaultColDef: ColDef = {
sortable: true,
resizable: true,
editable: true,
width: 250,
};

Expand Down Expand Up @@ -200,6 +207,22 @@ export class DatabaseDataComponent
});
}

public cellValueChanged(event: CellValueChangedEvent) {
const data = event.data as MixDynamicData;
Object.keys(data).forEach((key) => {
if (data[key] === null) {
delete data[key];
}
});

this.mixApi.databaseApi
.saveData(this.dbSysName, data.id ?? -1, data)
.pipe(toastObserverProcessing(this.toast))
.subscribe((result) => {
this.store.updateData(event.rowIndex || 0, result as MixDynamicData);
});
}

public onSelectionChanged() {
this.selectedItems = this.gridApi.getSelectedRows();
}
Expand Down

1 comment on commit d6c73d2

@vercel
Copy link

@vercel vercel bot commented on d6c73d2 Jan 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.