Skip to content

Commit d268681

Browse files
[DSC-1735] fix cherry-pick conflicts
1 parent 88ac610 commit d268681

2 files changed

Lines changed: 26 additions & 29 deletions

File tree

src/app/shared/form/builder/ds-dynamic-form-ui/ds-dynamic-form-control-container.component.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,7 @@ import { APP_CONFIG, AppConfig } from '../../../../../config/app-config.interfac
123123
import { itemLinksToFollow } from '../../../utils/relation-query.utils';
124124
import { DynamicConcatModel } from './models/ds-dynamic-concat.model';
125125
import { Metadata } from '../../../../core/shared/metadata.utils';
126-
import { DsDynamicMarkdownComponent } from './models/markdown/dynamic-markdown.component';
127-
import { DYNAMIC_FORM_CONTROL_TYPE_MARKDOWN } from './models/markdown/dynamic-markdown.model';
128-
import { DynamicLinkModel } from './models/ds-dynamic-link.model';
126+
import { DynamicLinkModel } from "./models/ds-dynamic-link.model";
129127

130128
export function dsDynamicFormControlMapFn(model: DynamicFormControlModel): Type<DynamicFormControl> | null {
131129
switch (model.type) {
@@ -188,9 +186,6 @@ export function dsDynamicFormControlMapFn(model: DynamicFormControlModel): Type<
188186
case DYNAMIC_FORM_CONTROL_TYPE_CUSTOM_SWITCH:
189187
return CustomSwitchComponent;
190188

191-
case DYNAMIC_FORM_CONTROL_TYPE_MARKDOWN:
192-
return DsDynamicMarkdownComponent;
193-
194189
default:
195190
return null;
196191
}
@@ -503,6 +498,7 @@ export class DsDynamicFormControlContainerComponent extends DynamicFormControlCo
503498
* Unsubscribe from all subscriptions
504499
*/
505500
ngOnDestroy(): void {
501+
super.ngOnDestroy();
506502
this.subs
507503
.filter((sub) => hasValue(sub))
508504
.forEach((sub) => sub.unsubscribe());

src/app/shared/form/form.component.ts

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ export class FormComponent implements OnDestroy, OnInit {
5555
@Input() displaySubmit = true;
5656

5757
/**
58-
* A boolean that indicate if to display form's cancel button
58+
* A boolean that indicate if to display form's reset button
5959
*/
60-
@Input() displayCancel = true;
60+
@Input() displayReset = true;
6161

6262
/**
6363
* A String that indicate the entity type of the item
@@ -82,7 +82,7 @@ export class FormComponent implements OnDestroy, OnInit {
8282
/**
8383
* i18n key for the cancel button
8484
*/
85-
@Input() cancelLabel = 'form.cancel';
85+
@Input() resetLabel = 'form.reset';
8686

8787
/**
8888
* An array of DynamicFormControlModel type
@@ -350,7 +350,6 @@ export class FormComponent implements OnDestroy, OnInit {
350350
removeItem($event, arrayContext: DynamicFormArrayModel, index: number): void {
351351
const formArrayControl = this.formGroup.get(this.formBuilderService.getPath(arrayContext)) as UntypedFormArray;
352352
const event = this.getEvent($event, arrayContext, index, 'remove');
353-
console.log(formArrayControl, event);
354353
if (this.formBuilderService.isQualdropGroup(event.model as DynamicFormControlModel) || this.isInlineGroupForm) {
355354
// In case of qualdrop value or inline-group remove event must be dispatched before removing the control from array
356355
this.removeArrayItem.emit(event);
@@ -434,25 +433,27 @@ export class FormComponent implements OnDestroy, OnInit {
434433
const metadataKeys = hasValue(metadataFields) ? Object.keys(metadataFields) : [];
435434
const formKeys = hasValue(this.formGroup.value) ? Object.keys(this.formGroup.value).map(key => key.replace('_array', '')) : [];
436435

437-
formKeys.forEach((key) => {
438-
const innerObjectKeys = (Object.keys(this.formGroup.value[key] ?? {} ) as any[]).map((oldKey) => oldKey.replaceAll('_', '.'));
439-
const filteredKeys = innerObjectKeys.filter(innerKey => metadataKeys.includes(innerKey));
440-
const oldValue = this.formGroup.value[key];
441-
442-
if (filteredKeys.length > 0) {
443-
filteredKeys.forEach((oldValueKey) => {
444-
const newValue = {...oldValue};
445-
const formattedKey = (oldValueKey as any).replaceAll('.', '_');
446-
const patchValue = {};
447-
448-
newValue[formattedKey] = metadataFields[oldValueKey][0];
449-
patchValue[key] = newValue;
450-
451-
if (!isEqual(oldValue[oldValueKey], newValue[oldValueKey])) {
452-
this.formGroup.patchValue(patchValue);
453-
}
454-
});
455-
}
436+
formKeys
437+
.filter((key) => isNotEmpty(this.formGroup.value[key]))
438+
.forEach((key) => {
439+
const innerObjectKeys = (Object.keys(this.formGroup.value[key] ?? {} ) as any[]).map((oldKey) => oldKey.replaceAll('_', '.'));
440+
const filteredKeys = innerObjectKeys.filter(innerKey => metadataKeys.includes(innerKey));
441+
const oldValue = this.formGroup.value[key];
442+
443+
if (filteredKeys.length > 0) {
444+
filteredKeys.forEach((oldValueKey) => {
445+
const newValue = {...oldValue};
446+
const formattedKey = (oldValueKey as any).replaceAll('.', '_');
447+
const patchValue = {};
448+
449+
newValue[formattedKey] = metadataFields[oldValueKey][0];
450+
patchValue[key] = newValue;
451+
452+
if (!isEqual(oldValue[oldValueKey], newValue[oldValueKey])) {
453+
this.formGroup.patchValue(patchValue);
454+
}
455+
});
456+
}
456457
});
457458
}
458459
}

0 commit comments

Comments
 (0)