Start with one option
This commit is contained in:
parent
29a142dee4
commit
e39c3b22fb
@ -3460,14 +3460,14 @@
|
|||||||
<source>Create new custom field</source>
|
<source>Create new custom field</source>
|
||||||
<context-group purpose="location">
|
<context-group purpose="location">
|
||||||
<context context-type="sourcefile">src/app/components/common/edit-dialog/custom-field-edit-dialog/custom-field-edit-dialog.component.ts</context>
|
<context context-type="sourcefile">src/app/components/common/edit-dialog/custom-field-edit-dialog/custom-field-edit-dialog.component.ts</context>
|
||||||
<context context-type="linenumber">52</context>
|
<context context-type="linenumber">53</context>
|
||||||
</context-group>
|
</context-group>
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
<trans-unit id="8751213029607178010" datatype="html">
|
<trans-unit id="8751213029607178010" datatype="html">
|
||||||
<source>Edit custom field</source>
|
<source>Edit custom field</source>
|
||||||
<context-group purpose="location">
|
<context-group purpose="location">
|
||||||
<context context-type="sourcefile">src/app/components/common/edit-dialog/custom-field-edit-dialog/custom-field-edit-dialog.component.ts</context>
|
<context context-type="sourcefile">src/app/components/common/edit-dialog/custom-field-edit-dialog/custom-field-edit-dialog.component.ts</context>
|
||||||
<context context-type="linenumber">56</context>
|
<context context-type="linenumber">57</context>
|
||||||
</context-group>
|
</context-group>
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
<trans-unit id="6672809941092516947" datatype="html">
|
<trans-unit id="6672809941092516947" datatype="html">
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
<div [formGroup]="objectForm.controls.extra_data">
|
<div [formGroup]="objectForm.controls.extra_data">
|
||||||
@switch (objectForm.get('data_type').value) {
|
@switch (objectForm.get('data_type').value) {
|
||||||
@case (CustomFieldDataType.Select) {
|
@case (CustomFieldDataType.Select) {
|
||||||
<button type="button" class="btn btn-sm btn-primary mb-2" (click)="addSelectOption()">
|
<button type="button" class="btn btn-sm btn-primary my-2" (click)="addSelectOption()">
|
||||||
<span i18n>Add option</span> <i-bs name="plus-circle"></i-bs>
|
<span i18n>Add option</span> <i-bs name="plus-circle"></i-bs>
|
||||||
</button>
|
</button>
|
||||||
<div formArrayName="select_options">
|
<div formArrayName="select_options">
|
||||||
|
@ -86,10 +86,6 @@ describe('CustomFieldEditDialogComponent', () => {
|
|||||||
component.dialogMode = EditDialogMode.CREATE
|
component.dialogMode = EditDialogMode.CREATE
|
||||||
fixture.detectChanges()
|
fixture.detectChanges()
|
||||||
component.ngOnInit()
|
component.ngOnInit()
|
||||||
expect(
|
|
||||||
component.objectForm.get('extra_data').get('select_options').value.length
|
|
||||||
).toBe(0)
|
|
||||||
component.addSelectOption()
|
|
||||||
expect(
|
expect(
|
||||||
component.objectForm.get('extra_data').get('select_options').value.length
|
component.objectForm.get('extra_data').get('select_options').value.length
|
||||||
).toBe(1)
|
).toBe(1)
|
||||||
@ -97,9 +93,13 @@ describe('CustomFieldEditDialogComponent', () => {
|
|||||||
expect(
|
expect(
|
||||||
component.objectForm.get('extra_data').get('select_options').value.length
|
component.objectForm.get('extra_data').get('select_options').value.length
|
||||||
).toBe(2)
|
).toBe(2)
|
||||||
|
component.addSelectOption()
|
||||||
|
expect(
|
||||||
|
component.objectForm.get('extra_data').get('select_options').value.length
|
||||||
|
).toBe(3)
|
||||||
component.removeSelectOption(0)
|
component.removeSelectOption(0)
|
||||||
expect(
|
expect(
|
||||||
component.objectForm.get('extra_data').get('select_options').value.length
|
component.objectForm.get('extra_data').get('select_options').value.length
|
||||||
).toBe(1)
|
).toBe(2)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -42,6 +42,7 @@ export class CustomFieldEditDialogComponent
|
|||||||
this.objectForm.get('data_type').disable()
|
this.objectForm.get('data_type').disable()
|
||||||
}
|
}
|
||||||
if (this.object?.data_type === CustomFieldDataType.Select) {
|
if (this.object?.data_type === CustomFieldDataType.Select) {
|
||||||
|
this.selectOptions.clear()
|
||||||
this.object.extra_data.select_options.forEach((option) =>
|
this.object.extra_data.select_options.forEach((option) =>
|
||||||
this.selectOptions.push(new FormControl(option))
|
this.selectOptions.push(new FormControl(option))
|
||||||
)
|
)
|
||||||
@ -61,7 +62,7 @@ export class CustomFieldEditDialogComponent
|
|||||||
name: new FormControl(null),
|
name: new FormControl(null),
|
||||||
data_type: new FormControl(null),
|
data_type: new FormControl(null),
|
||||||
extra_data: new FormGroup({
|
extra_data: new FormGroup({
|
||||||
select_options: new FormArray([]),
|
select_options: new FormArray([new FormControl(null)]),
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user