Просмотр исходного кода

fix(admin-ui): Fix critical FacetValue deletion issue

This is an important fix: previously, after deleting a FacetValue from the Facet detail page, the
remaining values _after_ the deleted value would get out of sync with the form values. This then
made it possible to accidentally delete the wrong value in subsequent delete operations.
Michael Bromley 3 лет назад
Родитель
Сommit
1e443e2b27

+ 4 - 0
packages/admin-ui/src/lib/catalog/src/components/facet-detail/facet-detail.component.ts

@@ -244,6 +244,10 @@ export class FacetDetailComponent
             )
             .subscribe(
                 () => {
+                    const valuesFormArray = this.detailForm.get('values') as FormArray | null;
+                    if (valuesFormArray) {
+                        valuesFormArray.removeAt(index);
+                    }
                     this.notificationService.success(_('common.notify-delete-success'), {
                         entity: 'FacetValue',
                     });

+ 7 - 0
packages/admin-ui/src/lib/core/src/data/data.module.ts

@@ -39,6 +39,13 @@ export function createApollo(
                     },
                 },
             },
+            Facet: {
+                fields: {
+                    values: {
+                        merge: (existing, incoming) => incoming,
+                    },
+                },
+            },
         },
     });
     apolloCache.writeQuery({