Skip to content

Commit 816de6a

Browse files
codepool867hb
andauthored
feat: Implement deleting custom form field (#5661)
Co-authored-by: hb <[email protected]>
1 parent 9314043 commit 816de6a

File tree

4 files changed

+15
-7
lines changed

4 files changed

+15
-7
lines changed

app/components/forms/wizard/attendee-step.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,12 @@ export default Component.extend(FormMixin, EventWizardMixin, {
1717

1818
showEditColumn: computed('editableFields.@each', function() {
1919
return this.editableFields?.some(field => field.isComplex);
20-
})
20+
}),
21+
22+
actions: {
23+
removeField(field) {
24+
this.data.customForms.removeObject(field);
25+
}
26+
}
2127
});
28+

app/components/forms/wizard/custom-forms/table.hbs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@
7171
<button class="ui compact icon positive circular button" data-tooltip="{{t 'Edit'}}" {{action @updateField field}}>
7272
<i class="pencil icon"></i>
7373
</button>
74-
{{!-- Hiding till implemented --}}
75-
<button class="ui compact icon negative circular button hidden-item" data-tooltip="{{t 'Delete'}}">
74+
<button class="ui compact icon negative circular button" data-tooltip="{{t 'Delete'}}" {{action (confirm (t "Are you sure you want to delete this?") (action @removeField field))}}>
7675
<i class="trash icon"></i>
7776
</button>
7877
{{/if}}

app/components/forms/wizard/custom-forms/table.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import Component from '@glimmer/component';
22

3-
43
interface CustomForm { isComplex: boolean }
54

65
interface Args {
76
fields: CustomForm[],
8-
updateField: (field: CustomForm) => void
9-
}
7+
removeField: (field: any) => void,
8+
updateField: (field: any) => void
9+
}
1010

1111
export default class CustomFormTable extends Component<Args> {
1212
get editColumn(): boolean {

app/templates/components/forms/wizard/attendee-step.hbs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@
4949
<div class="column">
5050
<Forms::Wizard::CustomForms::Table
5151
@fields={{this.editableFields}}
52-
@updateField={{action (mut this.field)}} />
52+
@removeField={{action "removeField"}}
53+
@updateField={{action (mut this.field)}}
54+
/>
5355
</div>
5456
</div>
5557
<Forms::Wizard::CustomFormInput

0 commit comments

Comments
 (0)