-
-
Notifications
You must be signed in to change notification settings - Fork 18
Feature/row edit send touched fields only #1733
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
7e39bb6
9cf5d83
ef35a9c
3a39678
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,7 @@ import { Title } from '@angular/platform-browser'; | |
| import { ActivatedRoute, Router, RouterModule } from '@angular/router'; | ||
| import JsonURL from '@jsonurl/jsonurl'; | ||
| import JSON5 from 'json5'; | ||
| import { isEqual } from 'lodash-es'; | ||
| import { DynamicModule } from 'ng-dynamic-component'; | ||
| import { SignalComponentIoModule } from 'ng-dynamic-component/signal-component-io'; | ||
| import { defaultTimestampValues, recordEditTypes, timestampTypes, UIwidgets } from 'src/app/consts/record-edit-types'; | ||
|
|
@@ -74,6 +75,7 @@ export class DbTableRowEditComponent implements OnInit { | |
| public tableName: string | null = null; | ||
| public dispalyTableName: string | null = null; | ||
| public tableRowValues: Record<string, any>; | ||
| private touchedFields = new Set<string>(); | ||
| public tableRowStructure: object; | ||
| public tableRowRequiredValues: object; | ||
| public identityColumn: string; | ||
|
|
@@ -612,6 +614,9 @@ export class DbTableRowEditComponent implements OnInit { | |
|
|
||
| updateField = (updatedValue: any, field: string) => { | ||
| const existing = this.tableRowValues[field]; | ||
| if (!isEqual(updatedValue, existing)) { | ||
| this.touchedFields.add(field); | ||
| } | ||
|
Comment on lines
615
to
+619
|
||
| if ( | ||
| typeof updatedValue === 'object' && | ||
| updatedValue !== null && | ||
|
|
@@ -631,8 +636,10 @@ export class DbTableRowEditComponent implements OnInit { | |
| } | ||
| }; | ||
|
|
||
| getFormattedUpdatedRow = () => { | ||
| let updatedRow = { ...this.tableRowValues }; | ||
| getFormattedUpdatedRow = (onlyTouched: boolean = false) => { | ||
| let updatedRow = onlyTouched | ||
| ? Object.fromEntries(Object.entries(this.tableRowValues).filter(([key]) => this.touchedFields.has(key))) | ||
| : { ...this.tableRowValues }; | ||
|
|
||
| //crutch, format datetime fields | ||
| //if no one edit manually datetime field, we have to remove '.000Z', cuz mysql return this format but it doesn't record it | ||
|
|
@@ -756,12 +763,13 @@ export class DbTableRowEditComponent implements OnInit { | |
| updateRow(continueEditing: boolean) { | ||
| this.submitting = true; | ||
|
|
||
| const formattedUpdatedRow = this.getFormattedUpdatedRow(); | ||
| const formattedUpdatedRow = this.getFormattedUpdatedRow(true); | ||
|
|
||
| this._tableRow | ||
| .updateTableRow(this.connectionID, this.tableName, this.keyAttributesFromURL, formattedUpdatedRow) | ||
| .subscribe( | ||
| (res) => { | ||
| this.touchedFields.clear(); | ||
| this.ngZone.run(() => { | ||
| if (continueEditing) { | ||
| if (this.isPrimaryKeyUpdated) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These comments describe the old behavior (“FK/Binary widgets … re-emit their current value on ngOnInit”), but this PR removes those init-time emits. The comment block should be updated to reflect the current intent (e.g., regression test ensures untouched FK/binary fields are not included in the update payload) so future readers don’t chase a behavior that no longer exists.